Meta: Set LD_LIBRARY_PATH to Build/lagom for Lagom test targets

Some tests, such as those under LibGL, try to load shared libraries at
runtime which are stored in Build/lagom. Because all tests' working
directory is that of their CMakeLists.txt file, they fail to find those
shared libraries at runtime.

Set LD_LIBRARY_PATH to Build/lagom so the tests may find the shared
libraries. This fixes, for example, both of these commands:

    ./Meta/serenity.sh test lagom TestAPI
    ./Meta/serenity.sh run lagom TestAPI
This commit is contained in:
Timothy Flynn 2023-02-01 08:42:31 -05:00 committed by Tim Flynn
parent 1bbd889f67
commit 38b0b32bb4
Notes: sideshowbarker 2024-07-17 18:23:22 +09:00

View file

@ -258,6 +258,7 @@ function(lagom_test source)
WORKING_DIRECTORY ${LAGOM_TEST_WORKING_DIRECTORY}
)
set_target_properties(${name} PROPERTIES LAGOM_WORKING_DIRECTORY "${LAGOM_TEST_WORKING_DIRECTORY}")
set_tests_properties(${name} PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}")
endfunction()
function(serenity_test test_src sub_dir)
@ -693,7 +694,10 @@ 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}
COMMAND "${CMAKE_COMMAND}"
-E env "SERENITY_SOURCE_DIR=${SERENITY_PROJECT_ROOT}" "LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}"
"$<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