-
Notifications
You must be signed in to change notification settings - Fork 993
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
add BUILD_TESTING=OFF to presets if tools.build:skip_test #11935
add BUILD_TESTING=OFF to presets if tools.build:skip_test #11935
Conversation
This looks good but I have a question!
In this PR, we would be a going a step beyond that - and potentially not building tests at all (depending on whether or not the projects use This can be convenient as on some projects this can save considerable compilation time, but on the other hand in some projects the tests are the first attempt at linking things that consume the library and it can serve as an early way of catching linking issues. Although it could be argued that is the purpose of the |
Yes, I would say that the expected behavior of the Conan integrations, regarding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this is the expected behavior, and the user will save time whenever he does not want to run all the tests.
if cmake_make_program: | ||
cmake_make_program = cmake_make_program.replace("\\", "/") | ||
cache_variables["CMAKE_MAKE_PROGRAM"] = cmake_make_program | ||
|
||
if "CMAKE_POLICY_DEFAULT_CMP0091" not in cache_variables: | ||
cache_variables["CMAKE_POLICY_DEFAULT_CMP0091"] = "NEW" | ||
|
||
if "BUILD_TESTING" not in cache_variables: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about CMakeToolchain.variables
? Is it a possible scenario, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds like CMakeToolchain.variables
should be for user variables, while everything that is a CMake built-in, should be to cache_variables
otherwise there is a risk that the variables
will not have enough priority. @jcar87 wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say that's a good approximation!
I can find widespread evidence on GitHub that BUILD_TESTING
is treated as a cache variable by projects:
-
For example here by calling
option()
-
It will also be a cache variable if the user provides it via
-DBUILD_TESTING=ON/OFF
- in this case, the user's preference will take precedence and be respected regardless of whether we define it as acache_variable
or the project sets anoption()
-
So I think the way it currently is in this PR is the safest and least likely to have side effects - especially if there's any chance projects define or reference BUILD_TESTING
before the first call to project()
(have found examples here and here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, lets recommend that in the docs then 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not in the opposite of using cached_variables
, but still, users are free to use both and it will have a different behavior, depending the usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but if we explicitly say it in the docs, they should use each one for the documented cases, so they will not be "free" to use them invariantly for all cases.
Changelog: Feature: Add
BUILD_TESTING=OFF
to CMakeToolchain presets iftools.build:skip_test
.Docs: conan-io/docs#2713
Close #11905