Skip to content

Commit 36f3c78

Browse files
studootmurraycu
authored andcommitted
CMake Build: tests: Let MSVC find the library
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 3864871 commit 36f3c78

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tests/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +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})
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}>)
6567
endfunction (add_sigcpp_test)
6668

6769
foreach (test_file ${TEST_SOURCE_FILES})

0 commit comments

Comments
 (0)