From 0a3b83776f417a3daf99c02aeecfb954e4632a50 Mon Sep 17 00:00:00 2001 From: Butta Date: Thu, 7 May 2020 15:29:46 +0530 Subject: [PATCH] [CMake] fix runpath for ELF platforms Remove the absolute path to the host toolchain's stdlib from the three Foundation shared libraries. --- Sources/Foundation/CMakeLists.txt | 2 ++ Sources/FoundationNetworking/CMakeLists.txt | 4 ++++ Sources/FoundationXML/CMakeLists.txt | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/Sources/Foundation/CMakeLists.txt b/Sources/Foundation/CMakeLists.txt index f138c8f2ba..dda85d6759 100644 --- a/Sources/Foundation/CMakeLists.txt +++ b/Sources/Foundation/CMakeLists.txt @@ -157,6 +157,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows) add_dependencies(Foundation CoreFoundationResources) target_link_options(Foundation PRIVATE $) +elseif(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) + target_link_options(Foundation PRIVATE "SHELL:-no-toolchain-stdlib-rpath") endif() diff --git a/Sources/FoundationNetworking/CMakeLists.txt b/Sources/FoundationNetworking/CMakeLists.txt index b6475b5442..2a571f4a24 100644 --- a/Sources/FoundationNetworking/CMakeLists.txt +++ b/Sources/FoundationNetworking/CMakeLists.txt @@ -68,6 +68,10 @@ set_target_properties(FoundationNetworking PROPERTIES Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/swift) +if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows") + target_link_options(FoundationNetworking PRIVATE "SHELL:-no-toolchain-stdlib-rpath") +endif() + set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS FoundationNetworking) _install_target(FoundationNetworking) diff --git a/Sources/FoundationXML/CMakeLists.txt b/Sources/FoundationXML/CMakeLists.txt index a3200322a9..4ca963a3dd 100644 --- a/Sources/FoundationXML/CMakeLists.txt +++ b/Sources/FoundationXML/CMakeLists.txt @@ -20,6 +20,10 @@ set_target_properties(FoundationXML PROPERTIES Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/swift) +if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows") + target_link_options(FoundationXML PRIVATE "SHELL:-no-toolchain-stdlib-rpath") +endif() + set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS FoundationXML) _install_target(FoundationXML)