Hide automatically generated CTest targets

隐身守侯 提交于 2019-12-07 14:16:20

问题


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.

回答1:


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

In your CMakefile replace

include(CTest)

with

enable_testing()



回答2:


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.




回答3:


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.15 (in which the CTEST_TARGETS_ADDED macro is still being used).



来源:https://stackoverflow.com/questions/44949354/hide-automatically-generated-ctest-targets

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!