[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 14:25:29 EDT 2016
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.
> 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?
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. Alternatively the implementation could directly add dependencies
on targets referenced by tests. That may be a bit trickier though.
-Brad
More information about the cmake-developers
mailing list