File tree 4 files changed +35
-0
lines changed 4 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -157,6 +157,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
157
157
add_dependencies (Foundation CoreFoundationResources)
158
158
target_link_options (Foundation PRIVATE
159
159
$<TARGET_OBJECTS:CoreFoundationResources>)
160
+ elseif (NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
161
+ target_link_options (Foundation PRIVATE "SHELL:-no-toolchain-stdlib-rpath" )
160
162
endif ()
161
163
162
164
Original file line number Diff line number Diff line change @@ -66,6 +66,10 @@ set_target_properties(FoundationNetworking PROPERTIES
66
66
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR} /swift
67
67
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR} /swift)
68
68
69
+ if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows" )
70
+ target_link_options (FoundationNetworking PRIVATE "SHELL:-no-toolchain-stdlib-rpath" )
71
+ endif ()
72
+
69
73
70
74
set_property (GLOBAL APPEND PROPERTY Foundation_EXPORTS FoundationNetworking)
71
75
install (TARGETS FoundationNetworking
Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ set_target_properties(FoundationXML PROPERTIES
20
20
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR} /swift
21
21
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR} /swift)
22
22
23
+ if (NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows" )
24
+ target_link_options (FoundationXML PRIVATE "SHELL:-no-toolchain-stdlib-rpath" )
25
+ endif ()
26
+
23
27
24
28
set_property (GLOBAL APPEND PROPERTY Foundation_EXPORTS FoundationXML)
25
29
install (TARGETS FoundationXML
Original file line number Diff line number Diff line change @@ -2,6 +2,31 @@ add_executable(plutil
2
2
main.swift)
3
3
target_link_libraries (plutil PRIVATE
4
4
Foundation)
5
+
6
+ # On ELF platforms, remove the absolute rpath to the host toolchain's stdlib, then add it
7
+ # back temporarily as a BUILD_RPATH just for the tests. Disabled for now, as BUILD_RPATH
8
+ # doesn't work for executables with CMake 3.16 on the CI.
9
+ if (FALSE ) #NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows")
10
+ target_link_options (plutil PRIVATE "SHELL:-no-toolchain-stdlib-rpath" )
11
+
12
+ # This assumes the host is the target, pass a target flag when cross-compiling.
13
+ execute_process (
14
+ COMMAND ${CMAKE_Swift_COMPILER} -print-target -info
15
+ OUTPUT_VARIABLE output
16
+ ERROR_VARIABLE error_output
17
+ RESULT_VARIABLE result
18
+ )
19
+ if (NOT ${result} EQUAL 0)
20
+ message (FATAL_ERROR "Error getting target info with\n "
21
+ " `${CMAKE_Swift_COMPILER} -print-target-info`\n "
22
+ "Error:\n "
23
+ " ${error_output} " )
24
+ endif ()
25
+
26
+ string (REGEX MATCH "\" runtimeLibraryPaths\" : \\ [\n\ +\" ([^\" ]+)\" " path ${output} )
27
+ set_target_properties (plutil PROPERTIES BUILD_RPATH ${CMAKE_MATCH_1} )
28
+ endif ()
29
+
5
30
set_target_properties (plutil PROPERTIES
6
31
INSTALL_RPATH "$ORIGIN/../lib/swift/$<LOWER_CASE:${CMAKE_SYSTEM_NAME} >" )
7
32
You can’t perform that action at this time.
0 commit comments