Skip to content

Commit a4a69d9

Browse files
CMake: Merge private dependencies into single static objects archive
When building the Testing library as a static library (BUILD_SHARED_LIBS=FALSE), `_TestingInternals` is not included in the `libTesting.a` archive by default. (when building as a shared library, `libTesting.so` includes `_TestingInternals`). This causes the linker to complain about missing symbols, so we need to manually merge the objects from `_TestingInternals` into `libTesting.a`.
1 parent d00d469 commit a4a69d9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Sources/Testing/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ add_library(Testing
9494
Traits/Trait.swift)
9595
target_link_libraries(Testing PRIVATE
9696
_TestingInternals)
97+
if(NOT BUILD_SHARED_LIBS)
98+
# Merge private dependencies into single static objects archive
99+
set_property(TARGET Testing PROPERTY STATIC_LIBRARY_OPTIONS
100+
$<TARGET_OBJECTS:_TestingInternals>)
101+
endif()
97102
add_dependencies(Testing
98103
TestingMacros)
99104
target_compile_options(Testing PRIVATE

0 commit comments

Comments
 (0)