diff options
author | Brad King <brad.king@kitware.com> | 2017-03-29 10:40:59 -0400 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-03-29 10:40:59 -0400 |
commit | 6ca509e7c65a94f4b486bacef766bac717f5308f (patch) | |
tree | 37a52f9fcfbf5ab98d3848ef65062689064a3ac3 | |
parent | d4a995750a1e3101f943a0d2e91fc9688f5e23f7 (diff) | |
parent | 77139e320c8ec7f92e1298cc57fea7276faceb12 (diff) | |
download | cmake-6ca509e7c65a94f4b486bacef766bac717f5308f.tar.gz |
Merge branch '16742-swift-3.0' into release
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 8 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 6 | ||||
-rw-r--r-- | Tests/SwiftMix/ObjCMain.m | 2 | ||||
-rw-r--r-- | Tests/SwiftMix/SwiftMain.swift | 8 |
4 files changed, 15 insertions, 9 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index bb34de5eed..c41a9862c7 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -269,7 +269,13 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} set(id_toolset "") endif() if("${lang}" STREQUAL "Swift") - set(id_lang_version "SWIFT_VERSION = 2.3;") + if(CMAKE_Swift_LANGUAGE_VERSION) + set(id_lang_version "SWIFT_VERSION = ${CMAKE_Swift_LANGUAGE_VERSION};") + elseif(XCODE_VERSION VERSION_GREATER_EQUAL 8.3) + set(id_lang_version "SWIFT_VERSION = 3.0;") + else() + set(id_lang_version "SWIFT_VERSION = 2.3;") + endif() else() set(id_lang_version "") endif() diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 8627cf2820..dd771b1fbe 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3075,10 +3075,14 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( this->CreateString(this->GeneratorToolset)); } if (this->GetLanguageEnabled("Swift")) { - std::string swiftVersion = "2.3"; + std::string swiftVersion; if (const char* vers = this->CurrentMakefile->GetDefinition( "CMAKE_Swift_LANGUAGE_VERSION")) { swiftVersion = vers; + } else if (this->XcodeVersion >= 83) { + swiftVersion = "3.0"; + } else { + swiftVersion = "2.3"; } buildSettings->AddAttribute("SWIFT_VERSION", this->CreateString(swiftVersion)); diff --git a/Tests/SwiftMix/ObjCMain.m b/Tests/SwiftMix/ObjCMain.m index 7fa90aefbe..20f0bf1eec 100644 --- a/Tests/SwiftMix/ObjCMain.m +++ b/Tests/SwiftMix/ObjCMain.m @@ -1,4 +1,4 @@ #import "SwiftMix-Swift.h" int ObjCMain(int argc, char const* const argv[]) { - return [SwiftMainClass SwiftMain:argc argv:argv]; + return [SwiftMainClass SwiftMain]; } diff --git a/Tests/SwiftMix/SwiftMain.swift b/Tests/SwiftMix/SwiftMain.swift index 3629ac82a6..a4a0a62b43 100644 --- a/Tests/SwiftMix/SwiftMain.swift +++ b/Tests/SwiftMix/SwiftMain.swift @@ -1,12 +1,8 @@ import Foundation @objc class SwiftMainClass : NSObject { - class func SwiftMain(argc:Int, argv:UnsafePointer<UnsafePointer<CChar>>) -> Int32 { - dump("argc: \(argc)") - for (var i = 0; i < argc; ++i) { - let argi = String.fromCString(argv[i]) - dump("arg[\(i)]: \(argi)"); - } + class func SwiftMain() -> Int32 { + dump("Hello World!"); return 0; } } |