Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMakeToolchain generator sets CMAKE_FRAMEWORK_PATH #14746

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

thorsten-klein
Copy link
Contributor

@thorsten-klein thorsten-klein commented Sep 15, 2023

Changelog: (Feature): CMakeToolchain generator sets CMAKE_FRAMEWORK_PATH to host package roots

Let cmake find_package() do its default search procedure instead of maintaining a list of directories as cpp_info.builddirs.

With this change users need to maintain only cmake module paths in cpp_info.builddirs (containing FindXXX.cmake).
cmake config paths (containing XXX-Config.cmake) do not need to be maintained anymore.
conan will add each host package root path automatically to CMAKE_FRAMEWORK_PATH, which allows cmake to find them automatically when doing its default search procedure
(Ref: https://cmake.org/cmake/help/latest/command/find_package.html#config-mode-search-procedure)

Statement from Kitware:

The CMAKE_FRAMEWORK_PATH variable will be used by find_* commands, on all platforms. 
The main difference is that by default, on non-Mac platforms, find_* will first look for 
CMAKE_PREFIX_PATH variable entries and then  CMAKE_FRAMEWORK_PATH. 
Order is inverted on Mac by default. 

Ref: #14334

  • Refer to the issue that supports this Pull Request.
  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • [x ] I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

support cppinfo.frameworkdirs also on non-apple systems.
Consider root directories of "host" context  by default:
they will be prepended to CMAKE_FRAMEWORK_PATH (so that they are
considered after CMAKE_PREFIX_PATH).
@thorsten-klein thorsten-klein changed the base branch from release/2.0 to develop September 15, 2023 07:51
@thorsten-klein thorsten-klein changed the title 14334 cmake framework path CMakeToolchain generator sets CMAKE_FRAMEWORK_PATH Sep 15, 2023
@thorsten-klein
Copy link
Contributor Author

Ref: #14748

@thorsten-klein
Copy link
Contributor Author

thorsten-klein commented Oct 16, 2023

We are now setting environment variable CMAKE_FRAMEWORK_PATH which is also considered by cmake automatically. This solves our issue well. But nevertheless it would be benefitial for other users if the CMakeToolchain generator sets this cmake variable and works out of the box.

The big advantage what I see is:
if the CMAKE_FRAMEWORK_PATH is used, conan does not need to store any information about the builddirs anymore. cmake will automatically search within some default directories when doing find_package(), find_library() or find_path(). These are exactly the things within host context.
find_program() (which should only search in build context) is not affected by this variable

Ref: #14748

I guess that with this change also some cmake variables (which are currently set in conan_toolchain.cmake) could become obsolete. But this can be checked in a subsequent PR then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant