@@ -13,6 +13,14 @@ project(Foundation
1313 LANGUAGES C Swift)
1414enable_testing ()
1515
16+ if (NOT SWIFT_SYSTEM_NAME)
17+ if (CMAKE_SYSTEM_NAME STREQUAL Darwin)
18+ set (SWIFT_SYSTEM_NAME macosx)
19+ else ()
20+ set (SWIFT_SYSTEM_NAME "$<LOWER_CASE:${CMAKE_SYSTEM_NAME} >" )
21+ endif ()
22+ endif ()
23+
1624# NOTE(compnerd) default to /MD or /MDd by default based on the configuration.
1725# Cache the variable to allow the user to alter the configuration.
1826set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL" CACHE
@@ -38,6 +46,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
3846set (CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR} /swift)
3947
4048option (BUILD_SHARED_LIBS "build shared libraries" ON )
49+ option (BUILD_FULLY_STATIC "build fully static" NO )
4150option (HAS_LIBDISPATCH_API "has libdispatch API" ON )
4251option (FOUNDATION_ENABLE_FOUNDATION_NETWORKING "build FoundationNetworking module" ON )
4352option (FOUNDATION_BUILD_TOOLS "build tools" ON )
@@ -49,6 +58,12 @@ endif()
4958
5059find_package (ICU COMPONENTS uc i18n REQUIRED OPTIONAL_COMPONENTS data)
5160
61+ # This is needed if we're statically linking, otherwise we can't pull in Dispatch
62+ # because we won't have RT::rt as a CMake target.
63+ if (NOT CMAKE_SYSTEM_NAME STREQUAL Android)
64+ find_package (LibRT)
65+ endif ()
66+
5267include (SwiftSupport)
5368include (GNUInstallDirs)
5469include (XCTest)
@@ -101,13 +116,13 @@ if(NOT BUILD_SHARED_LIBS)
101116 endif ()
102117
103118 install (TARGETS CoreFoundation CFXMLInterface
104- DESTINATION lib/swift_static/$<LOWER_CASE: ${CMAKE_SYSTEM_NAME} > )
119+ DESTINATION lib/swift_static/${SWIFT_SYSTEM_NAME} )
105120
106121 if (FOUNDATION_ENABLE_FOUNDATION_NETWORKING)
107122 set_property (GLOBAL APPEND PROPERTY Foundation_EXPORTS
108123 CFURLSessionInterface)
109124 install (TARGETS CFURLSessionInterface
110- DESTINATION lib/swift_static/$<LOWER_CASE: ${CMAKE_SYSTEM_NAME} > )
125+ DESTINATION lib/swift_static/${SWIFT_SYSTEM_NAME} )
111126 endif ()
112127endif ()
113128
0 commit comments