From b1eb493c11f38f651c2a8f0489918f3a55feeb99 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 5 Apr 2017 14:54:02 -0400 Subject: cmGlobalGenerator: Abort generation earlier on export() error --- Source/cmGlobalGenerator.cxx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index ce83e2e..a9243eb 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1347,10 +1347,11 @@ void cmGlobalGenerator::Generate() for (std::map::iterator it = this->BuildExportSets.begin(); it != this->BuildExportSets.end(); ++it) { - if (!it->second->GenerateImportFile() && - !cmSystemTools::GetErrorOccuredFlag()) { - this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, - "Could not write export file."); + if (!it->second->GenerateImportFile()) { + if (!cmSystemTools::GetErrorOccuredFlag()) { + this->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, + "Could not write export file."); + } return; } } -- cgit v0.12 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 From 5f4e26dfc8c4ae26e9226236a05d20b826100db9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 5 Apr 2017 14:00:27 -0400 Subject: Xcode: Refactor object directory name computation Factor out a helper function to compute the object directory name architecture component. --- Source/cmGlobalXCodeGenerator.cxx | 29 +++++++++++++++++++---------- Source/cmGlobalXCodeGenerator.h | 2 ++ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index cbad52c..efcbeff 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -152,6 +152,8 @@ cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(cmake* cm, this->CurrentLocalGenerator = 0; this->XcodeBuildCommandInitialized = false; + this->ComputeObjectDirArch(); + cm->GetState()->SetIsGeneratorMultiConfig(true); } @@ -3210,6 +3212,21 @@ void cmGlobalXCodeGenerator::ComputeArchitectures(cmMakefile* mf) } } +void cmGlobalXCodeGenerator::ComputeObjectDirArch() +{ + if (this->XcodeVersion >= 21) { + this->ObjectDirArch = "$(CURRENT_ARCH)"; + } else { +#if defined(__ppc__) + this->ObjectDirArch = "ppc"; +#elif defined(__i386) + this->ObjectDirArch = "i386"; +#else + this->ObjectDirArch = ""; +#endif + } +} + void cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::vector& targets) { @@ -3719,15 +3736,7 @@ void cmGlobalXCodeGenerator::ComputeTargetObjectDirectory( std::string configName = this->GetCMakeCFGIntDir(); std::string dir = this->GetObjectsNormalDirectory("$(PROJECT_NAME)", configName, gt); - if (this->XcodeVersion >= 21) { - dir += "$(CURRENT_ARCH)/"; - } else { -#ifdef __ppc__ - dir += "ppc/"; -#endif -#ifdef __i386 - dir += "i386/"; -#endif - } + dir += this->ObjectDirArch; + dir += "/"; gt->ObjectDirectory = dir; } diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index beb789b..2cd9985 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -241,6 +241,7 @@ private: const cmGeneratorTarget* t) const; void ComputeArchitectures(cmMakefile* mf); + void ComputeObjectDirArch(); void addObject(cmXCodeObject* obj); std::string PostBuildMakeTarget(std::string const& tName, @@ -263,6 +264,7 @@ private: std::map FileRefs; std::map XCodeObjectMap; std::vector Architectures; + std::string ObjectDirArch; std::string GeneratorToolset; }; -- cgit v0.12 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 efcbeff..d07cc3d 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 2cd9985..7921842 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 v0.12