Skip to content

Commit d033990

Browse files
committed
Move SWIFT_CONCURRENCY_USES_DISPATCH to StdlibOptions.cmake
It is only used in the stdlib build, so really has no business being set in the root `CMakeLists.txt`.
1 parent 8d3a769 commit d033990

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

CMakeLists.txt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -623,13 +623,6 @@ if(NOT EXISTS "${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}")
623623
message(SEND_ERROR "swift-syntax is required to build the Swift compiler. Please run update-checkout or specify SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE")
624624
endif()
625625

626-
# Use dispatch as the system scheduler by default.
627-
# For convenience, we set this to false when concurrency is disabled.
628-
set(SWIFT_CONCURRENCY_USES_DISPATCH FALSE)
629-
if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY AND "${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "dispatch")
630-
set(SWIFT_CONCURRENCY_USES_DISPATCH TRUE)
631-
endif()
632-
633626
set(SWIFT_BUILD_HOST_DISPATCH FALSE)
634627
if(SWIFT_ENABLE_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
635628
# Only build libdispatch for the host if the host tools are being built and
@@ -638,9 +631,9 @@ if(SWIFT_ENABLE_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
638631
set(SWIFT_BUILD_HOST_DISPATCH TRUE)
639632
endif()
640633

641-
if(SWIFT_BUILD_HOST_DISPATCH OR SWIFT_CONCURRENCY_USES_DISPATCH)
634+
if(SWIFT_BUILD_HOST_DISPATCH)
642635
if(NOT EXISTS "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}")
643-
message(SEND_ERROR "SourceKit and concurrency require libdispatch on non-Darwin hosts. Please specify SWIFT_PATH_TO_LIBDISPATCH_SOURCE")
636+
message(SEND_ERROR "SourceKit requires libdispatch on non-Darwin hosts. Please specify SWIFT_PATH_TO_LIBDISPATCH_SOURCE")
644637
endif()
645638
endif()
646639
endif()

stdlib/cmake/modules/StdlibOptions.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,16 @@ option(SWIFT_STDLIB_CONCURRENCY_TRACING
228228
"Enable concurrency tracing in the runtime; assumes the presence of os_log(3)
229229
and the os_signpost(3) API."
230230
"${SWIFT_STDLIB_CONCURRENCY_TRACING_default}")
231+
232+
# Use dispatch as the system scheduler by default.
233+
# For convenience, we set this to false when concurrency is disabled.
234+
set(SWIFT_CONCURRENCY_USES_DISPATCH FALSE)
235+
if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY AND "${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "dispatch")
236+
set(SWIFT_CONCURRENCY_USES_DISPATCH TRUE)
237+
endif()
238+
239+
if(SWIFT_CONCURRENCY_USES_DISPATCH)
240+
if(NOT EXISTS "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}")
241+
message(SEND_ERROR "Concurrency requires libdispatch on non-Darwin hosts. Please specify SWIFT_PATH_TO_LIBDISPATCH_SOURCE")
242+
endif()
243+
endif()

0 commit comments

Comments
 (0)