From d4e86324e9f2fa5f5c359fcf69102e70668fb539 Mon Sep 17 00:00:00 2001 From: Guillaume Lessard Date: Wed, 29 Jul 2026 16:14:42 -0700 Subject: [PATCH] Add availability macro support to CMake build For now this heplfully silences warnings. --- Sources/System/CMakeLists.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Sources/System/CMakeLists.txt b/Sources/System/CMakeLists.txt index a904eb1..c7ffad7 100644 --- a/Sources/System/CMakeLists.txt +++ b/Sources/System/CMakeLists.txt @@ -23,8 +23,27 @@ add_library(SystemPackage WinSDK+Overlay.swift) set_target_properties(SystemPackage PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) + +# Availability macro definitions. +# Should stay in sync with the `availability` array in Package.swift, +# matching `sourceAvailability`, which is the minimum Swift availability. +# Availability support for Darwin platforms is omitted. +set(SWIFT_SYSTEM_AVAILABILITY_VERSIONS + 0.0.1 0.0.2 0.0.3 + 1.1.0 1.1.1 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.4.0 + 1.7.0 + 199) +set(SWIFT_SYSTEM_SOURCE_AVAILABILITY + "macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, visionOS 1.0") +set(SWIFT_SYSTEM_AVAILABILITY_MACRO) +foreach(version IN LISTS SWIFT_SYSTEM_AVAILABILITY_VERSIONS) + list(APPEND SWIFT_SYSTEM_AVAILABILITY_MACRO + "SHELL:-enable-experimental-feature \"AvailabilityMacro=System ${version}:${SWIFT_SYSTEM_SOURCE_AVAILABILITY}\"") +endforeach() + target_compile_options(SystemPackage PRIVATE -enable-experimental-feature Lifetimes + ${SWIFT_SYSTEM_AVAILABILITY_MACRO} "SHELL:-package-name swift-system") target_sources(SystemPackage PRIVATE FilePath/FilePath.swift