Skip to content

Commit

Permalink
Move SWIFT_CONCURRENCY_USES_DISPATCH to StdlibOptions.cmake
Browse files Browse the repository at this point in the history
It is only used in the stdlib build, so really has no business being set in the root `CMakeLists.txt`.
  • Loading branch information
MaxDesiatov committed May 10, 2023
1 parent 2db62ca commit 5275255
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
11 changes: 2 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -691,13 +691,6 @@ if(NOT EXISTS "${SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE}")
message(SEND_ERROR "swift-syntax is required to build the Swift compiler. Please run update-checkout or specify SWIFT_PATH_TO_SWIFT_SYNTAX_SOURCE")
endif()

# Use dispatch as the system scheduler by default.
# For convenience, we set this to false when concurrency is disabled.
set(SWIFT_CONCURRENCY_USES_DISPATCH FALSE)
if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY AND "${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "dispatch")
set(SWIFT_CONCURRENCY_USES_DISPATCH TRUE)
endif()

set(SWIFT_BUILD_HOST_DISPATCH FALSE)
if(SWIFT_ENABLE_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
# Only build libdispatch for the host if the host tools are being built and
Expand All @@ -706,9 +699,9 @@ if(SWIFT_ENABLE_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
set(SWIFT_BUILD_HOST_DISPATCH TRUE)
endif()

if(SWIFT_BUILD_HOST_DISPATCH OR SWIFT_CONCURRENCY_USES_DISPATCH)
if(SWIFT_BUILD_HOST_DISPATCH)
if(NOT EXISTS "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}")
message(SEND_ERROR "SourceKit and concurrency require libdispatch on non-Darwin hosts. Please specify SWIFT_PATH_TO_LIBDISPATCH_SOURCE")
message(SEND_ERROR "SourceKit requires libdispatch on non-Darwin hosts. Please specify SWIFT_PATH_TO_LIBDISPATCH_SOURCE")
endif()
endif()
endif()
Expand Down
13 changes: 13 additions & 0 deletions stdlib/cmake/modules/StdlibOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,16 @@ set(SWIFT_RUNTIME_FIXED_BACKTRACER_PATH "" CACHE STRING
"If set, provides a fixed path to the swift-backtrace binary. This
will disable dynamic determination of the path and will also disable
the setting in SWIFT_BACKTRACE.")

# Use dispatch as the system scheduler by default.
# For convenience, we set this to false when concurrency is disabled.
set(SWIFT_CONCURRENCY_USES_DISPATCH FALSE)
if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY AND "${SWIFT_CONCURRENCY_GLOBAL_EXECUTOR}" STREQUAL "dispatch")
set(SWIFT_CONCURRENCY_USES_DISPATCH TRUE)
endif()

if(SWIFT_CONCURRENCY_USES_DISPATCH)
if(NOT EXISTS "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}")
message(SEND_ERROR "Concurrency require libdispatch on non-Darwin hosts. Please specify SWIFT_PATH_TO_LIBDISPATCH_SOURCE")
endif()
endif()

0 comments on commit 5275255

Please sign in to comment.