Feature Request: Make <command> argument to add_test available as a property of the test
Per https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#properties-on-tests it doesn't seem to be currently possible to look up the argument passed to add_test (https://cmake.org/cmake/help/latest/command/add_test.html) when the test was originally defined.
One of the standard workarounds for making a testing target that depends on build targets in addition to tests is to define a custom target that runs a ctest command to trigger the tests, and has the custom target depend on the associated build targets. It would be very helpful, when building up such a target, to have the value passed to add_test available as a property on the test (maybe a COMMAND property?)
If we define an executable:
add_executable(test_exe test_src.c)
and then define a test that uses that executable:
add_test(NAME test1 COMMAND test_exe)
what I'm looking for is for
get_property(T_CMD TEST test1 PROPERTY COMMAND)
to return "test_exe"
The idea would be to enable something like the following:
foreach(dir ${DIR_LIST})
get_property(DIR_TESTS DIRECTORY "${dir}" PROPERTY TESTS)
foreach(t ${DIR_TESTS})
get_property(T_CMD TEST ${t} PROPERTY COMMAND)
if(TARGET "${T_CMD}")
add_dependencies(check ${T_CMD})
endif()
endforeach()
endforeach()
where "check" is a custom target that runs a ctest command.