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.
This commit is contained in:
Saleem Abdulrasool
2020-01-25 08:49:23 -08:00
parent 03e2757c66
commit 15f6606abd
5 changed files with 24 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -0,0 +1 @@
1

View File

@@ -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

View File

@@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.15.1)
set(CMAKE_OSX_ARCHITECTURES "armv7;arm64;i386;x86_64")
project(SwiftMultiArch
LANGUAGES Swift)