Skip to content

Commit 7412199

Browse files
committed
Allow making tests dependend on main target
E.g. tests of `syncthingctl` invoke `syncthingctl` and hence should depend on it so one can just invoke `check` after configuration.
1 parent 94ceaf8 commit 7412199

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

cmake/modules/TestTarget.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ set(RUN_TESTS_ARGS -p "${CMAKE_CURRENT_SOURCE_DIR}/testfiles" -w "${CMAKE_CURREN
162162
if (META_TEST_TARGET_IS_MANUAL)
163163
list(APPEND TEST_TARGET_OPTIONS MANUAL)
164164
endif ()
165+
if (META_TEST_REQUIRE_MAIN_TARGET)
166+
list(APPEND TEST_TARGET_OPTIONS REQUIRES_MAIN_TARGET)
167+
endif ()
165168
configure_test_target(
166169
TARGET_NAME
167170
"${META_TARGET_NAME}"

cmake/modules/TestUtilities.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ option(EXCLUDE_TESTS_FROM_ALL "specifies whether to exclude tests from the 'all'
1818

1919
function (configure_test_target)
2020
# parse arguments
21-
set(OPTIONAL_ARGS MANUAL)
21+
set(OPTIONAL_ARGS MANUAL REQUIRES_MAIN_TARGET)
2222
set(ONE_VALUE_ARGS TARGET_NAME TEST_NAME FULL_TEST_NAME_OUT_VAR)
2323
set(MULTI_VALUE_ARGS HEADER_FILES SRC_FILES LIBRARIES RUN_ARGS)
2424
cmake_parse_arguments(ARGS "${OPTIONAL_ARGS}" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN})
@@ -89,5 +89,8 @@ function (configure_test_target)
8989
# add the test executable to the dependencies of the check target
9090
if (NOT ARGS_MANUAL AND TARGET check)
9191
add_dependencies(check ${TEST_TARGET_NAME})
92+
if (ARGS_REQUIRES_MAIN_TARGET)
93+
add_dependencies(check "${META_TARGET_NAME}")
94+
endif ()
9295
endif ()
9396
endfunction ()

0 commit comments

Comments
 (0)