-
Notifications
You must be signed in to change notification settings - Fork 984
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
[question] CMakeToolchain: When use cached_variables vs variables #11937
Comments
Do you have some examples of such variables? that would help also to learn about the use cases. I ask this question to myself when implementing things, and it typically depends on the variable itself. |
Two real PRs which are open right now: |
This has come up as well in other issues so I'll try to summarise.
There are practical differences:
This second behaviour is where we may find issues in the following scenarios:
There may be more cases that we haven't seen because this hasn't been used more widely. The recommended approach (at least in Craig Scott's book) is for CMake toolchain to define as few variables as possible. Some variables are intended to be defined by the toolchain rather than other means, but for everything else we need to consider that the project may have its own defaults that a user may override via command line We are dealing with a tradeoff: we also don't want users in local workflows to have to define variables manually when they invoke CMake themselves, so the "single" As for recipes in Conan Center Index, in the interim, and under an assumption that those are built by CI in Conan Center, or built with |
Okay, we have an answer. I'll use it as recommendation for future PRs. /cc @SpaceIm @jwillikers |
From what I've seen, they are passed as From my experimentations:
|
Yeah, that fits with why I was using them in the first place. @uilianries I'll update my PR's to use cache variables. Thanks for opening the issue. |
@jwillikers Sorry! 😓 |
The documentation only explains
CMakeToolchain.variables
andCMakeToolchain.cached_variables
features, one is better for multiple configuration and another is single configuration:https://docs.conan.io/en/latest/reference/conanfile/tools/cmake/cmaketoolchain.html#variables
But it's not clear when each one should be used, based on real examples.
So far, we are migrating recipes in CCI and there is a doubt about which one should be adopted by default when using
CMakeToolchain
.The text was updated successfully, but these errors were encountered: