Skip to content

Commit 2a33288

Browse files
committed
Correctly set PATH for test executables
Use 'cmake -E env ... <test-executable>' to execute the test executable. The '-E env' option allows the environment to be altered for the executed test. Use generator expressions to retrieve the build directory/file for the sigc++ & test targets
1 parent 64e391f commit 2a33288

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

tests/CMakeLists.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ function (add_sigcpp_test TEST_SOURCE_FILE)
6161
get_filename_component (test_name ${TEST_SOURCE_FILE} NAME_WE)
6262
add_executable (${test_name} ${TEST_SOURCE_FILE} testutilities.cc)
6363
target_link_libraries (${test_name} sigc-${SIGCXX_API_VERSION})
64-
add_test (${test_name} ${CMAKE_CURRENT_BINARY_DIR}/${test_name})
65-
66-
# Help MSVC to find the library that the tests should link against.
67-
set_tests_properties( ${test_name} PROPERTIES ENVIRONMENT "PATH=${sigc++_BINARY_DIR};$ENV{PATH}" )
64+
add_test (NAME ${test_name}
65+
# Help MSVC to find the library that the tests should link against.
66+
COMMAND ${CMAKE_COMMAND} -E env "PATH=$<TARGET_FILE_DIR:sigc-${SIGCXX_API_VERSION}>;$ENV{PATH}" $<TARGET_FILE:${test_name}>)
6867
endfunction (add_sigcpp_test)
6968

7069
foreach (test_file ${TEST_SOURCE_FILES})

0 commit comments

Comments
 (0)