Meta: Set the Lagom test working directory for run-lagom-target

When we call add_test() from each test's CMakeLists.txt, we specify the
working directory to be that of the CMakeList.txt file itself. Create a
property to store that directory and reference it when run-lagom-target
is invoked by serenity.sh.

Note that for non-test Lagom targets which do not set this property, the
working directory will be Build/lagom (because the property will be the
empty string, which CMake resolves relative to the current build path).
This commit is contained in:
Timothy Flynn 2023-02-01 08:36:15 -05:00 committed by Tim Flynn
parent 0a97206a25
commit 1bbd889f67

View file

@ -253,10 +253,11 @@ function(lagom_test source)
add_executable(${name} ${source})
target_link_libraries(${name} PRIVATE LibCore LibTest LibTestMain ${LAGOM_TEST_LIBS})
add_test(
NAME ${name}
COMMAND ${name}
WORKING_DIRECTORY ${LAGOM_TEST_WORKING_DIRECTORY}
NAME ${name}
COMMAND ${name}
WORKING_DIRECTORY ${LAGOM_TEST_WORKING_DIRECTORY}
)
set_target_properties(${name} PROPERTIES LAGOM_WORKING_DIRECTORY "${LAGOM_TEST_WORKING_DIRECTORY}")
endfunction()
function(serenity_test test_src sub_dir)
@ -693,6 +694,7 @@ endif()
if (NOT "$ENV{LAGOM_TARGET}" STREQUAL "")
add_custom_target(run-lagom-target
COMMAND "${CMAKE_COMMAND}" -E env "SERENITY_SOURCE_DIR=${SERENITY_PROJECT_ROOT}" "$<TARGET_FILE:$ENV{LAGOM_TARGET}>" $ENV{LAGOM_ARGS}
WORKING_DIRECTORY "$<TARGET_PROPERTY:$ENV{LAGOM_TARGET},LAGOM_WORKING_DIRECTORY>"
DEPENDS "$<TARGET_FILE:$ENV{LAGOM_TARGET}>"
USES_TERMINAL
VERBATIM