CMake TARGET_FILE generator expression

The CMake generator expression TARGET_FILE yields the full path to a binary target file. This is useful with add_custom_command() and add_test() when a script is used as part of those commands. For CMake native commands, it’s usually not necessary to use TARGET_FILE.

Example:

add_executable(my_exe main.c)

find_package(Python COMPONENTS Interpreter REQUIRED)

add_test(NAME scripted
COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example.py $<TARGET_FILE:my_exe>
)

When using scripts it’s a good practice to also specify the full path as above.