diff options
author | Brad King <brad.king@kitware.com> | 2019-05-20 14:55:11 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-05-20 14:55:27 (GMT) |
commit | a9fb9a8774a7b1dd411542d1d14fb537968e32f1 (patch) | |
tree | 2d74dc351b298a5317d05634170c91a8b43bc07e /Modules/CMakeDetermineSwiftCompiler.cmake | |
parent | 28ee31149030c75c32ebbf134502a9d020dbd54b (diff) | |
parent | a9180ccf9a9e845658ba455e2dbc2447b18d2654 (diff) | |
download | CMake-a9fb9a8774a7b1dd411542d1d14fb537968e32f1.zip CMake-a9fb9a8774a7b1dd411542d1d14fb537968e32f1.tar.gz CMake-a9fb9a8774a7b1dd411542d1d14fb537968e32f1.tar.bz2 |
Merge topic 'ninja-swift'
a9180ccf9a Tests: add a check for the Swift compiler
d745551fb6 Help: add some initial documentation for Swift support
9a182c9e5b Auxiliary: update vim syntax highlighting
e9b0063e8e Modules: add build rules for Swift Ninja support
b6412e3e38 Ninja: add placeholders to support Swift build
7d7f31161d Ninja: add support for Swift's output-file-map.json
d688c4c19d Swift: remove unnecessary unreleased Ninja infrastructure
0723582208 Swift: Detect compiler version
...
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3297
Diffstat (limited to 'Modules/CMakeDetermineSwiftCompiler.cmake')
-rw-r--r-- | Modules/CMakeDetermineSwiftCompiler.cmake | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/Modules/CMakeDetermineSwiftCompiler.cmake b/Modules/CMakeDetermineSwiftCompiler.cmake index dd02d54..2fcf7b0 100644 --- a/Modules/CMakeDetermineSwiftCompiler.cmake +++ b/Modules/CMakeDetermineSwiftCompiler.cmake @@ -1,15 +1,46 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. - include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake) +# Local system-specific compiler preferences for this language. +include(Platform/${CMAKE_SYSTEM_NAME}-Determine-Swift OPTIONAL) +include(Platform/${CMAKE_SYSTEM_NAME}-Swift OPTIONAL) +if(NOT CMAKE_Swift_COMPILER_NAMES) + set(CMAKE_Swift_COMPILER_NAMES swiftc) +endif() + if("${CMAKE_GENERATOR}" STREQUAL "Xcode") if(XCODE_VERSION VERSION_LESS 6.1) message(FATAL_ERROR "Swift language not supported by Xcode ${XCODE_VERSION}") endif() set(CMAKE_Swift_COMPILER_XCODE_TYPE sourcecode.swift) _cmake_find_compiler_path(Swift) +elseif("${CMAKE_GENERATOR}" STREQUAL "Ninja") + if(CMAKE_Swift_COMPILER) + _cmake_find_compiler_path(Swift) + else() + set(CMAKE_Swift_COMPILER_INIT NOTFOUND) + + if(NOT $ENV{SWIFTC} STREQUAL "") + get_filename_component(CMAKE_Swift_COMPILER_INIT $ENV{SWIFTC} PROGRAM + PROGRAM_ARGS CMAKE_Swift_FLAGS_ENV_INIT) + if(CMAKE_Swift_FLAGS_ENV_INIT) + set(CMAKE_Swift_COMPILER_ARG1 "${CMAKE_Swift_FLAGS_ENV_INIT}" CACHE + STRING "First argument to the Swift compiler") + endif() + if(NOT EXISTS ${CMAKE_Swift_COMPILER_INIT}) + message(FATAL_ERROR "Could not find compiler set in environment variable SWIFTC\n$ENV{SWIFTC}.\n${CMAKE_Swift_COMPILER_INIT}") + endif() + endif() + + if(NOT CMAKE_Swift_COMPILER_INIT) + set(CMAKE_Swift_COMPILER_LIST swiftc ${_CMAKE_TOOLCHAIN_PREFIX}swiftc) + endif() + + _cmake_find_compiler(Swift) + endif() + mark_as_advanced(CMAKE_Swift_COMPILER) else() message(FATAL_ERROR "Swift language not supported by \"${CMAKE_GENERATOR}\" generator") endif() @@ -18,11 +49,13 @@ endif() if(NOT CMAKE_Swift_COMPILER_ID_RUN) set(CMAKE_Swift_COMPILER_ID_RUN 1) - list(APPEND CMAKE_Swift_COMPILER_ID_MATCH_VENDORS Apple) - set(CMAKE_Swift_COMPILER_ID_MATCH_VENDOR_REGEX_Apple "com.apple.xcode.tools.swift.compiler") + if("${CMAKE_GENERATOR}" STREQUAL "Xcode") + list(APPEND CMAKE_Swift_COMPILER_ID_MATCH_VENDORS Apple) + set(CMAKE_Swift_COMPILER_ID_MATCH_VENDOR_REGEX_Apple "com.apple.xcode.tools.swift.compiler") - set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_REGEX "\nCompileSwiftSources[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]* -c[^\r\n]*CompilerIdSwift/CompilerId/main.swift") - set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_INDEX 2) + set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_REGEX "\nCompileSwiftSources[^\n]*(\n[ \t]+[^\n]*)*\n[ \t]+([^ \t\r\n]+)[^\r\n]* -c[^\r\n]*CompilerIdSwift/CompilerId/main.swift") + set(CMAKE_Swift_COMPILER_ID_TOOL_MATCH_INDEX 2) + endif() # Try to identify the compiler. set(CMAKE_Swift_COMPILER_ID) @@ -40,6 +73,6 @@ unset(_CMAKE_PROCESSING_LANGUAGE) # configure variables set in this file for fast reload later on configure_file(${CMAKE_ROOT}/Modules/CMakeSwiftCompiler.cmake.in - ${CMAKE_PLATFORM_INFO_DIR}/CMakeSwiftCompiler.cmake - @ONLY - ) + ${CMAKE_PLATFORM_INFO_DIR}/CMakeSwiftCompiler.cmake @ONLY) + +set(CMAKE_Swift_COMPILER_ENV_VAR "SWIFTC") |