CMakePackage: remove -DBUILD_TESTING flag#37967
Conversation
haampie
left a comment
There was a problem hiding this comment.
Yeah, this was a mistake. Thanks for fixing this.
|
The arguments for defining it still stands. It saves compile time for projects that use ctest and conditional test compilation. The warning may be annoying, but it's not a problem. I can think of the following possible solutions to get rid of the warning:
|
|
What percentage of packages use CTest? Can we manually add it to those packages as needed? |
If there are quite a few, and all following the same pattern, we can also extract a mixin. Packages that are known to use CTest would just inherit from it. |
|
The Even if packages don't implement tests using ctest, it's the current expectation of spack that they do. Defining At the end of the day it is a warning, which can be disabled or ignored. Anyway, I don't have the full picture here. Take this as feedback from the perspective of a package maintainer. :) |
|
Disabling the current feature of enabling the default testing flag for CTest in CMake automatically seems a bit heavy handed to fix a configuration warning in a subset of CMake packages.
From my experience nearly all of the CMake packages that implement unit tests are using CTest unless CMake is a secondary build system.
I am not opposed to this, but I think it is maybe a bit overkill if the only motivation is to drop a configuration warning. |
|
What I meant with "this was a mistake": Some project conditionally include To me setting See also #30374 (comment) |
Adding a feature to enable a flag for CTest in CMake automatically seems a bit heavy handed to support testing in a subset of CMake packages. I guess I'm not very familiar with the CMake ecosystem so I'm not sure how common CTest is. But I'm still in favor of adding this flag to packages that use it instead of adding it globally. |
kwryankrattiger
left a comment
There was a problem hiding this comment.
I don't think this should go in until there is a better understanding of what the CMakePackages in spack are doing. I don't think fixing a warning is worth quietly disabling testing in packages that were previously getting this enabled through the CMakePackage.
|
|
Of the ~80 packages I have installed, more than half issued this warning, meaning less than half use CTest if I'm understanding correctly. |
|
Taking a step back from this, there are 4 cases of how CMake projects define tests:
Before the default def cmake_args(self):
return [define("BUILD_TESTING", self.run_tests)]This, however, means that tests always compile in case a package maintainer doesn't add this statement, even if they aren't requested by spack. If we agree that def cmake_test_args(self):
return [define("BUILD_TESTING", self.run_tests)]This way, a package that uses Other packages that don't use def cmake_test_args(self):
return [define("ACTIVATE_TESTING", self.run_tests),
define("PLEASE_BUILD_MY_TEST_BINARIES", self.run_tests)]The last problem with this suggestion are CMake projects without any unit tests. The main benefit of the default is that packages not using the I personally wasn't aware of this |
If you introduce I'd rather have packages enable tests explicitly like this PR is requiring.
|
I absolutely agree. It needs documentation.
Currently, spack provides default variants for
Sadly, this is the case for many things in CMake.
Absolutely agree. I personally think that this inconvenience is worth saving potentially many CPU hours per build. Now that the default build_type changed to release, packages using IPO will waste a long time linking test binaries, especially if they use the default linker. Even if energy bills aren't an issue, blocking compute time may be.
As mentioned before,
Not sure if I understand your point. Packages would override Another possibility to move on could be to:
|
I think this is the biggest sticking point of my PR. No one really wants to download and extract tarballs for all 1.1K CMake packages in Spack, grep for CTest in the CMakeLists.txt, and update those. Here's an alternative idea that may make everyone happy. What if we grep the root CMakeLists.txt file and look for evidence of CTest usage, then append that flag if it's used? Not sure if CTest is always mentioned in the root CMakeLists.txt or if this would require us to recursively search for all of them. But if there's a consistent string it shouldn't be that hard to find. Are there any downsides to this solution? |
|
For a variety of…arcane wart-shaped reasons, |
Spack packages list their maintainers, so one could also mention them in a new issue and ask them if they could have a look at their packages. This distributes the work nicely and adjusting package configs should be way easier for people knowing the software. For 41d2161 that's 1096 packages and a total of 382 maintainers: $ rg CMakePackage -l | grep "builtin/packages" | wc -l
1096
$ rg CMakePackage -l | grep "builtin/packages" | cut -d/ -f6 | xargs spack maintainers | wc -l
382Not sure if GitHub has any mention limitations in place though. |
|
There are mention limitations but you can distribute across multiple comments. The problem is that most packages don't have maintainers. |
40969e8 to
b91c3b7
Compare
|
@spackbot rebuild everything |
|
I've started that pipeline for you! |
|
@spackbot rebuild everything |
|
I've started that pipeline for you! |
|
@spackbot run pipeline |
|
I've started that pipeline for you! |
e45dcd3 to
b4a88d8
Compare
There was a problem hiding this comment.
I'm sorry, but I'm not a fan of this magic either :(
It's going to lead to false positives and false negatives:
# include(CTest)include (CTest)
also not robust if included in e.g. test/CMakeLists.txt.
This magic conditional makes it only confusing.
And again, it's defining the variable that should be defined as a consequence of include(CTest), packages may rely on this option for knowing whether CTest was included. I don't agree with @fsimonis's assessment that that is a build system bug:
As mentioned before, BUILD_TESTING is defined as an option, which purpose is to be user-overridable. These are/were bugs in the build-systems of the packaged projects.
I would still suggest to stick to the original revert that drops -DBUILD_TESTING and we'll fix things on a per package basis. There simply is not a universal standard for enabling/disabling tests in cmake. Just like there's no universal standard to build shared or static libraries. Every cmake project is a unique snowflake.
|
I'm fine with reverting back to just dropping the flag, but will give others time to comment first. |
|
I agree with @haampie. If the choice is between adding magic logic to CMakePackage or dropping the flag entirely, I would prefer to just drop it. I think people like @eugeneswalker and @wspear who depend on the Spack testing heavily may be able to inform which packages to prioritize in a followup. |
b4a88d8 to
3c6f82e
Compare
|
Sounds like we have a consensus. Should be ready to merge! |
-DBUILD_TESTINGis not a general CMake flag that exists for all CMake packages, it only exists when CTest is used in CMakeLists.txt. The majority of packages I build issue the following warning:For packages that do use CTest, this flag should be added only to those packages, not all packages.