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

Daniel Pfeifer daniel at pfeifer-mail.de
Thu Oct 6 07:57:08 EDT 2016


On Wed, Oct 5, 2016 at 12:54 PM, Nils Gladitz <nilsgladitz at gmail.com> wrote:
> On 04.10.2016 11:20, Tobias Hunger wrote:
>>
>> On Mo, 2016-10-03 at 14:25 -0400, Brad King wrote:
>>>>
>>>> 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.
>>
>> Access to the list of defined tests would be nice to have in the
>> server-mode,
>> too:-)
>>
>> If some work is done in that direction, please keep server-mode in mind
>> when
>> designing the APIs. I would love to reuse them to expose that information
>> to
>> clients.
>
>
> This might be rare but the tests that cmake knows about might differ from
> the tests that ctest knows about given that tests can be dynamically defined
> through TEST_INCLUDE_FILE[1].
>
> I've never used it that way but I was considering e.g. querying test
> binaries (produced at build time) for the tests they define and making those
> available dynamically when ctest processes CTestTestfile.cmake. This is in
> contrast to e.g. FindGTests.cmake's GTEST_ADD_TESTS() which tries to
> accomplish the same thing at configuration time by parsing test sources
> instead.

+1. I wrote about that approach here:
http://purplekarrot.net/blog/cmake-and-test-suites.html


More information about the cmake-developers mailing list