[feature] CMakeToolchain: prepend CMAKE_CURRENT_LIST_DIR instead of CMAKE_BINARY_DIR
See original GitHub issue- I’ve read the CONTRIBUTING guide.
Currently, toolchain file generated by CMakeToolchain sets CMAKE_MODULE_PATH and CMAKE_PREFIX_PATH like this:
# To support the cmake_find_package generators
set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH})
set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR} ${CMAKE_PREFIX_PATH})
It would be more robust to prepend CMAKE_CURRENT_LIST_DIR since conan install could be called from an other directory than root build tree.
Usually I call conan install in a subfolder (I like to call it conan_generators) to isolate specific conan generated build files from standard build artifacts.
I can live with this behavior, I inject absolute path of this subfolder (or any folder on my system where Ive called conan install) into CMAKE_MODULE_PATH & CMAKE_PREFIX_PATH through cmake command line, but it would be nice if toolchain file was more robust.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
[feature] Issues with the CMakeToolchain generator #11224
We are building custom workspace functionality for Conan 1 based on the existing code, but using CMakeToolchain and the new layout method ...
Read more >CMakeToolchain — conan 1.53.0 documentation
The CMakeToolchain is the toolchain generator for CMake. It will generate toolchain files that can be used in the command line invocation of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

AFAIK,
CMAKE_CURRENT_LIST_DIRdoesn’t refer to anyCMakeLists.txtfolder, but to the local folder where the cmake file referencing this variable lives. Since toolchain files is generated in the same folder than others conan generated file, it’s exactly the folder you want to append in CMAKE_MODULE_PATH & CMAKE_PREFIX_PATH.Merged https://github.com/conan-io/conan/pull/8810, will be released next 1.36