summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2020-01-25 16:49:23 (GMT)
committerSaleem Abdulrasool <compnerd@compnerd.org>2020-01-28 18:13:28 (GMT)
commit15f6606abdf383c72461651c8cd4ab01cd3da175 (patch)
tree8a6cf734672ec5320aa7b58b6565d3b2fb759885
parent03e2757c665f285f3a75d75841473bc7afb2bbc9 (diff)
downloadCMake-15f6606abdf383c72461651c8cd4ab01cd3da175.zip
CMake-15f6606abdf383c72461651c8cd4ab01cd3da175.tar.gz
CMake-15f6606abdf383c72461651c8cd4ab01cd3da175.tar.bz2
Swift: disallow multiple `CMAKE_OSX_ARCHITECTURES` with Swift
This disallows the use of multiple values in `CMAKE_OSX_ARCHITECTURES` with Swift which does not support FAT compilation.
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx11
-rw-r--r--Tests/RunCMake/Swift/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/Swift/SwiftMultiArch-result.txt1
-rw-r--r--Tests/RunCMake/Swift/SwiftMultiArch-stderr.txt4
-rw-r--r--Tests/RunCMake/Swift/SwiftMultiArch.cmake4
5 files changed, 24 insertions, 0 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 2dd89e3..25bb453 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -660,6 +660,17 @@ bool cmGlobalNinjaGenerator::CheckLanguages(
if (cmContains(languages, "Fortran")) {
return this->CheckFortran(mf);
}
+ if (cmContains(languages, "Swift")) {
+ const std::string architectures =
+ mf->GetSafeDefinition("CMAKE_OSX_ARCHITECTURES");
+ if (architectures.find_first_of(';') != std::string::npos) {
+ mf->IssueMessage(MessageType::FATAL_ERROR,
+ "multiple values for CMAKE_OSX_ARCHITECTURES not "
+ "supported with Swift");
+ cmSystemTools::SetFatalErrorOccured();
+ return false;
+ }
+ }
return true;
}
diff --git a/Tests/RunCMake/Swift/RunCMakeTest.cmake b/Tests/RunCMake/Swift/RunCMakeTest.cmake
index 4817045..918df0b 100644
--- a/Tests/RunCMake/Swift/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Swift/RunCMakeTest.cmake
@@ -7,6 +7,10 @@ if(RunCMake_GENERATOR STREQUAL Xcode)
elseif(RunCMake_GENERATOR STREQUAL Ninja)
if(CMAKE_Swift_COMPILER)
run_cmake(Win32ExecutableDisallowed)
+
+ set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=Darwin)
+ run_cmake(SwiftMultiArch)
+ unset(RunCMake_TEST_OPTIONS)
endif()
else()
run_cmake(NotSupported)
diff --git a/Tests/RunCMake/Swift/SwiftMultiArch-result.txt b/Tests/RunCMake/Swift/SwiftMultiArch-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Swift/SwiftMultiArch-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Swift/SwiftMultiArch-stderr.txt b/Tests/RunCMake/Swift/SwiftMultiArch-stderr.txt
new file mode 100644
index 0000000..874bdc7
--- /dev/null
+++ b/Tests/RunCMake/Swift/SwiftMultiArch-stderr.txt
@@ -0,0 +1,4 @@
+^CMake Error at SwiftMultiArch.cmake:3 \(project\):
+ multiple values for CMAKE_OSX_ARCHITECTURES not supported with Swift
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3
diff --git a/Tests/RunCMake/Swift/SwiftMultiArch.cmake b/Tests/RunCMake/Swift/SwiftMultiArch.cmake
new file mode 100644
index 0000000..5fdb688
--- /dev/null
+++ b/Tests/RunCMake/Swift/SwiftMultiArch.cmake
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 3.15.1)
+set(CMAKE_OSX_ARCHITECTURES "armv7;arm64;i386;x86_64")
+project(SwiftMultiArch
+ LANGUAGES Swift)