[feature] CMakeToolchain: remove CMAKE_FIND_PACKAGE_PREFER_CONFIG ON
See original GitHub issue- I’ve read the CONTRIBUTING guide.
CMAKE_FIND_PACKAGE_PREFER_CONFIG ON
in CMakeToolchain
originally addressed this problem:
CMakeDeps
is supposed to be able to work in conjunction withCMakeDeps
(cmake_find_package
&cmake_find_package_multi
removed in conan v2).CMakeDeps
was supposed to generate only CMake config files.- by default CMake looks first for Find files, then config files in a call like
find_package(foo)
(withoutCONFIG
orNO_MODULE
). - it would have been an issue for consumers/recipes depending on recipes packaging libraries listed in https://cmake.org/cmake/help/latest/manual/cmake-modules.7.html#find-modules, since those modules would have take precedence over config files generated by
CMakeDeps
. Indeed, no one in C++ ecosystem has ever written in its CMakeListsfind_package(ZLIB REQUIRED CONFIG)
.
But now:
CMakeDeps
has learned generation of Find module files when a recipe setcmake_find_mode
property toboth
inpackage_info()
.- all CCI recipes listed in https://cmake.org/cmake/help/latest/manual/cmake-modules.7.html#find-modules have been updated so that CMakeDeps will always generate both Find & config files.
There is no more reason to keep CMAKE_FIND_PACKAGE_PREFER_CONFIG ON
. it may have undesirable side effects. For example an agnostic CMakeLists looking for one of the files in https://cmake.org/cmake/help/latest/manual/cmake-modules.7.html#find-modules, may ends up with the config file which have different target names than the Find file (there are few cases like freetype and expat, which have built-in CMake modules files in CMake installation, and also provide config files. Target names are different but not the Find & config file names).
Issue Analytics
- State:
- Created 2 years ago
- Comments:20 (17 by maintainers)
Top Results From Across the Web
CMakeToolchain — conan 1.43.4 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 >cmake-toolchains(7) — CMake 3.25.1 Documentation
Introduction¶. CMake uses a toolchain of utilities to compile, link libraries and create archives, and other tasks to drive the build.
Read more >Create Custom CMake Toolchain Definition - MathWorks
When you run, for example, the slbuild function or a software-in-the-loop (SIL) simulation, the build process uses the custom toolchain to build generated...
Read more >How to set compile features in cmake toolchain file for known ...
Also I try to set CMAKE_CXX_KNOWN_FEATURES. You most probably forgot to clear your build tree. Variables in toolchain file are not ...
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
Just follow upstream convention? I don’t understand all these questions. It’s even explicitly described in https://cmake.org/cmake/help/latest/module/FindVTK.html
FindVTK.cmake is the module file VTKConfig.cmake is the config file
So a vtk recipe should follow these names in
package_info()
, it’s the only criteria.Ok, yes, now I see what you mean, thanks for explaining!