-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[bug] tools.build:skip_test and shared option behavior inconsistent #17748
Comments
Hi @aagor Thanks for your feedback. I think this is related to #12995 and this issue #12994 (could be a duplicated of the issue) that goes back to #7832. In summary, the issue is that the toolchain/presets defines its values as cache variables, because there are too many existing situations with existing The downside is that when some configurations change in Conan and using the "local flow", that is the So it is not possible to have everything, and the current proposal is the one that tries to minimize inconvenience:
|
Hi, thanks for your explanation. I think the problematic behavior may have been mitigated with CMake Policy CMP0126. Nevertheless I don't understand why the |
Yes, but CMake Policy CMP0126 is CMake>3.21, and the basic behavior keeps working with CMake 3.15
I think that disables the possibility for users to dynamically define things. Consider that the most popular approach is to do |
I understand that workflow and it's true that changing things via CMake CLI wouldn't work if This way the variables would be set to the ones defined by conan on the first invocation and when using For the But for |
But
But isn't this more like a building and IDE things? Like this enabled define certain targets in the IDE, and developers just build the targets they want, without really building or running tests. This is true also for other languages and technologies, the environment is setup, including the tests (when working as developer, tests typically disabled in CI), and then the developer has everything in the IDE and works from there, not really going to the terminal to "reinstall" or reconfigure the project to drop or enable testing. The Note also that Finally, it is relevant to understand that before we introduced the def build_requirements(self):
if not self.conf.get("tools.build:skip_test"):
self.test_requires("mytestdep/version") That means that enabling or disabling tests also implied relevant changes in the dependency graph (as I am pinging @jcar87 for extra feedback on this matter. |
Hi, very thanks for your detailed explanation.
Yeah, I know, it's at least not trivial to solve.
I think, workflows differ, some developers do everything in IDE, some uses terminal a lot.
I checked conans source and don't understand why diff --git a/conan/tools/cmake/presets.py b/conan/tools/cmake/presets.py
index cd7e3db27..cfcb5965c 100644
--- a/conan/tools/cmake/presets.py
+++ b/conan/tools/cmake/presets.py
@@ -51,8 +51,7 @@ class _CMakePresets:
cache_variables["CMAKE_POLICY_DEFAULT_CMP0091"] = "NEW"
if "BUILD_TESTING" not in cache_variables:
- if conanfile.conf.get("tools.build:skip_test", check_type=bool):
- cache_variables["BUILD_TESTING"] = "OFF"
+ cache_variables["BUILD_TESTING"] = "OFF" if conanfile.conf.get("tools.build:skip_test", check_type=bool) else "ON"
preset_path = os.path.join(conanfile.generators_folder, "CMakePresets.json")
multiconfig = is_multi_configuration(generator) With this change, a |
Describe the bug
Environment details: Linux, Conan 2.12.1
When testing conans
tools.build:skip_test
config option, I encountered that conansskip_test
and the generated CMake cache variableBUILD_TESTING
are diverting.Preparation:
Consider the following after the preparation:
Modify
tests/test.cpp
.Execute
conan build . -c tools.build:skip_test=True
.No tests are build, no tests executed. Expected behavior.
Modify
tests/test.cpp
again.Execute
conan build .
.No tests are build, old tests are executed. Not expected and inconsistent.
Modify
tests/test.cpp
again.Execute
conan build . -c tools.build:skip_test=False
.No tests are build (not expected), old tests are executed (test execution itself is fine).
At least for the third case, when I explicitly set
skip_test
to false, I would expect the tests to build and the CMake cache variableBUILD_TESTING
to be overriden toON
. As conan doesn't have something similar to CMake cache variables, I think it would be more consistent ifBUILD_TESTING
always follows conanstools.build:skip_test
config option.The exact same problem exists with conan packages
shared
option andBUILD_SHARED_LIBS
CMake cache variable (and possibly others).Is this intended? Is there a workaround?
How to reproduce it
No response
The text was updated successfully, but these errors were encountered: