Xcode: Refactor internal architecture list construction

Factor population of the `Architectures` member out into a helper to
avoid duplication.
This commit is contained in:
Brad King
2017-04-05 13:33:37 -04:00
parent b1eb493c11
commit 5b29fd6d4d
2 changed files with 17 additions and 17 deletions

View File

@@ -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<cmXCodeObject*>& targets)
{

View File

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