From 8c346bbc6ec3321c8ac99a5495cf4d842c71e260 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 5 Apr 2017 14:14:13 -0400 Subject: Xcode: Compute a concrete object file arch dir if possible --- Source/cmGlobalXCodeGenerator.cxx | 19 ++++++++++++++++++- Source/cmGlobalXCodeGenerator.h | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index efcbeff628..d07cc3d712 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -152,6 +152,7 @@ cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(cmake* cm, this->CurrentLocalGenerator = 0; this->XcodeBuildCommandInitialized = false; + this->ObjectDirArchDefault = "$(CURRENT_ARCH)"; this->ComputeObjectDirArch(); cm->GetState()->SetIsGeneratorMultiConfig(true); @@ -3210,12 +3211,28 @@ void cmGlobalXCodeGenerator::ComputeArchitectures(cmMakefile* mf) cmSystemTools::ExpandListArgument(std::string(osxArch), this->Architectures); } + + if (this->Architectures.empty()) { + // With no ARCHS we use ONLY_ACTIVE_ARCH. + // Look up the arch that Xcode chooses in this case. + if (const char* arch = mf->GetDefinition("CMAKE_XCODE_CURRENT_ARCH")) { + this->ObjectDirArchDefault = arch; + } + } + + this->ComputeObjectDirArch(); } void cmGlobalXCodeGenerator::ComputeObjectDirArch() { if (this->XcodeVersion >= 21) { - this->ObjectDirArch = "$(CURRENT_ARCH)"; + if (this->Architectures.size() > 1) { + this->ObjectDirArch = "$(CURRENT_ARCH)"; + } else if (!this->Architectures.empty()) { + this->ObjectDirArch = this->Architectures[0]; + } else { + this->ObjectDirArch = this->ObjectDirArchDefault; + } } else { #if defined(__ppc__) this->ObjectDirArch = "ppc"; diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 2cd99855cf..79218423c3 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -264,6 +264,7 @@ private: std::map FileRefs; std::map XCodeObjectMap; std::vector Architectures; + std::string ObjectDirArchDefault; std::string ObjectDirArch; std::string GeneratorToolset; }; -- cgit v1.2.1