Skip to content

Commit dfb10f7

Browse files
finagolfindrexin
authored andcommitted
[CMake] fix runpath for ELF platforms
Remove the absolute path to the host toolchain's stdlib from the three Foundation shared libraries.
1 parent c391da5 commit dfb10f7

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

Sources/Foundation/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
157157
add_dependencies(Foundation CoreFoundationResources)
158158
target_link_options(Foundation PRIVATE
159159
$<TARGET_OBJECTS:CoreFoundationResources>)
160+
elseif(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
161+
target_link_options(Foundation PRIVATE "SHELL:-no-toolchain-stdlib-rpath")
160162
endif()
161163

162164

Sources/FoundationNetworking/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ set_target_properties(FoundationNetworking PROPERTIES
6666
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift
6767
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/swift)
6868

69+
if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows")
70+
target_link_options(FoundationNetworking PRIVATE "SHELL:-no-toolchain-stdlib-rpath")
71+
endif()
72+
6973

7074
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS FoundationNetworking)
7175
install(TARGETS FoundationNetworking

Sources/FoundationXML/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ set_target_properties(FoundationXML PROPERTIES
2020
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift
2121
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/swift)
2222

23+
if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows")
24+
target_link_options(FoundationXML PRIVATE "SHELL:-no-toolchain-stdlib-rpath")
25+
endif()
26+
2327

2428
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS FoundationXML)
2529
install(TARGETS FoundationXML

0 commit comments

Comments
 (0)