|
| 1 | +##===----------------------------------------------------------------------===## |
| 2 | +## |
| 3 | +## This source file is part of the Swift open source project |
| 4 | +## |
| 5 | +## Copyright (c) 2024 Apple Inc. and the Swift project authors |
| 6 | +## Licensed under Apache License v2.0 |
| 7 | +## |
| 8 | +## See LICENSE.txt for license information |
| 9 | +## See CONTRIBUTORS.md for the list of Swift project authors |
| 10 | +## |
| 11 | +## SPDX-License-Identifier: Apache-2.0 |
| 12 | +## |
| 13 | +##===----------------------------------------------------------------------===## |
| 14 | + |
| 15 | +cmake_minimum_required(VERSION 3.24) |
| 16 | + |
| 17 | +if(POLICY CMP0156) |
| 18 | + # Deduplicate linked libraries where appropriate |
| 19 | + cmake_policy(SET CMP0156 NEW) |
| 20 | +endif() |
| 21 | + |
| 22 | +if(POLICY CMP0157) |
| 23 | + # New Swift build model: improved incremental build performance and LSP support |
| 24 | + cmake_policy(SET CMP0157 NEW) |
| 25 | +endif() |
| 26 | + |
| 27 | +project(SwiftFoundation |
| 28 | + LANGUAGES C Swift) |
| 29 | + |
| 30 | +if(NOT SWIFT_SYSTEM_NAME) |
| 31 | + if(CMAKE_SYSTEM_NAME STREQUAL Darwin) |
| 32 | + set(SWIFT_SYSTEM_NAME macosx) |
| 33 | + else() |
| 34 | + set(SWIFT_SYSTEM_NAME "$<LOWER_CASE:${CMAKE_SYSTEM_NAME}>") |
| 35 | + endif() |
| 36 | +endif() |
| 37 | + |
| 38 | +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 39 | +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 40 | +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
| 41 | +set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift) |
| 42 | + |
| 43 | +set(BUILD_TESTING NO) |
| 44 | + |
| 45 | +set(COLLECTIONS_SINGLE_MODULE YES) |
| 46 | +set(COLLECTIONS_FOUNDATION_TOOLCHAIN_MODULE YES) |
| 47 | + |
| 48 | +# Make sure our dependencies exists |
| 49 | +include(FetchContent) |
| 50 | +if (_SwiftFoundationICU_SourceDIR) |
| 51 | + FetchContent_Declare(SwiftFoundationICU |
| 52 | + SOURCE_DIR ${_SwiftFoundationICU_SourceDIR}) |
| 53 | +else() |
| 54 | + FetchContent_Declare(SwiftFoundationICU |
| 55 | + GIT_REPOSITORY https://github.com/iCharlesHu/swift-foundation-icu.git |
| 56 | + GIT_TAG charles/cmake-support) |
| 57 | +endif() |
| 58 | +FetchContent_MakeAvailable(SwiftFoundationICU) |
| 59 | + |
| 60 | +if (_SwiftCollections_SourceDIR) |
| 61 | + FetchContent_Declare(SwiftCollections |
| 62 | + SOURCE_DIR ${_SwiftCollections_SourceDIR}) |
| 63 | +else() |
| 64 | + FetchContent_Declare(SwiftCollections |
| 65 | + GIT_REPOSITORY https://github.com/apple/swift-collections.git |
| 66 | + GIT_TAG release/1.1) |
| 67 | +endif() |
| 68 | +FetchContent_MakeAvailable(SwiftCollections) |
| 69 | + |
| 70 | +# Availability Macros (only applies to FoundationEssentials and FoundationInternationalization) |
| 71 | +set(_SwiftFoundation_availability_macros) |
| 72 | +list(APPEND _SwiftFoundation_availability_macros |
| 73 | + "SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend \"AvailabilityMacro=FoundationPreview 0.1:macOS 13.3, iOS 16.4, tvOS 16.4, watchOS 9.4\">" |
| 74 | + "SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend \"AvailabilityMacro=FoundationPreview 0.2:macOS 13.3, iOS 16.4, tvOS 16.4, watchOS 9.4\">" |
| 75 | + "SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend \"AvailabilityMacro=FoundationPreview 0.3:macOS 13.3, iOS 16.4, tvOS 16.4, watchOS 9.4\">" |
| 76 | + "SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend \"AvailabilityMacro=FoundationPreview 0.4:macOS 13.3, iOS 16.4, tvOS 16.4, watchOS 9.4\">" |
| 77 | + "SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend \"AvailabilityMacro=FoundationPredicate 0.1:macOS 14, iOS 17, tvOS 17, watchOS 10\">" |
| 78 | + "SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend \"AvailabilityMacro=FoundationPredicate 0.2:macOS 14, iOS 17, tvOS 17, watchOS 10\">" |
| 79 | + "SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend \"AvailabilityMacro=FoundationPredicate 0.3:macOS 14, iOS 17, tvOS 17, watchOS 10\">" |
| 80 | + "SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend \"AvailabilityMacro=FoundationPredicate 0.4:macOS 14, iOS 17, tvOS 17, watchOS 10\">" |
| 81 | + "SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend \"AvailabilityMacro=FoundationPredicateRegex 0.1:macOS 10000, iOS 10000, tvOS 10000, watchOS 10000\">" |
| 82 | + "SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend \"AvailabilityMacro=FoundationPredicateRegex 0.2:macOS 10000, iOS 10000, tvOS 10000, watchOS 10000\">" |
| 83 | + "SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend \"AvailabilityMacro=FoundationPredicateRegex 0.3:macOS 10000, iOS 10000, tvOS 10000, watchOS 10000\">" |
| 84 | + "SHELL:$<$<COMPILE_LANGUAGE:Swift>:-Xfrontend -enable-experimental-feature -Xfrontend \"AvailabilityMacro=FoundationPredicateRegex 0.4:macOS 10000, iOS 10000, tvOS 10000, watchOS 10000\">") |
| 85 | + |
| 86 | +include(SwiftSupport) |
| 87 | + |
| 88 | +add_subdirectory(Sources) |
| 89 | +add_subdirectory(cmake/modules) |
0 commit comments