Skip to content

Commit 869a2eb

Browse files
committed
Add BUILD_RPATH for Foundation too
1 parent 6a7e27a commit 869a2eb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Sources/Foundation/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,22 @@ if(CMAKE_SYSTEM_NAME STREQUAL Windows)
159159
$<TARGET_OBJECTS:CoreFoundationResources>)
160160
elseif(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
161161
target_link_options(Foundation PRIVATE "SHELL:-no-toolchain-stdlib-rpath")
162+
163+
execute_process(
164+
COMMAND ${CMAKE_Swift_COMPILER} -print-target-info
165+
OUTPUT_VARIABLE output
166+
ERROR_VARIABLE error_output
167+
RESULT_VARIABLE result
168+
)
169+
if(NOT ${result} EQUAL 0)
170+
message(FATAL_ERROR "Error getting target info with\n"
171+
" `${CMAKE_Swift_COMPILER} -print-target-info`\n"
172+
"Error:\n"
173+
" ${error_output}")
174+
endif()
175+
176+
string(REGEX MATCH "\"runtimeLibraryPaths\": \\[\n\ +\"([^\"]+)\"" path ${output})
177+
set_target_properties(Foundation PROPERTIES BUILD_RPATH ${CMAKE_MATCH_1})
162178
endif()
163179

164180

0 commit comments

Comments
 (0)