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

Clifford Yapp cliffyapp at gmail.com
Tue Oct 4 11:22:57 EDT 2016


On Mon, Oct 3, 2016 at 2:25 PM, Brad King <brad.king at kitware.com> wrote:
> On 10/03/2016 12:14 PM, Clifford Yapp wrote:
>> so what we need is not actually the test names themselves,
>> but a list of the executables used to run tests that are also defined
>> as build targets.
> [snip]
>> The list we need would thus be built up to contain all COMMAND
>> arguments to add_test that are also build targets in CMake.
>
> The list would also need to include targets mentioned in generator
> expressions such as `$<TARGET_FILE:...>`.  This will almost certainly
> be better done as a CMake feature implemented in C++.  This was actually
> an early design philosophy: do the hard stuff in C++ so that complex
> logic is not needed in CMake-language code.

Sounds like a plan.  I must confess I'm not familiar with the use of
generator expressions yet (we've been holding off requiring CMake 3,
but I see Debian stable has now updated so it's probably time) but
I'll start catching up on my homework since I think they'll be needed
to "modernize" some of our features that are still using the LOCATION
property.

>> dependency of the custom target "check".  Then, when the custom target
>> "check" executes, it will first make sure all of the test executables
>> (and their dependencies) have  been built.
>
> Why do you need a "check" target instead of the CMake-defined "test"
> target?

Primarily because we have experimental CTest targets that are in
various stages of development, and not ready for prime time.  check is
the target we use when the test is ready to be used as a determining
factor in whether something has broken.

> One could teach cmGlobalGenerator::AddGlobalTarget_Test an option to add
> a dependency on the "all" target from "test".  Most projects do not have
> so many non-test targets that they cannot afford to build "all" before
> testing.

While we could "afford" to, we have quite a large number of doc
targets (for example) that aren't needed for make test so it would be
a noticeable increase.

> Alternatively the implementation could directly add dependencies
> on targets referenced by tests.  That may be a bit trickier though.

That would be ideal, if it can be done.

Cheers,
CY


More information about the cmake-developers mailing list