1 # CheckTarget.cmake 2 # 3 # Defines a custom target 'check', which gathers test programs like 'make check' 4 # This is taken from https://cmake.org/Wiki/CMakeEmulateMakeCheck 5 # 6 # What you do is to call command: 7 # add_check_test(_name) 8 # where _name is the name of the test, as defined by add_executable(). 9 # Note it is a good idea to use EXCLUDE_FROM_ALL within the add_executable(). 10 11 include(CTest) 12 13 # Disable this to not have verbose tests 14 set(CMAKE_CTEST_COMMAND ${CMAKE_CTEST_COMMAND} -V) 15 16 add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) 17 18 macro(add_check_test _name) 19 add_test(NAME ${_name} COMMAND ${_name}) 20 add_dependencies(check ${_name}) 21 endmacro(add_check_test)