Skip to content

Conversation

theodelrieu
Copy link

Hello,

I'm opening this PR to solve an issue I have with my setup, here is a short summary:

I'm using Conan at work to manage C++ dependencies, and we are trying to cross-build to WebAssembly with Emscripten. To do so, I created a "Toolchain package" which sets correct flags automatically for consumers of this package.

For CMake builds, I simply exposed the CMAKE_TOOLCHAIN_FILE to point to Emscripten.cmake.

The thing is find_package now fails to find any dependency, due to the CMAKE_FIND_ROOT_PATH_MODE_PACKAGE set to ONLY.

While this is a valid behavior for regular CMake use-case, it is quite inconvenient for us, since Conan packages are all located in different folders, but are still found easily with CMAKE_PREFIX_PATH being set with all the package folders' paths. However, ONLY prevents it from working, and I'd like to set every MODE_XXX setting to BOTH.

So I simply mimicked what's done in the Android NDK's toolchain file and added some if/endif guards around each set(). It allows users to specify a different value if they need. This works great for us when cross-building to Android with Conan.

Note:

I first tried to simply include Emscripten's Toolchain from a custom toolchain file, and reset those variables. However, the CMakeSystemSpecificInformation.cmake includes Emscripten.cmake right before processing the customer CMakeLists.txt and thus the variables are overriden with the default values.

This is useful for custom CMake toolchain files which include
Emscripten's.
@kripken kripken requested a review from juj January 9, 2019 19:48
@gabrielcuvillier
Copy link
Contributor

Did you try to update the CMAKE_FIND_ROOT_PATH with your own paths ?
eg. list(APPEND CMAKE_FIND_ROOT_PATH <path_to_conan_root>)

It could possibly work. At least, I am solving a similar issue like this...

@sbc100 sbc100 closed this Jan 30, 2020
@sbc100 sbc100 reopened this Jan 31, 2020
@sbc100 sbc100 changed the base branch from incoming to master January 31, 2020 01:19
@traversaro
Copy link

Did you try to update the CMAKE_FIND_ROOT_PATH with your own paths ?
eg. list(APPEND CMAKE_FIND_ROOT_PATH <path_to_conan_root>)

It could possibly work. At least, I am solving a similar issue like this...

We are experiencing a similar issue in vcpkg (see microsoft/vcpkg#11323 (comment)) and, unless we are doing something wrong, appending the desired root to CMAKE_FIND_ROOT_PATH is not sufficient.

@traversaro
Copy link

Did you try to update the CMAKE_FIND_ROOT_PATH with your own paths ?
eg. list(APPEND CMAKE_FIND_ROOT_PATH <path_to_conan_root>)
It could possibly work. At least, I am solving a similar issue like this...

We are experiencing a similar issue in vcpkg (see microsoft/vcpkg#11323 (comment)) and, unless we are doing something wrong, appending the desired root to CMAKE_FIND_ROOT_PATH is not sufficient.

It turns out that solution was working, but it is also necessary to add / to the CMAKE_PREFIX_PATH, see microsoft/vcpkg#11323 (comment) .

Base automatically changed from master to main March 8, 2021 23:49
@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

@stale stale bot added the wontfix label Apr 16, 2022
@stale stale bot closed this Jun 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants