|
|
@@ -12,6 +12,7 @@
|
|
|
|
|
|
#include <cm/memory>
|
|
|
#include <cmext/algorithm>
|
|
|
+#include <cmext/string_view>
|
|
|
|
|
|
#include "cmsys/RegularExpression.hxx"
|
|
|
|
|
|
@@ -3118,6 +3119,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));
|
|
|
@@ -3217,7 +3226,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;
|