Commit 25e61686 authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'swift-xcode-10.2'

96dece6d

 Xcode: Update default Swift language version for Xcode 10.2
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !2912
parents 762a41fd 96dece6d
Pipeline #129358 canceled with stage
in 0 seconds
CMAKE_Swift_LANGUAGE_VERSION
----------------------------
Set to the Swift language version number. If not set, the legacy "2.3"
version is assumed.
Set to the Swift language version number. If not set, the oldest legacy
version known to be available in the host Xcode version is assumed:
* Swift ``4.0`` for Xcode 10.2 and above.
* Swift ``3.0`` for Xcode 8.3 and above.
* Swift ``2.3`` for Xcode 8.2 and below.
......@@ -332,6 +332,8 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
if("${lang}" STREQUAL "Swift")
if(CMAKE_Swift_LANGUAGE_VERSION)
set(id_lang_version "SWIFT_VERSION = ${CMAKE_Swift_LANGUAGE_VERSION};")
elseif(XCODE_VERSION VERSION_GREATER_EQUAL 10.2)
set(id_lang_version "SWIFT_VERSION = 4.0;")
elseif(XCODE_VERSION VERSION_GREATER_EQUAL 8.3)
set(id_lang_version "SWIFT_VERSION = 3.0;")
else()
......
......@@ -3142,6 +3142,8 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects(
if (const char* vers = this->CurrentMakefile->GetDefinition(
"CMAKE_Swift_LANGUAGE_VERSION")) {
swiftVersion = vers;
} else if (this->XcodeVersion >= 102) {
swiftVersion = "4.0";
} else if (this->XcodeVersion >= 83) {
swiftVersion = "3.0";
} else {
......
cmake_minimum_required(VERSION 3.3)
project(SwiftOnly Swift)
if(NOT XCODE_VERSION VERSION_LESS 8.0)
if(NOT XCODE_VERSION VERSION_LESS 10.2)
set(CMAKE_Swift_LANGUAGE_VERSION 5.0)
elseif(NOT XCODE_VERSION VERSION_LESS 8.0)
set(CMAKE_Swift_LANGUAGE_VERSION 3.0)
endif()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment