From 608cf8149ccbf8954926ab7c86fd658099a52f7b Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 28 Jul 2014 11:41:53 -0400 Subject: Xcode: Fix static library creation for Xcode 6 (#15038) Xcode 6 introduced an 'OTHER_LIBTOOLFLAGS' setting for the "Other Librarian Flags" of a static library. Now 'OTHER_LDFLAGS' are ignored. Teach the Xcode generator to choose the correct name for the build setting based on the type of target and the version of Xcode. Inspired-by: Jamie Kirkpatrick --- Source/cmGlobalXCodeGenerator.cxx | 28 +++++++++++++++++++++++----- Source/cmGlobalXCodeGenerator.h | 1 + 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 484b28f..3503e19 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2298,7 +2298,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } } - buildSettings->AddAttribute("OTHER_LDFLAGS", + buildSettings->AddAttribute(this->GetTargetLinkFlagsVar(target), this->CreateString(extraLinkOptions.c_str())); buildSettings->AddAttribute("OTHER_REZFLAGS", this->CreateString("")); @@ -2522,6 +2522,22 @@ std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target, } //---------------------------------------------------------------------------- +const char* +cmGlobalXCodeGenerator::GetTargetLinkFlagsVar(cmTarget const& cmtarget) const +{ + if(this->XcodeVersion >= 60 && + (cmtarget.GetType() == cmTarget::STATIC_LIBRARY || + cmtarget.GetType() == cmTarget::OBJECT_LIBRARY)) + { + return "OTHER_LIBTOOLFLAGS"; + } + else + { + return "OTHER_LDFLAGS"; + } +} + +//---------------------------------------------------------------------------- const char* cmGlobalXCodeGenerator::GetTargetFileType(cmTarget& cmtarget) { switch(cmtarget.GetType()) @@ -2834,8 +2850,9 @@ void cmGlobalXCodeGenerator sep = " "; linkObjs += this->XCodeEscapePath(oi->c_str()); } - this->AppendBuildSettingAttribute(target, "OTHER_LDFLAGS", - linkObjs.c_str(), configName); + this->AppendBuildSettingAttribute( + target, this->GetTargetLinkFlagsVar(*cmtarget), + linkObjs.c_str(), configName); } // Skip link information for object libraries. @@ -2913,8 +2930,9 @@ void cmGlobalXCodeGenerator target->AddDependTarget(configName, li->Target->GetName()); } } - this->AppendBuildSettingAttribute(target, "OTHER_LDFLAGS", - linkLibs.c_str(), configName); + this->AppendBuildSettingAttribute( + target, this->GetTargetLinkFlagsVar(*cmtarget), + linkLibs.c_str(), configName); } } } diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index c9d20c2..a7b54e9 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -141,6 +141,7 @@ private: cmXCodeObject* buildPhases); void ForceLinkerLanguages(); void ForceLinkerLanguage(cmTarget& cmtarget); + const char* GetTargetLinkFlagsVar(cmTarget const& cmtarget) const; const char* GetTargetFileType(cmTarget& cmtarget); const char* GetTargetProductType(cmTarget& cmtarget); std::string AddConfigurations(cmXCodeObject* target, cmTarget& cmtarget); -- cgit v0.12