I am creating an executable using the add_executable(foo sources.cpp)
then I would like to have a target that runs foo, so right now I'm doing this:
add_custom_target(run_foo
COMMAND ${CMAKE_BINARY_DIR}/test/foo
DEPENDS foo
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
it works now, but I feel like I'm doing it wrong by hardcoding the path to the binary in "COMMAND". Isn't there a way to get the path to the binary from foo
?