blob: 1e74f90fe0d355dc5be7cfa9bbf76fd4df4fb92f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
project(test_include_dirs)
include(CTest)
enable_testing()
add_executable(dummy dummy.cpp)
function(generate_tests NAME)
set(ctest_file "${CMAKE_CURRENT_BINARY_DIR}/${NAME}_tests.cmake")
add_custom_command(
OUTPUT "${ctest_file}"
COMMAND "${CMAKE_COMMAND}"
-D "TEST_EXECUTABLE=$<TARGET_FILE:dummy>"
-D "TEST_SUITE=${NAME}"
-D "TEST_NAMES=${ARGN}"
-D "CTEST_FILE=${ctest_file}"
-P "${CMAKE_CURRENT_SOURCE_DIR}/add-tests.cmake"
VERBATIM
)
add_custom_target(${NAME}_tests ALL DEPENDS "${ctest_file}")
endfunction()
generate_tests(house dog cat)
generate_tests(farm cow pig)
generate_tests(zoo fox emu)
set_property(DIRECTORY PROPERTY TEST_INCLUDE_FILE "house_tests.cmake")
set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES "farm_tests.cmake")
set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES "zoo_tests.cmake")
|