Skip to content

Commit 7017362

Browse files
authored
Merge pull request #35939 from davezarzycki/pr35939
[CMake] Formalize whether libdispatch is used/allowed
2 parents 2259db2 + ceea7b2 commit 7017362

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

CMakeLists.txt

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ set(CMAKE_CXX_EXTENSIONS NO)
5050
# First include general CMake utilities.
5151
include(SwiftUtils)
5252
include(CheckSymbolExists)
53+
include(CMakeDependentOption)
5354

5455
#
5556
# User-configurable options that control the inclusion and default build
@@ -406,6 +407,24 @@ option(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY
406407
"Enable experimental Swift concurrency model"
407408
FALSE)
408409

410+
option(SWIFT_ENABLE_DISPATCH
411+
"Enable use of libdispatch"
412+
TRUE)
413+
414+
cmake_dependent_option(SWIFT_BUILD_SYNTAXPARSERLIB
415+
"Build the Swift Syntax Parser library" TRUE
416+
"SWIFT_ENABLE_DISPATCH" FALSE)
417+
cmake_dependent_option(SWIFT_BUILD_ONLY_SYNTAXPARSERLIB
418+
"Only build the Swift Syntax Parser library" FALSE
419+
"SWIFT_BUILD_SYNTAXPARSERLIB" FALSE)
420+
421+
cmake_dependent_option(SWIFT_BUILD_SOURCEKIT
422+
"Build SourceKit" TRUE
423+
"SWIFT_ENABLE_DISPATCH" FALSE)
424+
cmake_dependent_option(SWIFT_ENABLE_SOURCEKIT_TESTS
425+
"Enable running SourceKit tests" TRUE
426+
"SWIFT_BUILD_SOURCEKIT" FALSE)
427+
409428
#
410429
# End of user-configurable options.
411430
#
@@ -429,11 +448,6 @@ if(CMAKE_C_COMPILER_ID MATCHES Clang)
429448
add_compile_options($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:-Werror=gnu>)
430449
endif()
431450

432-
option(SWIFT_BUILD_SYNTAXPARSERLIB "Build the Swift Syntax Parser library" TRUE)
433-
option(SWIFT_BUILD_ONLY_SYNTAXPARSERLIB "Only build the Swift Syntax Parser library" FALSE)
434-
option(SWIFT_BUILD_SOURCEKIT "Build SourceKit" TRUE)
435-
option(SWIFT_ENABLE_SOURCEKIT_TESTS "Enable running SourceKit tests" ${SWIFT_BUILD_SOURCEKIT})
436-
437451
# Use dispatch as the system scheduler by default.
438452
# For convenience, we set this to false when concurrency is disabled.
439453
set(SWIFT_CONCURRENCY_USES_DISPATCH FALSE)
@@ -442,14 +456,12 @@ if(SWIFT_ENABLE_EXPERIMENTAL_CONCURRENCY AND NOT SWIFT_STDLIB_SINGLE_THREADED_RU
442456
endif()
443457

444458
set(SWIFT_BUILD_HOST_DISPATCH FALSE)
445-
if(SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT)
446-
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
459+
if(SWIFT_ENABLE_DISPATCH AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
460+
if(SWIFT_BUILD_SYNTAXPARSERLIB OR SWIFT_BUILD_SOURCEKIT)
447461
set(SWIFT_BUILD_HOST_DISPATCH TRUE)
448462
endif()
449-
endif()
450463

451-
if(SWIFT_BUILD_HOST_DISPATCH OR SWIFT_CONCURRENCY_USES_DISPATCH)
452-
if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
464+
if(SWIFT_BUILD_HOST_DISPATCH OR SWIFT_CONCURRENCY_USES_DISPATCH)
453465
if(NOT EXISTS "${SWIFT_PATH_TO_LIBDISPATCH_SOURCE}")
454466
message(SEND_ERROR "SyntaxParserLib, SourceKit, and concurrency require libdispatch on non-Darwin hosts. Please specify SWIFT_PATH_TO_LIBDISPATCH_SOURCE")
455467
endif()
@@ -961,7 +973,9 @@ if (LLVM_ENABLE_DOXYGEN)
961973
message(STATUS "Doxygen: enabled")
962974
endif()
963975

964-
include(Libdispatch)
976+
if(SWIFT_ENABLE_DISPATCH)
977+
include(Libdispatch)
978+
endif()
965979

966980
# Add all of the subdirectories, where we actually do work.
967981

0 commit comments

Comments
 (0)