diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c88b430de..adc989d42 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -155,6 +155,10 @@ if(CMAKE_SYSTEM_NAME STREQUAL Darwin) "-Xlinker -alias_list -Xlinker ${PROJECT_SOURCE_DIR}/xcodeconfig/libdispatch.aliases") endif() +if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows") + set_target_properties(dispatch PROPERTIES INSTALL_RPATH "$ORIGIN") +endif() + if(ENABLE_SWIFT) add_subdirectory(swift) endif() diff --git a/src/swift/CMakeLists.txt b/src/swift/CMakeLists.txt index ba987e747..53924723e 100644 --- a/src/swift/CMakeLists.txt +++ b/src/swift/CMakeLists.txt @@ -59,4 +59,7 @@ if(NOT BUILD_SHARED_LIBS) install(TARGETS DispatchStubs EXPORT dispatchExports DESTINATION ${INSTALL_TARGET_DIR}) +elseif(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows") + target_link_options(swiftDispatch PRIVATE "SHELL:-no-toolchain-stdlib-rpath") + set_target_properties(swiftDispatch PROPERTIES INSTALL_RPATH "$ORIGIN") endif()