Skip to content

Commit 5124e7c

Browse files
committed
CMake: Add targets to export set
In order to install a static archive, all libraries that feed into it must be part of an export set, including object libraries. Installing an object library without providing a `DESTINATION` field only generates an interface library with the appropriate interface flags to ensure that flags are correctly propagated in the generated SwiftCoreTargets.cmake. This does not add any objects to the resulting installation.
1 parent 59b5391 commit 5124e7c

File tree

6 files changed

+32
-1
lines changed

6 files changed

+32
-1
lines changed

Runtimes/Core/CommandLineSupport/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ if(SwiftCore_ENABLE_COMMANDLINE_SUPPORT)
1010
swiftShims)
1111

1212
if(NOT BUILD_SHARED_LIBS)
13-
install(TARGETS swiftCommandLineSupport)
13+
install(TARGETS swiftCommandLineSupport
14+
EXPORT SwiftCoreTargets
15+
COMPONENT SwiftCore_runtime)
1416
endif()
1517
endif()

Runtimes/Core/Demangling/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,6 @@ endif()
4949

5050
if(NOT BUILD_SHARED_LIBS)
5151
install(TARGETS swiftDemangling
52+
EXPORT SwiftCoreTargets
5253
COMPONENT SwiftCore_runtime)
5354
endif()

Runtimes/Core/LLVMSupport/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@ add_library(swiftLLVMSupport OBJECT
88
target_compile_options(swiftLLVMSupport
99
PRIVATE
1010
$<$<BOOL:${SwiftCore_HAS_ASL}>:-DSWIFT_STDLIB_HAS_ASL>)
11+
12+
if(NOT BUILD_SHARED_LIBS)
13+
install(TARGETS swiftLLVMSupport
14+
EXPORT SwiftCoreTargets
15+
COMPONENT SwiftCore_runtime)
16+
endif()

Runtimes/Core/Threading/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ target_link_libraries(swiftThreading PRIVATE swiftShims)
1313
# to avoid pulling in headers from the compiler.
1414
target_include_directories(swiftThreading PRIVATE
1515
"${SwiftCore_SWIFTC_SOURCE_DIR}/include")
16+
17+
if(NOT BUILD_SHARED_LIBS)
18+
install(TARGETS swiftThreading
19+
EXPORT SwiftCoreTargets
20+
COMPONENT SwiftCore_runtime)
21+
endif()

Runtimes/Core/runtime/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ if(SwiftCore_ENABLE_OBJC_INTEROP)
143143
ObjCRuntimeGetImageNameFromClass.mm)
144144
endif()
145145

146+
if(NOT BUILD_SHARED_LIBS)
147+
install(TARGETS swiftRuntime
148+
EXPORT SwiftCoreTargets
149+
COMPONENT SwiftCore_runtime)
150+
endif()
151+
146152
string(TOLOWER "${SwiftCore_OBJECT_FORMAT}x" SwiftCore_OBJECT_FORMAT)
147153
if("${SwiftCore_OBJECT_FORMAT}" STREQUAL "elfx")
148154
add_library(swiftrt OBJECT SwiftRT-ELF-WASM.cpp)
@@ -155,6 +161,8 @@ if("${SwiftCore_OBJECT_FORMAT}" STREQUAL "elfx")
155161
# The driver requires that swifrt.o is under `usr/lib/swift/<platform>/<arch>`
156162
# Regardless of settings
157163
install(FILES $<TARGET_OBJECTS:swiftrt>
164+
EXPORT SwiftCoreTargets
165+
COMPONENT SwiftCore_runtime
158166
DESTINATION "${CMAKE_INSTALL_LIBDIR}/swift/${SwiftCore_PLATFORM_SUBDIR}/${SwiftCore_ARCH_SUBDIR}"
159167
RENAME swiftrt.o)
160168
elseif("${SwiftCore_OBJECT_FORMAT}" STREQUAL "coffx")
@@ -169,6 +177,8 @@ elseif("${SwiftCore_OBJECT_FORMAT}" STREQUAL "coffx")
169177
add_library(swiftrt OBJECT SwiftRT-COFF.cpp)
170178
target_link_libraries(swiftrt PRIVATE swiftShims)
171179
install(FILES $<TARGET_OBJECTS:swiftrt>
180+
EXPORT SwiftCoreTargets
181+
COMPONENT SwiftCore_runtime
172182
DESTINATION "${CMAKE_INSTALL_LIBDIR}/swift/${SwiftCore_PLATFORM_SUBDIR}/${SwiftCore_ARCH_SUBDIR}"
173183
RENAME swiftrt.obj)
174184
elseif(NOT "${SwiftCore_OBJECT_FORMAT}" STREQUAL "x")

Runtimes/Core/stubs/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,9 @@ if(APPLE)
5858
APPEND_STRING
5959
PROPERTY COMPILE_FLAGS "-fobjc-arc")
6060
endif()
61+
62+
if(NOT BUILD_SHARED_LIBS)
63+
install(TARGETS swiftStdlibStubs
64+
EXPORT SwiftCoreTargets
65+
COMPONENT SwiftCore_runtime)
66+
endif()

0 commit comments

Comments
 (0)