Skip to content

Commit 1f4b014

Browse files
committed
build: make the static build work
Correct the library name specification for the ICU components. We would get away with this as there can be unresolved symbols in a shared link. Link in the implicit dependencies pulled in through Foundation via CoreFoundation. When statically linking, we would no longer link against CoreFoundation.
1 parent 5b5a744 commit 1f4b014

File tree

1 file changed

+26
-7
lines changed

1 file changed

+26
-7
lines changed

CMakeLists.txt

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ add_swift_library(Foundation
8383
Foundation
8484
MODULE_PATH
8585
${CMAKE_CURRENT_BINARY_DIR}/swift/Foundation.swiftmodule
86-
OUTPUT
87-
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}Foundation${CMAKE_SHARED_LIBRARY_SUFFIX}
8886
SOURCES
8987
Foundation/AffineTransform.swift
9088
Foundation/Array.swift
@@ -250,7 +248,7 @@ add_swift_library(Foundation
250248
-L${install_dir}/usr/lib
251249
-lCoreFoundation
252250
${CURL_LIBRARIES}
253-
${ICU_UC_LIBRARIES} ${ICU_I18N_LIBRARIES}
251+
${ICU_UC_LIBRARY} ${ICU_I18N_LIBRARY}
254252
${LIBXML2_LIBRARIES}
255253
${libdispatch_ldflags}
256254
${uuid_LIBRARIES}
@@ -265,6 +263,17 @@ add_swift_library(Foundation
265263
DEPENDS
266264
CoreFoundation)
267265

266+
if(NOT BUILD_SHARED_LIBS)
267+
set(Foundation_INTERFACE_LIBRARIES
268+
-L${install_dir}/usr/lib
269+
-lCoreFoundation
270+
${CURL_LIBRARIES}
271+
${ICU_UC_LIBRARY}
272+
${ICU_I18N_LIBRARY}
273+
${LIBXML2_LIBRARIES}
274+
${uuid_LIBRARIES})
275+
endif()
276+
268277
add_swift_executable(plutil
269278
SOURCES
270279
Tools/plutil/main.swift
@@ -276,6 +285,7 @@ add_swift_executable(plutil
276285
-L${CMAKE_CURRENT_BINARY_DIR}
277286
${libdispatch_ldflags}
278287
-lFoundation
288+
${Foundation_INTERFACE_LIBRARIES}
279289
SWIFT_FLAGS
280290
-DDEPLOYMENT_RUNTIME_SWIFT
281291
${deployment_enable_libdispatch}
@@ -298,6 +308,7 @@ if(ENABLE_TESTING)
298308
${libdispatch_ldflags}
299309
-L${CMAKE_CURRENT_BINARY_DIR}
300310
-lFoundation
311+
${Foundation_INTERFACE_LIBRARIES}
301312
SOURCES
302313
TestFoundation/xdgTestHelper/main.swift
303314
SWIFT_FLAGS
@@ -404,6 +415,7 @@ if(ENABLE_TESTING)
404415
${libdispatch_ldflags}
405416
-L${CMAKE_CURRENT_BINARY_DIR}
406417
-lFoundation
418+
${Foundation_INTERFACE_LIBRARIES}
407419
-L${FOUNDATION_PATH_TO_XCTEST_BUILD}
408420
-lXCTest
409421
RESOURCES
@@ -474,10 +486,17 @@ install(FILES
474486
${CMAKE_CURRENT_BINARY_DIR}/swift/Foundation.swiftmodule
475487
DESTINATION
476488
lib/swift/${swift_os}/${swift_arch})
477-
install(FILES
478-
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}Foundation${CMAKE_SHARED_LIBRARY_SUFFIX}
479-
DESTINATION
480-
lib/swift/${swift_os})
489+
if(BUILD_SHARED_LIBS)
490+
install(FILES
491+
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}Foundation${CMAKE_SHARED_LIBRARY_SUFFIX}
492+
DESTINATION
493+
lib/swift/${swift_os})
494+
else()
495+
install(FILES
496+
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}Foundation${CMAKE_STATIC_LIBRARY_SUFFIX}
497+
DESTINATION
498+
lib/swift/${swift_os})
499+
endif()
481500
# TODO(compnerd) install as a Framework as that is how swift actually is built
482501
install(DIRECTORY
483502
${install_dir}/System/Library/Frameworks/CoreFoundation.framework/Headers/

0 commit comments

Comments
 (0)