CTest: Request way to hide automatically generated CTest targets
Request
Please could there be an official way for projects to instruct include(CTest)
to either not add the 20 or so extra targets such as ContinuousMemCheck
- or to remove those targets afterwards.
Example use case: Projects that do not use CDash, and that pull in CMake code from external projects which unconditionally call include(CTest)
- and where developers are using IDEs that populate their UI with all targets.
Background
I understand that using enable_testing()
enables use of CTest
and that include(CTest)
does extra work to enable testing with CDash
. It also adds about 20 extra targets like:
Continuous
ContinuousBuild
ContinuousConfigure
ContinuousCoverage
ContinuousMemCheck
ContinuousStart
ContinuousSubmit
ContinuousTest
ContinuousUpdate
Experimental
ExperimentalBuild
ExperimentalConfigure
ExperimentalCoverage
ExperimentalMemCheck
ExperimentalStart
ExperimentalSubmit
ExperimentalTest
ExperimentalUpdate
Nightly
NightlyBuild
NightlyConfigure
NightlyCoverage
NightlyMemCheck
NightlyStart
NightlySubmit
NightlyTest
NightlyUpdate
In small projects with just 2 or 3 targets, those extra targets really clutter up IDEs.
Problem
The problem is that there are various ways to use CMake with 3rd-party dependencies, where one of those dependencies itself does include(CTest)
, forcing the extra targets on all users.
Example
Example CMake that triggers the problem:
message(NOTICE "Fetching Catch2...")
FetchContent_Declare(Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.11.1)
FetchContent_MakeAvailable(Catch2)
After that, even the tiniest small project - with one library and one test program - will have all these extra targets.
References to the problem
- Hide automatically generated CTest targets
- CMake in QtCreator 4.3 shows many automatic targets, how to remove/hide them?
Workarounds
- In CLion, it is possible to use "Edit Configurations" to select and delete all the unwanted configurations. This is tedious and error-prone, though
- Put in a pull request to every project you depend on, to hide their
include(CTest)
behind an option, or move toenable_testing()
- and then, if they are accepted, update all your projects to set the options... This fails if any one dependency declines the request.- I see that Catch has already declined to do this
- Use the hack in this answer - adding this line, with explanatory comment, before every time you pull in another dependency...
set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1)
Here is a GitHub search showing where others have done this already.