I'm using CMake and CTest in CLion. Annoyingly, CTest generates a load of targets that I don't care about:
These all show up in CLion. Quite annoying as I'm sure you'll agree. Is there solution to remove them? I'm open to any solution:
Unless you are using CDash, the solution is very simple.
In your CMakefile replace
include(CTest)
with
enable_testing()
Hack warning - below hack relies on an internal implementation detail (CTestTargets.cmake), and thus not guaranteed to work with any CMake version.
If one cannot avoid include(CTest)
, since certain CTest functionalities are needed and aren't available by enable_testing()
, such as Valgrind integration, generation of the automatic CTest targets could be avoided altogether using the following hack:
set_property(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1) # hack to prevent CTest added targets
include (CTest)
Setting CTEST_TARGETS_ADDED
to 1
prior to including CTest
will prevent generation of the automatic CTest targets.
I've tested this with CMake 3.6, and it should be working through CMake 3.19.6 (in which the CTEST_TARGETS_ADDED
macro is still being used).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With