Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix autolink mechanism for static libraries on Linux #2996

Merged
merged 2 commits into from
Aug 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Sources/Foundation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,18 @@ set_target_properties(Foundation PROPERTIES
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/swift)

if(NOT BUILD_SHARED_LIBS)
target_compile_options(Foundation
PRIVATE
"SHELL:-Xfrontend -public-autolink-library -Xfrontend icui18n
-Xfrontend -public-autolink-library -Xfrontend BlocksRuntime")

# Merge private dependencies into single static objects archive
set_property(TARGET Foundation PROPERTY STATIC_LIBRARY_OPTIONS
$<TARGET_OBJECTS:CoreFoundation>
$<TARGET_OBJECTS:uuid>)
endif()

if(CMAKE_SYSTEM_NAME STREQUAL Windows)
# NOTE: workaround for CMake which doesn't link in OBJECT libraries properly
add_dependencies(Foundation CoreFoundationResources)
Expand Down
11 changes: 11 additions & 0 deletions Sources/FoundationNetworking/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ target_link_libraries(FoundationNetworking
CFURLSessionInterface
PUBLIC
Foundation)

if(NOT BUILD_SHARED_LIBS)
target_compile_options(FoundationNetworking
PRIVATE
"SHELL:-Xfrontend -public-autolink-library -Xfrontend curl")

# Merge private dependencies into single static objects archive
set_property(TARGET FoundationNetworking PROPERTY STATIC_LIBRARY_OPTIONS
$<TARGET_OBJECTS:CFURLSessionInterface>)
endif()

set_target_properties(FoundationNetworking PROPERTIES
INSTALL_RPATH "$ORIGIN"
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift
Expand Down
11 changes: 11 additions & 0 deletions Sources/FoundationXML/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ target_link_libraries(FoundationXML
CFXMLInterface
PUBLIC
Foundation)

if(NOT BUILD_SHARED_LIBS)
target_compile_options(FoundationXML
PRIVATE
"SHELL:-Xfrontend -public-autolink-library -Xfrontend xml2")

# Merge private dependencies into single static objects archive
set_property(TARGET FoundationXML PROPERTY STATIC_LIBRARY_OPTIONS
$<TARGET_OBJECTS:CFXMLInterface>)
endif()

set_target_properties(FoundationXML PROPERTIES
INSTALL_RPATH "$ORIGIN"
Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift
Expand Down