Skip to content

Commit 5275255

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 2db62ca commit 5275255

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
@@ -691,13 +691,6 @@ if(NOT EXISTS "${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}")
691691
message(SEND_ERROR "swift-syntax is required to build the Swift compiler. Please run update-checkout or specify SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE")
692692
endif()
693693

694-
# Use dispatch as the system scheduler by default.
695-
# For convenience, we set this to false when concurrency is disabled.
696-
set(SWIFT_CONCURRENCY_USES_DISPATCH FALSE)
697-
if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY AND "${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "dispatch")
698-
set(SWIFT_CONCURRENCY_USES_DISPATCH TRUE)
699-
endif()
700-
701694
set(SWIFT_BUILD_HOST_DISPATCH FALSE)
702695
if(SWIFT_ENABLE_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
703696
# Only build libdispatch for the host if the host tools are being built and
@@ -706,9 +699,9 @@ if(SWIFT_ENABLE_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
706699
set(SWIFT_BUILD_HOST_DISPATCH TRUE)
707700
endif()
708701

709-
if(SWIFT_BUILD_HOST_DISPATCH OR SWIFT_CONCURRENCY_USES_DISPATCH)
702+
if(SWIFT_BUILD_HOST_DISPATCH)
710703
if(NOT EXISTS "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}")
711-
message(SEND_ERROR "SourceKit and concurrency require libdispatch on non-Darwin hosts. Please specify SWIFT_PATH_TO_LIBDISPATCH_SOURCE")
704+
message(SEND_ERROR "SourceKit requires libdispatch on non-Darwin hosts. Please specify SWIFT_PATH_TO_LIBDISPATCH_SOURCE")
712705
endif()
713706
endif()
714707
endif()

stdlib/cmake/modules/StdlibOptions.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,16 @@ set(SWIFT_RUNTIME_FIXED_BACKTRACER_PATH "" CACHE STRING
239239
"If set, provides a fixed path to the swift-backtrace binary. This
240240
will disable dynamic determination of the path and will also disable
241241
the setting in SWIFT_BACKTRACE.")
242+
243+
# Use dispatch as the system scheduler by default.
244+
# For convenience, we set this to false when concurrency is disabled.
245+
set(SWIFT_CONCURRENCY_USES_DISPATCH FALSE)
246+
if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY AND "${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "dispatch")
247+
set(SWIFT_CONCURRENCY_USES_DISPATCH TRUE)
248+
endif()
249+
250+
if(SWIFT_CONCURRENCY_USES_DISPATCH)
251+
if(NOT EXISTS "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}")
252+
message(SEND_ERROR "Concurrency require libdispatch on non-Darwin hosts. Please specify SWIFT_PATH_TO_LIBDISPATCH_SOURCE")
253+
endif()
254+
endif()

0 commit comments

Comments
 (0)