Allow custom targets and commands depend on "install" target
This would be really helpful for running for example integration test that needs install target to be completed. So instead of make install -j && ctest
only make check -j
could be needed (supported by custom defined target that DEPENDS
on install
):
include(CTest)
add_custom_target(check
COMMAND echo [----] Running tests
USES_TERMINAL
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C Debug
DEPENDS install)
add_test(NAME "Is_Runable"
WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin
COMMAND $<TARGET_FILE:exampleApp>)
Other common use case would be replacing make install -j && cd $CMAKE_INSTALL_PREFIX/bin && ./exampleApp ; cd -
with make run -j
supported by custom target that DEPENDS
on install
:
add_custom_target(run
WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/bin
USES_TERMINAL
COMMAND ./exampleApp
DEPENDS install)
These are useful since running the app might need some build time generated resources that are put together into $CMAKE_INSTALL_PREFIX folder by install
target and it is impractical to provide them to executables with other means.