Finding program (really, build target) to be run by a CTest test?

Is there any way to use get_test_property to report the program to be run to execute the test?

Background: I’m using one of the standard workarounds for the current inability to make Ctest tests depend on the building of CMake targets: defining a custom “check” target that runs CTest to run the tests, and hanging the exec dependencies on the check target. I’m trying to use the TESTS directory property introduced in 3.12 to automatically add build target dependencies to the “check” target, without having to add more per-test logic (or the gnarly trick we’re currently using of wrapping add_test and calling _add_test.) I can use the TESTS property to get a list of tests, but thus far I’ve not found a way to extract from the test definition the information about what program (really, add_executable target) it is slated to be run. Does anybody know of a way to extract that information? I found but none of those seem to be what I need…


This is a completely separate approach, but I also have a project where it’s difficult for CMake to know what will be runnable until test time. I write add_test to call simple Python scripts that determine if the test can be run and return code 77 for SKIP_RETURN_CODE if not.