Skip to content

Commit c5f47e7

Browse files
[CMake] Build BlocksRuntime as object library
To avoid shippig BlocksRuntime as a separate library, build it as an object library and include it in CoreFoundation static archive.
1 parent a9dbce0 commit c5f47e7

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

Sources/CoreFoundation/BlockRuntime/CMakeLists.txt

+4-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
# Build the vendored version of the BlocksRuntime library, which is used by
1616
# platforms that don't support libdispatch.
1717

18-
add_library(BlocksRuntime
18+
# Build the BlocksRuntime as an object library, shipped as a part
19+
# of libCoreFoundation.
20+
add_library(BlocksRuntime OBJECT
1921
data.c
2022
runtime.c)
2123

@@ -27,11 +29,4 @@ target_include_directories(BlocksRuntime PUBLIC
2729
set_target_properties(BlocksRuntime PROPERTIES
2830
POSITION_INDEPENDENT_CODE FALSE)
2931

30-
add_library(BlocksRuntime::BlocksRuntime ALIAS BlocksRuntime)
31-
32-
if(NOT BUILD_SHARED_LIBS)
33-
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS BlocksRuntime)
34-
install(TARGETS BlocksRuntime
35-
ARCHIVE DESTINATION lib/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/${SWIFT_SYSTEM_NAME}
36-
LIBRARY DESTINATION lib/swift$<$<NOT:$<BOOL:${BUILD_SHARED_LIBS}>>:_static>/${SWIFT_SYSTEM_NAME})
37-
endif()
32+
set_property(GLOBAL APPEND PROPERTY Foundation_EXPORTS BlocksRuntime)

Sources/CoreFoundation/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ target_link_libraries(CoreFoundation
121121
if(CMAKE_SYSTEM_NAME STREQUAL WASI)
122122
# On WASI, we use vendored BlocksRuntime instead of the one from libdispatch
123123
add_subdirectory(BlockRuntime)
124+
# Add BlocksRuntime object library to CoreFoundation static archive
124125
target_link_libraries(CoreFoundation PRIVATE BlocksRuntime)
125126
endif()
126127

0 commit comments

Comments
 (0)