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

**URL:** <https://discourse.cmake.org/t/finding-program-really-build-target-to-be-run-by-a-ctest-test/2047>\
**Category:** Code\
**Created:** [October 22, 2020, 9:13pm UTC](https://discourse.cmake.org/t/finding-program-really-build-target-to-be-run-by-a-ctest-test/2047 "2020-10-22T21:13:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![starseeker](https://discourse.cmake.org/user_avatar/discourse.cmake.org/starseeker/32/4923_2.png) [@starseeker](https://discourse.cmake.org/u/starseeker)\
**Post date:** [October 22, 2020, 9:13pm UTC](https://discourse.cmake.org/t/finding-program-really-build-target-to-be-run-by-a-ctest-test/2047/1 "2020-10-22T21:13:29Z")

</div>

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 [https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#properties-on-tests](https://cmake.org/cmake/help/latest/manual/cmake-properties.7.html#properties-on-tests) but none of those seem to be what I need…

Thanks,  
CY

---

<div class="post-metadata">

**Author:** ![scivision](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/a87d85/32.png) [@scivision](https://discourse.cmake.org/u/scivision)\
**Post date:** [October 25, 2020, 12:48pm UTC](https://discourse.cmake.org/t/finding-program-really-build-target-to-be-run-by-a-ctest-test/2047/2 "2020-10-25T12:48:24Z")

</div>

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[¶](https://cmake.org/cmake/help/latest/prop_test/SKIP_RETURN_CODE.html#skip-return-code) if not.
