-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GHI #13 Fix Windows PATH issues for tests
Signed-off-by: doodspav <[email protected]>
- Loading branch information
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# ---- Windows Tests Path ---- | ||
|
||
# By default we set PATH for tests run with CTest on Windows in order to prevent | ||
# linker errors. | ||
# Due to limitations in CMake, we can only completely override the PATH, rather | ||
# than prepend to it. | ||
# This gives users the option to disable this behaviour. | ||
option( | ||
patomic_test_SET_CTEST_PATH_ENV_WINDOWS | ||
"Set PATH environment variable for tests when run using CTest on Windows" | ||
ON | ||
) | ||
mark_as_advanced(patomic_test_SET_CTEST_PATH_ENV_WINDOWS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# ---- Windows Path Prefix ---- | ||
|
||
# Windows doesn't support rpath, so when linking dynamically the libraries need | ||
# to either be in the same directory or on PATH. | ||
# This function sets a variable to a GENERATOR string that may be prepended to | ||
# path in order to find linked dependencies | ||
# See: https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order | ||
# Usage: windows_deps_path(<variable> <link-target>...) | ||
function(windows_deps_path VAR) | ||
if(NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") | ||
set(${VAR} "" PARENT_SCOPE) | ||
return() | ||
endif() | ||
|
||
set(path "") | ||
set(glue "") | ||
foreach(target IN LISTS ARGN) | ||
get_target_property(type "${target}" TYPE) | ||
if(type STREQUAL "SHARED_LIBRARY") | ||
set(path "${path}${glue}$<TARGET_FILE_DIR:${target}>") | ||
set(glue "\;") # backslash is important | ||
endif() | ||
endforeach() | ||
|
||
if(NOT path STREQUAL "") | ||
set(${VAR} "${path}" PARENT_SCOPE) | ||
else() | ||
set(${VAR} "" PARENT_SCOPE) | ||
endif() | ||
endfunction() |