Expose test name (created via `TestTarget.cmake`) for fixing downstream bug

This allows to set test properties in other projects as needed to fix
https://github.com/Martchus/syncthingtray/issues/116.
This commit is contained in:
Martchus 2021-10-12 23:38:54 +02:00
parent 5509caff89
commit 5563776061
3 changed files with 9 additions and 3 deletions

View File

@ -115,7 +115,7 @@ set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
set(META_APP_DESCRIPTION "Useful C++ classes and routines such as argument parser, IO and conversion utilities") set(META_APP_DESCRIPTION "Useful C++ classes and routines such as argument parser, IO and conversion utilities")
set(META_VERSION_MAJOR 5) set(META_VERSION_MAJOR 5)
set(META_VERSION_MINOR 11) set(META_VERSION_MINOR 11)
set(META_VERSION_PATCH 2) set(META_VERSION_PATCH 3)
# find required 3rd party libraries # find required 3rd party libraries
include(3rdParty) include(3rdParty)

View File

@ -154,6 +154,8 @@ configure_test_target(
"${TEST_SRC_FILES}" "${TEST_SRC_FILES}"
LIBRARIES LIBRARIES
"${TEST_LIBRARIES}" "${TEST_LIBRARIES}"
FULL_TEST_NAME_OUT_VAR
META_MAIN_TEST_NAME
RUN_ARGS RUN_ARGS
"${RUN_TESTS_ARGS}" "${RUN_TESTS_ARGS}"
${TEST_TARGET_OPTIONS}) ${TEST_TARGET_OPTIONS})

View File

@ -16,7 +16,7 @@ option(EXCLUDE_TESTS_FROM_ALL "specifies whether to exclude tests from the 'all'
function (configure_test_target) function (configure_test_target)
# parse arguments # parse arguments
set(OPTIONAL_ARGS MANUAL) set(OPTIONAL_ARGS MANUAL)
set(ONE_VALUE_ARGS TARGET_NAME TEST_NAME) set(ONE_VALUE_ARGS TARGET_NAME TEST_NAME FULL_TEST_NAME_OUT_VAR)
set(MULTI_VALUE_ARGS HEADER_FILES SRC_FILES LIBRARIES RUN_ARGS) set(MULTI_VALUE_ARGS HEADER_FILES SRC_FILES LIBRARIES RUN_ARGS)
cmake_parse_arguments(ARGS "${OPTIONAL_ARGS}" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN}) cmake_parse_arguments(ARGS "${OPTIONAL_ARGS}" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN})
if (NOT ARGS_TARGET_NAME) if (NOT ARGS_TARGET_NAME)
@ -70,7 +70,11 @@ function (configure_test_target)
# make the test recognized by ctest # make the test recognized by ctest
if (NOT ARGS_MANUAL) if (NOT ARGS_MANUAL)
add_test(NAME "${ARGS_TARGET_NAME}_run_${ARGS_TEST_NAME}" COMMAND "${TEST_TARGET_NAME}" ${RUN_ARGS}) set(FULL_TEST_NAME "${ARGS_TARGET_NAME}_run_${ARGS_TEST_NAME}")
set("${FULL_TEST_NAME_OUT_VAR}"
"${FULL_TEST_NAME}"
PARENT_SCOPE)
add_test(NAME "${FULL_TEST_NAME}" COMMAND "${TEST_TARGET_NAME}" ${RUN_ARGS})
endif () endif ()
# add the test executable to the dependencies of the check target # add the test executable to the dependencies of the check target