question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[feature] CMakeToolchain: remove CMAKE_FIND_PACKAGE_PREFER_CONFIG ON

See original GitHub issue

CMAKE_FIND_PACKAGE_PREFER_CONFIG ON in CMakeToolchain originally addressed this problem:

  • CMakeDeps is supposed to be able to work in conjunction with CMakeDeps (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) (without CONFIG or NO_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 CMakeLists find_package(ZLIB REQUIRED CONFIG).

But now:

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:open
  • Created 2 years ago
  • Comments:20 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
SpaceImcommented, May 17, 2022

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.

1reaction
memshardedcommented, Jan 20, 2022

conan won’t force anything. It’s the opposite with my proposal, conan would allow you to write a good agnostic CMakeLists. If they want to use expat-config.cmake, they must write find_package(expat REQUIRED CONFIG), because it’s what would work outside of conan.

Ok, yes, now I see what you mean, thanks for explaining!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found