-
Notifications
You must be signed in to change notification settings - Fork 10.5k
CMake: Find Dispatch module #79455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMake: Find Dispatch module #79455
Conversation
@compnerd, can I have you check that the filepaths work on Windows? I wasn't sure quite how to interpret the location from the xml files of the installer. |
f7d953b
to
df64a1c
Compare
dispatch_LIBRARY dispatch_INCLUDE_DIR) | ||
elseif(WIN32) | ||
# Issue: https://github.com/swiftlang/swift/issues/79591 | ||
message(FATAL_ERROR "79591: Finddispatch.cmake module not implemented for Windows yet") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I think that should do it. Only have the implib and headers on Windows, sort of like the Apple SDKs.
@swift-ci please smoke test |
Implementing an initial `Finddispatch.cmake` module to find Dispatch from the system SDK on Apple platforms. Still should implement a basic mechanism for finding it on Windows and Linux. Note that those platforms will likely use the dispatch config mechanism most frequently, but this should still work as a fallback. This mechanism is the only one that works for Apple platforms though as those use libdispatch from the SDK rather than building it with corelibs-libdispatch. When building for Linux and Windows, it is possible to build a custom corelibs-libdispatch runtime with `dispatch_DIR` and avoid this module. This module makes it possible to use a pre-built corelibs-libdispatch when one is available without needing to build it. The module uses the `Swift_SDKROOT` filepath as a hint on where to look for the runtime libraries and the `dispatch_STATIC` boolean to specify whether it should find the dynamic library or the static archive.
We need to define the defaulted setting so that it pulls in the default value. Otherwise we hit a configuration failure in `Concurrency/CMakeLists.txt` when it includes the config file specific to the global executor because `SwiftCore_CONCURRENCY_GLOBAL_EXECUTOR` is an empty string.
Enabling building the concurrency runtimes for build-testing purposes.
The dispatch global executor depends on finding dispatch. If dispatch is not found, it will fail to build. Mark it as required to get a configuration failure early.
df64a1c
to
a0682cb
Compare
@swift-ci please smoke test |
@swift-ci please smoke test Linux |
Adding a
Finddispatch.cmake
module to find libdispatch, both on Apple platforms and from corelibs-libdispatch.This gets concurrency building on Apple platforms, picking up Dispatch from the SDK.
When building for Windows and Linux, this module imports the library from the pre-existing SDK, making it possible to build Swift Concurrency without having to build dispatch if an existing copy is available.
If desired, one can set
dispatch_DIR
to point at the directory containingdispatchConfig.cmake
in order to pull in a new build, or set CMAKE_FIND_PACKAGE_PREFER_CONFIG to ignore the module entirely and search for an installed config file.When building for Apple-platforms, the module will only look for the libdispatch from the SDK.
When building for Linux, the module considers two variables:
swift_SDKROOT
:FILEPATH
: Path to the installed Swift SDK. The SDK and toolchain are currently shipped as one package, so this is likely just pointing at the root of the downloaded tarball.dispatch_STATIC
:BOOLEAN
: Hint the module to find the static archive for libdispatch instead of the dynamic library.