|
6 | 6 | # See http://swift.org/LICENSE.txt for license information |
7 | 7 | # See http://swift.org/CONTRIBUTORS.txt for Swift project authors |
8 | 8 |
|
| 9 | +cmake_minimum_required(VERSION 3.19.6) |
| 10 | + |
| 11 | +if(POLICY CMP0077) |
| 12 | + cmake_policy(SET CMP0077 NEW) |
| 13 | +endif() |
| 14 | + |
9 | 15 | if(POLICY CMP0091) |
10 | 16 | cmake_policy(SET CMP0091 NEW) |
11 | 17 | endif() |
12 | 18 |
|
13 | | -cmake_minimum_required(VERSION 3.19.6) |
14 | | - |
15 | | -list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) |
16 | | - |
17 | 19 | project(SwiftDriver LANGUAGES C Swift) |
18 | 20 |
|
19 | | -set(CMAKE_Swift_LANGUAGE_VERSION 5) |
20 | | -set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift) |
21 | | -set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY MultiThreadedDLL) |
22 | | - |
23 | 21 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
24 | 22 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
25 | 23 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
26 | 24 |
|
27 | 25 | set(CMAKE_MACOSX_RPATH YES) |
28 | 26 | set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL) |
| 27 | +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) |
| 28 | + |
| 29 | +set(CMAKE_Swift_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY MultiThreadedDLL) |
| 30 | +set(CMAKE_Swift_LANGUAGE_VERSION 5) |
| 31 | +set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift) |
29 | 32 |
|
30 | 33 | # ensure Swift compiler can find _CSwiftScan |
31 | 34 | add_compile_options($<$<COMPILE_LANGUAGE:Swift>:-I$<SEMICOLON>${CMAKE_CURRENT_SOURCE_DIR}/Sources/CSwiftScan/include>) |
32 | 35 |
|
33 | 36 | option(BUILD_SHARED_LIBS "Build shared libraries by default" YES) |
34 | 37 |
|
35 | | -find_package(TSC CONFIG REQUIRED) |
| 38 | +# Toolchain Vended Dependencies |
| 39 | +find_package(dispatch QUIET) |
| 40 | +find_package(Foundation QUIET) |
| 41 | + |
| 42 | +include(FetchContent) |
| 43 | + |
| 44 | +set(_SD_SAVED_BUILD_TESTING ${BUILD_TESTING}) |
| 45 | +set(_SD_SAVED_BUILD_EXAMPLES ${BUILD_EXAMPLES}) |
| 46 | + |
| 47 | +set(BUILD_TESTING NO) |
| 48 | +set(BUILD_EXAMPLES NO) |
| 49 | + |
| 50 | +find_package(ArgumentParser CONFIG) |
| 51 | +if(NOT ArgumentParser_FOUND) |
| 52 | + message("-- Vending swift-argument-parser") |
| 53 | + FetchContent_Declare(ArgumentParser |
| 54 | + GIT_REPOSITORY https://github.com/apple/swift-argument-parser |
| 55 | + GIT_TAG 1.2.3) |
| 56 | + FetchContent_MakeAvailable(ArgumentParser) |
| 57 | +endif() |
36 | 58 |
|
37 | 59 | find_package(LLBuild CONFIG) |
38 | 60 | if(NOT LLBuild_FOUND) |
39 | | - find_package(LLBuild REQUIRED) |
| 61 | + if(APPLE) |
| 62 | + find_package(LLBuild REQUIRED) |
| 63 | + else() |
| 64 | + message("-- Vending swift-llbuild") |
| 65 | + set(LLBUILD_SUPPORT_BINDINGS Swift) |
| 66 | + FetchContent_Declare(LLBuild |
| 67 | + GIT_REPOSITORY https://github.com/apple/swift-llbuild |
| 68 | + GIT_TAG main) |
| 69 | + FetchContent_MakeAvailable(LLBuild) |
| 70 | + endif() |
40 | 71 | endif() |
41 | 72 |
|
42 | | -find_package(dispatch QUIET) |
43 | | -find_package(Foundation QUIET) |
44 | | -find_package(Yams CONFIG REQUIRED) |
45 | | -find_package(ArgumentParser CONFIG REQUIRED) |
| 73 | +find_package(TSC CONFIG) |
| 74 | +if(NOT TSC_FOUND) |
| 75 | + message("-- Vending swift-tools-support-core") |
| 76 | + FetchContent_Declare(ToolsSupportCore |
| 77 | + GIT_REPOSITORY https://github.com/apple/swift-tools-support-core |
| 78 | + GIT_TAG main) |
| 79 | + FetchContent_MakeAvailable(ToolsSupportCore) |
| 80 | +endif() |
| 81 | + |
| 82 | +find_package(Yams CONFIG) |
| 83 | +if(NOT Yams_FOUND) |
| 84 | + message("-- Vending yams") |
| 85 | + FetchContent_Declare(Yams |
| 86 | + GIT_REPOSITORY https://github.com/jpsim/yams |
| 87 | + GIT_TAG 5.0.6) |
| 88 | + FetchContent_MakeAvailable(Yams) |
| 89 | +endif() |
| 90 | + |
| 91 | +set(BUILD_TESTING ${_SD_SAVED_BUILD_TESTING}) |
| 92 | +set(BUILD_EXAMPLES ${_SD_SAVED_BUILD_EXAMPLES}) |
46 | 93 |
|
47 | 94 | add_subdirectory(Sources) |
48 | 95 | add_subdirectory(cmake/modules) |
0 commit comments