From 22289cd004bdcbaa81e51bfd2619043595342c14 Mon Sep 17 00:00:00 2001 From: Butta Date: Wed, 6 May 2020 11:32:07 +0530 Subject: [PATCH] [CMake] fix runpath for ELF platforms Remove the absolute path to the host stdlib for libswiftDispatch.so and add $ORIGIN to it and libdispatch.so. --- src/CMakeLists.txt | 4 ++++ src/swift/CMakeLists.txt | 3 +++ 2 files changed, 7 insertions(+) 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()