Skip to content

Commit 6a1c981

Browse files
committed
[CMake] Allow *only* static stdlib to be built
Prior to these changes, it was only possible to build static libraries for the standard library and SDK overlays if *also* building dynamic libraries. This is problematic if, for example, you wanted to defer the linking of the standard library build products until later. These changes allow you to build *only* static libraries, using something like the following command: ``` $ utils/build-script -R --skip-build-benchmarks \ -- --build-swift-static-stdlib=1 --build-swift-dynamic-stdlib=0 ```
1 parent 1a0891c commit 6a1c981

File tree

4 files changed

+227
-175
lines changed

4 files changed

+227
-175
lines changed

CMakeLists.txt

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,34 @@ option(SWIFT_BUILD_TOOLS
4444
"Build the Swift compiler and other tools"
4545
TRUE)
4646

47-
option(SWIFT_BUILD_STDLIB
48-
"Build the Swift standard library (independent of the SDK headers)"
47+
option(SWIFT_BUILD_DYNAMIC_STDLIB
48+
"Build dynamic variants of the Swift standard library"
4949
TRUE)
5050

51-
option(SWIFT_BUILD_SDK_OVERLAY
52-
"Build Swift SDK overlay"
51+
option(SWIFT_BUILD_STATIC_STDLIB
52+
"Build static variants of the Swift standard library"
53+
FALSE)
54+
55+
if(SWIFT_BUILD_DYNAMIC_STDLIB OR SWIFT_BUILD_STATIC_STDLIB)
56+
set(SWIFT_BUILD_STDLIB TRUE)
57+
else()
58+
set(SWIFT_BUILD_STDLIB FALSE)
59+
endif()
60+
61+
option(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY
62+
"Build dynamic variants of the Swift SDK overlays"
5363
TRUE)
5464

55-
option(SWIFT_BUILD_STATIC_STDLIB
56-
"Build static variants of the Swift standard library and SDK overlay"
65+
option(SWIFT_BUILD_STATIC_SDK_OVERLAY
66+
"Build static variants of the Swift SDK overlays"
5767
FALSE)
5868

69+
if(SWIFT_BUILD_DYNAMIC_SDK_OVERLAY OR SWIFT_BUILD_STATIC_SDK_OVERLAY)
70+
set(SWIFT_BUILD_SDK_OVERLAY TRUE)
71+
else()
72+
set(SWIFT_BUILD_SDK_OVERLAY FALSE)
73+
endif()
74+
5975
option(SWIFT_BUILD_PERF_TESTSUITE
6076
"Create targets for swift performance benchmarks."
6177
FALSE)
@@ -795,14 +811,14 @@ if(SWIFT_BUILD_TOOLS)
795811
endif()
796812

797813
is_sdk_requested("${SWIFT_HOST_VARIANT_SDK}" SWIFT_HOST_SDK_REQUESTED)
798-
if(SWIFT_BUILD_TOOLS AND SWIFT_BUILD_STDLIB AND SWIFT_HOST_SDK_REQUESTED)
814+
if(SWIFT_BUILD_TOOLS AND SWIFT_BUILD_DYNAMIC_STDLIB AND SWIFT_HOST_SDK_REQUESTED)
799815
add_subdirectory(tools/swift-reflection-dump)
800816
endif()
801817

802818
add_subdirectory(utils)
803819
add_subdirectory(stdlib)
804820

805-
if(SWIFT_BUILD_STDLIB AND SWIFT_INCLUDE_TESTS)
821+
if(SWIFT_BUILD_DYNAMIC_STDLIB AND SWIFT_INCLUDE_TESTS)
806822
add_subdirectory(tools/swift-reflection-test)
807823
endif()
808824

0 commit comments

Comments
 (0)