diff options
author | Craig Scott <craig.scott@crascit.com> | 2020-07-21 11:18:50 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-07-21 11:19:02 (GMT) |
commit | 8abeec58f339f804ad5cb4a58a75e20f0dc878a1 (patch) | |
tree | 4b67a7ecf4251b9a69b299e6ff226306d58a836b /Source/cmGlobalXCodeGenerator.cxx | |
parent | cd580a99bdaa658487d7080279c9d394545c4f10 (diff) | |
parent | 26673bf48011a48fe0ad01e97409a32c1f50143d (diff) | |
download | CMake-8abeec58f339f804ad5cb4a58a75e20f0dc878a1.zip CMake-8abeec58f339f804ad5cb4a58a75e20f0dc878a1.tar.gz CMake-8abeec58f339f804ad5cb4a58a75e20f0dc878a1.tar.bz2 |
Merge topic 'xcode-native-arch'
26673bf480 Xcode: Explicitly specify default native architecture on macOS
ce624cfbd4 cmGlobalXCodeGenerator: Save CMAKE_SYSTEM_NAME in member
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5023
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 360807c..e54de5d 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -12,6 +12,7 @@ #include <cm/memory> #include <cmext/algorithm> +#include <cmext/string_view> #include "cmsys/RegularExpression.hxx" @@ -272,6 +273,13 @@ std::string cmGlobalXCodeGenerator::FindXcodeBuildCommand() return makeProgram; } +bool cmGlobalXCodeGenerator::SetSystemName(std::string const& s, + cmMakefile* mf) +{ + this->SystemName = s; + return this->cmGlobalGenerator::SetSystemName(s, mf); +} + bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts, bool build, cmMakefile* mf) { @@ -3375,6 +3383,14 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( if (archs.empty()) { // Tell Xcode to use NATIVE_ARCH instead of ARCHS. buildSettings->AddAttribute("ONLY_ACTIVE_ARCH", this->CreateString("YES")); + // When targeting macOS, use only the host architecture. + if (this->SystemName == "Darwin"_s && + (!sysroot || !*sysroot || + cmSystemTools::LowerCase(sysroot).find("macos") != + std::string::npos)) { + buildSettings->AddAttribute("ARCHS", + this->CreateString("$(NATIVE_ARCH_ACTUAL)")); + } } else { // Tell Xcode to use ARCHS (ONLY_ACTIVE_ARCH defaults to NO). buildSettings->AddAttribute("ARCHS", this->CreateString(archs)); @@ -3480,7 +3496,8 @@ void cmGlobalXCodeGenerator::ComputeArchitectures(cmMakefile* mf) } if (this->Architectures.empty()) { - // With no ARCHS we use ONLY_ACTIVE_ARCH. + // With no ARCHS we use ONLY_ACTIVE_ARCH and possibly a + // platform-specific default ARCHS placeholder value. // Look up the arch that Xcode chooses in this case. if (const char* arch = mf->GetDefinition("CMAKE_XCODE_ARCHS")) { this->ObjectDirArchDefault = arch; |