From 5b29fd6d4df4eea8ac04a3f6287f721e28b6b5b4 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 5 Apr 2017 13:33:37 -0400 Subject: Xcode: Refactor internal architecture list construction Factor population of the `Architectures` member out into a helper to avoid duplication. --- Source/cmGlobalXCodeGenerator.cxx | 32 +++++++++++++++----------------- Source/cmGlobalXCodeGenerator.h | 2 ++ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index febe95d..cbad52c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -282,13 +282,7 @@ void cmGlobalXCodeGenerator::EnableLanguage( } mf->AddDefinition("CMAKE_GENERATOR_NO_COMPILER_ENV", "1"); this->cmGlobalGenerator::EnableLanguage(lang, mf, optional); - const char* osxArch = mf->GetDefinition("CMAKE_OSX_ARCHITECTURES"); - const char* sysroot = mf->GetDefinition("CMAKE_OSX_SYSROOT"); - if (osxArch && sysroot) { - this->Architectures.clear(); - cmSystemTools::ExpandListArgument(std::string(osxArch), - this->Architectures); - } + this->ComputeArchitectures(mf); } void cmGlobalXCodeGenerator::GenerateBuildCommand( @@ -3089,23 +3083,16 @@ bool cmGlobalXCodeGenerator::CreateXCodeObjects( this->CreateString(defaultConfigName)); cmXCodeObject* buildSettings = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); - const char* osxArch = - this->CurrentMakefile->GetDefinition("CMAKE_OSX_ARCHITECTURES"); const char* sysroot = this->CurrentMakefile->GetDefinition("CMAKE_OSX_SYSROOT"); const char* deploymentTarget = this->CurrentMakefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET"); - std::string archs; if (sysroot) { - if (osxArch) { - // recompute this as it may have been changed since enable language - this->Architectures.clear(); - cmSystemTools::ExpandListArgument(std::string(osxArch), - this->Architectures); - archs = cmJoin(this->Architectures, " "); - } buildSettings->AddAttribute("SDKROOT", this->CreateString(sysroot)); } + // recompute this as it may have been changed since enable language + this->ComputeArchitectures(this->CurrentMakefile); + std::string const archs = cmJoin(this->Architectures, " "); if (archs.empty()) { // Tell Xcode to use NATIVE_ARCH instead of ARCHS. buildSettings->AddAttribute("ONLY_ACTIVE_ARCH", this->CreateString("YES")); @@ -3212,6 +3199,17 @@ std::string cmGlobalXCodeGenerator::GetObjectsNormalDirectory( return dir; } +void cmGlobalXCodeGenerator::ComputeArchitectures(cmMakefile* mf) +{ + this->Architectures.clear(); + const char* osxArch = mf->GetDefinition("CMAKE_OSX_ARCHITECTURES"); + const char* sysroot = mf->GetDefinition("CMAKE_OSX_SYSROOT"); + if (osxArch && sysroot) { + cmSystemTools::ExpandListArgument(std::string(osxArch), + this->Architectures); + } +} + void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::vector& targets) { diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 172e414..beb789b 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -240,6 +240,8 @@ private: const std::string& configName, const cmGeneratorTarget* t) const; + void ComputeArchitectures(cmMakefile* mf); + void addObject(cmXCodeObject* obj); std::string PostBuildMakeTarget(std::string const& tName, std::string const& configName); -- cgit v0.12