forked from VowpalWabbit/vowpal_wabbit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWindowsSetPath.cmake
25 lines (23 loc) · 893 Bytes
/
WindowsSetPath.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# This function will add shared libraries to the PATH when running the test, so
# they can be found. Windows does not support RPATH or similar. See:
# https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order
# Usage: windows_set_path(<test> <target>...)
function(windows_set_path TEST)
if(NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
return()
endif()
set(targets_path "")
set(glue "")
foreach(target IN LISTS ARGN)
if(TARGET "${target}")
get_target_property(type "${target}" TYPE)
if(type STREQUAL "SHARED_LIBRARY")
set(targets_path "${targets_path}${glue}$<TARGET_FILE_DIR:${target}>")
set(glue "\;") # backslash is important
endif()
endif()
endforeach()
if(NOT targets_path STREQUAL "")
set_property(TEST "${TEST}" PROPERTY ENVIRONMENT "PATH=$ENV{PATH};${targets_path}")
endif()
endfunction()