[cmake-developers] Is there a way in CMake to get a list of all CTest tests added with add_test?

Brad King brad.king at kitware.com
Mon Oct 3 11:21:39 EDT 2016


On 10/03/2016 11:17 AM, Clifford Yapp wrote:
> One of the functions we are wrapping in our build with CMake's "_"
> prefix debugging mechanism is add_test.  Looking at why we do that, it
> should be possible to avoid wrapping if we can get access in CMake to
> the list of all test build targets defined with add_test.
> Essentially, we need to add them to some custom target dependencies,
> and it should be OK to do that after all tests are added if we can get
> access to the list of targets within CMake.
> 
> Is there a property somewhere that exposes this list?

I don't recall one off the top of my head.  Even if there were,
the `set_property(TEST ...)` only works on tests in the invoking
directory.  There is no global scope for test names.

Some projects use a `myproj_add_test()` wrapper around their
`add_test()` calls specifically to provide customizations.

-Brad



More information about the cmake-developers mailing list