Skip to content

Commit 715cda8

Browse files
authored
Merge pull request #2996 from kateinoigakukun/katei/merge-private-libs
Fix autolink mechanism for static libraries on Linux
2 parents 05e3c24 + 718159e commit 715cda8

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

Sources/Foundation/CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,18 @@ set_target_properties(Foundation PROPERTIES
160160
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift
161161
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/swift)
162162

163+
if(NOT BUILD_SHARED_LIBS)
164+
target_compile_options(Foundation
165+
PRIVATE
166+
"SHELL:-Xfrontend -public-autolink-library -Xfrontend icui18n
167+
-Xfrontend -public-autolink-library -Xfrontend BlocksRuntime")
168+
169+
# Merge private dependencies into single static objects archive
170+
set_property(TARGET Foundation PROPERTY STATIC_LIBRARY_OPTIONS
171+
$<TARGET_OBJECTS:CoreFoundation>
172+
$<TARGET_OBJECTS:uuid>)
173+
endif()
174+
163175
if(CMAKE_SYSTEM_NAME STREQUAL Windows)
164176
# NOTE: workaround for CMake which doesn't link in OBJECT libraries properly
165177
add_dependencies(Foundation CoreFoundationResources)

Sources/FoundationNetworking/CMakeLists.txt

+11
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ target_link_libraries(FoundationNetworking
6464
CFURLSessionInterface
6565
PUBLIC
6666
Foundation)
67+
68+
if(NOT BUILD_SHARED_LIBS)
69+
target_compile_options(FoundationNetworking
70+
PRIVATE
71+
"SHELL:-Xfrontend -public-autolink-library -Xfrontend curl")
72+
73+
# Merge private dependencies into single static objects archive
74+
set_property(TARGET FoundationNetworking PROPERTY STATIC_LIBRARY_OPTIONS
75+
$<TARGET_OBJECTS:CFURLSessionInterface>)
76+
endif()
77+
6778
set_target_properties(FoundationNetworking PROPERTIES
6879
INSTALL_RPATH "$ORIGIN"
6980
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift

Sources/FoundationXML/CMakeLists.txt

+11
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,17 @@ target_link_libraries(FoundationXML
1616
CFXMLInterface
1717
PUBLIC
1818
Foundation)
19+
20+
if(NOT BUILD_SHARED_LIBS)
21+
target_compile_options(FoundationXML
22+
PRIVATE
23+
"SHELL:-Xfrontend -public-autolink-library -Xfrontend xml2")
24+
25+
# Merge private dependencies into single static objects archive
26+
set_property(TARGET FoundationXML PROPERTY STATIC_LIBRARY_OPTIONS
27+
$<TARGET_OBJECTS:CFXMLInterface>)
28+
endif()
29+
1930
set_target_properties(FoundationXML PROPERTIES
2031
INSTALL_RPATH "$ORIGIN"
2132
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift

0 commit comments

Comments
 (0)