Hide automatically generated CTest targets
Asked Answered
O

4

8

I'm using CMake and CTest in CLion. Annoyingly, CTest generates a load of targets that I don't care about:

  • 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

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:

  1. Get CTest to not generate them in the first place.
  2. Delete the targets after CTest has created them.
  3. A setting in CLion to hide them.
Ostracize answered 6/7, 2017 at 12:48 Comment(2)
See this Q/A on SO. That probably solves also your problems.Jarry
Just to note that I've logged a feature request for CMake to provide a way to prevent the creation of these targets: gitlab.kitware.com/cmake/cmake/-/issues/21730Discriminator
O
1

A possible solution that I'm not sure works 100% is to go to Run->Edit Configurations... in CLion and simply delete all the targets you don't want.

This seems to survive reloading the CMake configuration, and make clean.

Ostracize answered 6/7, 2017 at 12:53 Comment(0)
I
11

Unless you are using CDash, the solution is very simple.

In your CMakefile replace

include(CTest)

with

enable_testing()
Interpellation answered 11/8, 2018 at 15:12 Comment(0)
S
6

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).

Shadrach answered 28/7, 2019 at 11:24 Comment(0)
P
2

A simple solution to manage the clutter that doesn't require deleting those targets (so you can easily go back to them if the need arises) is to create a sub-folder in the Edit Configurations... menu where you can drag and move all the entries you are not interested to see at the top level.

Note that this applies more generally to various target types, not just test related ones.
Here is an example here where I put all that stuff in a misc folder :

enter image description here

Payee answered 18/3, 2022 at 8:20 Comment(0)
O
1

A possible solution that I'm not sure works 100% is to go to Run->Edit Configurations... in CLion and simply delete all the targets you don't want.

This seems to survive reloading the CMake configuration, and make clean.

Ostracize answered 6/7, 2017 at 12:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.