Skip to content

Commit 80e95bb

Browse files
committed
[Build] Add some libraries to the autolink list.
For static linking, we need to list all the dependencies of libcurl or libxml2 that we're using. This differs from dynamic linking, because in the latter case that information is in the shared objects, which is not true in the statically linked case. rdar://123381867
1 parent db0c7fc commit 80e95bb

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
4646
set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)
4747

4848
option(BUILD_SHARED_LIBS "build shared libraries" ON)
49+
option(BUILD_FULLY_STATIC "build fully static" NO)
4950
option(HAS_LIBDISPATCH_API "has libdispatch API" ON)
5051
option(BUILD_NETWORKING "build FoundationNetworking module" ON)
5152
option(BUILD_TOOLS "build tools" ON)

Sources/FoundationNetworking/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ if(NOT BUILD_SHARED_LIBS)
7272
PRIVATE
7373
"SHELL:-Xfrontend -public-autolink-library -Xfrontend curl")
7474

75+
if(BUILD_FULLY_STATIC)
76+
target_compile_options(FoundationNetworking
77+
PRIVATE
78+
"SHELL:-Xfrontend -public-autolink-library -Xfrontend crypto"
79+
"SHELL:-Xfrontend -public-autolink-library -Xfrontend ssl"
80+
"SHELL:-Xfrontend -public-autolink-library -Xfrontend z")
81+
endif()
82+
7583
# Merge private dependencies into single static objects archive
7684
set_property(TARGET FoundationNetworking PROPERTY STATIC_LIBRARY_OPTIONS
7785
$<TARGET_OBJECTS:CFURLSessionInterface>)

Sources/FoundationXML/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ if(NOT BUILD_SHARED_LIBS)
2323
PRIVATE
2424
"SHELL:-Xfrontend -public-autolink-library -Xfrontend xml2")
2525

26+
if(BUILD_FULLY_STATIC)
27+
target_compile_options(FoundationXML
28+
PRIVATE
29+
"SHELL:-Xfrontend -public-autolink-library -Xfrontend z")
30+
endif()
31+
2632
# Merge private dependencies into single static objects archive
2733
set_property(TARGET FoundationXML PROPERTY STATIC_LIBRARY_OPTIONS
2834
$<TARGET_OBJECTS:CFXMLInterface>)

0 commit comments

Comments
 (0)