Skip to content

Commit 78e4752

Browse files
authored
Merge pull request #1787 from compnerd/static
repair static builds of Foundation
2 parents 16b6831 + 1f4b014 commit 78e4752

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-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/

cmake/modules/FindICU.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ function(_icu_find)
7676
set(component_cache_debug "${component_cache}_DEBUG")
7777
set(component_found "${component_cache}_FOUND")
7878

79+
unset(component_libnames)
80+
unset(component_debug_libnames)
7981
list(APPEND component_libnames "icu${component}")
8082
list(APPEND component_debug_libnames "icu${component}d")
8183
if(component STREQUAL data)

0 commit comments

Comments
 (0)