@@ -13,6 +13,14 @@ project(Foundation
13
13
LANGUAGES C Swift)
14
14
enable_testing ()
15
15
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
+
16
24
# NOTE(compnerd) default to /MD or /MDd by default based on the configuration.
17
25
# Cache the variable to allow the user to alter the configuration.
18
26
set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL" CACHE
@@ -38,6 +46,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
38
46
set (CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR} /swift)
39
47
40
48
option (BUILD_SHARED_LIBS "build shared libraries" ON )
49
+ option (BUILD_FULLY_STATIC "build fully static" NO )
41
50
option (HAS_LIBDISPATCH_API "has libdispatch API" ON )
42
51
option (FOUNDATION_ENABLE_FOUNDATION_NETWORKING "build FoundationNetworking module" ON )
43
52
option (FOUNDATION_BUILD_TOOLS "build tools" ON )
@@ -49,6 +58,12 @@ endif()
49
58
50
59
find_package (ICU COMPONENTS uc i18n REQUIRED OPTIONAL_COMPONENTS data)
51
60
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
+
52
67
include (SwiftSupport)
53
68
include (GNUInstallDirs)
54
69
include (XCTest)
@@ -101,13 +116,13 @@ if(NOT BUILD_SHARED_LIBS)
101
116
endif ()
102
117
103
118
install (TARGETS CoreFoundation CFXMLInterface
104
- DESTINATION lib/swift_static/$<LOWER_CASE: ${CMAKE_SYSTEM_NAME} > )
119
+ DESTINATION lib/swift_static/${SWIFT_SYSTEM_NAME} )
105
120
106
121
if (FOUNDATION_ENABLE_FOUNDATION_NETWORKING)
107
122
set_property (GLOBAL APPEND PROPERTY Foundation_EXPORTS
108
123
CFURLSessionInterface)
109
124
install (TARGETS CFURLSessionInterface
110
- DESTINATION lib/swift_static/$<LOWER_CASE: ${CMAKE_SYSTEM_NAME} > )
125
+ DESTINATION lib/swift_static/${SWIFT_SYSTEM_NAME} )
111
126
endif ()
112
127
endif ()
113
128
0 commit comments