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 <jkp@spotify.com>
This commit is contained in:
Brad King 2014-07-28 11:41:53 -04:00
parent 55d6aa36a5
commit 608cf8149c
2 changed files with 24 additions and 5 deletions

View File

@ -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(""));
@ -2521,6 +2521,22 @@ std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target,
return "";
}
//----------------------------------------------------------------------------
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)
{
@ -2834,7 +2850,8 @@ void cmGlobalXCodeGenerator
sep = " ";
linkObjs += this->XCodeEscapePath(oi->c_str());
}
this->AppendBuildSettingAttribute(target, "OTHER_LDFLAGS",
this->AppendBuildSettingAttribute(
target, this->GetTargetLinkFlagsVar(*cmtarget),
linkObjs.c_str(), configName);
}
@ -2913,7 +2930,8 @@ void cmGlobalXCodeGenerator
target->AddDependTarget(configName, li->Target->GetName());
}
}
this->AppendBuildSettingAttribute(target, "OTHER_LDFLAGS",
this->AppendBuildSettingAttribute(
target, this->GetTargetLinkFlagsVar(*cmtarget),
linkLibs.c_str(), configName);
}
}

View File

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