Xcode: Port internal API to cmGeneratorTarget.

This commit is contained in:
Stephen Kelly 2015-10-17 15:20:23 +02:00
parent eb3be7d688
commit a527abf099
2 changed files with 19 additions and 16 deletions

View File

@ -2639,23 +2639,24 @@ cmGlobalXCodeGenerator::GetTargetLinkFlagsVar(cmTarget const& cmtarget) const
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
const char* cmGlobalXCodeGenerator::GetTargetFileType(cmTarget& cmtarget) const char* cmGlobalXCodeGenerator::GetTargetFileType(
cmGeneratorTarget* target)
{ {
switch(cmtarget.GetType()) switch(target->GetType())
{ {
case cmState::OBJECT_LIBRARY: case cmState::OBJECT_LIBRARY:
case cmState::STATIC_LIBRARY: case cmState::STATIC_LIBRARY:
return "archive.ar"; return "archive.ar";
case cmState::MODULE_LIBRARY: case cmState::MODULE_LIBRARY:
if (cmtarget.IsXCTestOnApple()) if (target->Target->IsXCTestOnApple())
return "wrapper.cfbundle"; return "wrapper.cfbundle";
else if (cmtarget.IsCFBundleOnApple()) else if (target->Target->IsCFBundleOnApple())
return "wrapper.plug-in"; return "wrapper.plug-in";
else else
return ((this->XcodeVersion >= 22)? return ((this->XcodeVersion >= 22)?
"compiled.mach-o.executable" : "compiled.mach-o.dylib"); "compiled.mach-o.executable" : "compiled.mach-o.dylib");
case cmState::SHARED_LIBRARY: case cmState::SHARED_LIBRARY:
return (cmtarget.GetPropertyAsBool("FRAMEWORK")? return (target->GetPropertyAsBool("FRAMEWORK")?
"wrapper.framework" : "compiled.mach-o.dylib"); "wrapper.framework" : "compiled.mach-o.dylib");
case cmState::EXECUTABLE: case cmState::EXECUTABLE:
return "compiled.mach-o.executable"; return "compiled.mach-o.executable";
@ -2665,28 +2666,29 @@ const char* cmGlobalXCodeGenerator::GetTargetFileType(cmTarget& cmtarget)
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
const char* cmGlobalXCodeGenerator::GetTargetProductType(cmTarget& cmtarget) const char* cmGlobalXCodeGenerator::GetTargetProductType(
cmGeneratorTarget* target)
{ {
switch(cmtarget.GetType()) switch(target->GetType())
{ {
case cmState::OBJECT_LIBRARY: case cmState::OBJECT_LIBRARY:
case cmState::STATIC_LIBRARY: case cmState::STATIC_LIBRARY:
return "com.apple.product-type.library.static"; return "com.apple.product-type.library.static";
case cmState::MODULE_LIBRARY: case cmState::MODULE_LIBRARY:
if (cmtarget.IsXCTestOnApple()) if (target->Target->IsXCTestOnApple())
return "com.apple.product-type.bundle.unit-test"; return "com.apple.product-type.bundle.unit-test";
else if (cmtarget.IsCFBundleOnApple()) else if (target->Target->IsCFBundleOnApple())
return "com.apple.product-type.bundle"; return "com.apple.product-type.bundle";
else else
return ((this->XcodeVersion >= 22)? return ((this->XcodeVersion >= 22)?
"com.apple.product-type.tool" : "com.apple.product-type.tool" :
"com.apple.product-type.library.dynamic"); "com.apple.product-type.library.dynamic");
case cmState::SHARED_LIBRARY: case cmState::SHARED_LIBRARY:
return (cmtarget.GetPropertyAsBool("FRAMEWORK")? return (target->GetPropertyAsBool("FRAMEWORK")?
"com.apple.product-type.framework" : "com.apple.product-type.framework" :
"com.apple.product-type.library.dynamic"); "com.apple.product-type.library.dynamic");
case cmState::EXECUTABLE: case cmState::EXECUTABLE:
return (cmtarget.GetPropertyAsBool("MACOSX_BUNDLE")? return (target->GetPropertyAsBool("MACOSX_BUNDLE")?
"com.apple.product-type.application" : "com.apple.product-type.application" :
"com.apple.product-type.tool"); "com.apple.product-type.tool");
default: break; default: break;
@ -2727,9 +2729,11 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget,
target->AddAttribute("name", this->CreateString(cmtarget.GetName())); target->AddAttribute("name", this->CreateString(cmtarget.GetName()));
target->AddAttribute("productName",this->CreateString(cmtarget.GetName())); target->AddAttribute("productName",this->CreateString(cmtarget.GetName()));
cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget);
cmXCodeObject* fileRef = cmXCodeObject* fileRef =
this->CreateObject(cmXCodeObject::PBXFileReference); this->CreateObject(cmXCodeObject::PBXFileReference);
if(const char* fileType = this->GetTargetFileType(cmtarget)) if(const char* fileType = this->GetTargetFileType(gtgt))
{ {
fileRef->AddAttribute("explicitFileType", this->CreateString(fileType)); fileRef->AddAttribute("explicitFileType", this->CreateString(fileType));
} }
@ -2742,7 +2746,6 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget,
} }
else else
{ {
cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget);
fullName = gtgt->GetFullName(defConfig.c_str()); fullName = gtgt->GetFullName(defConfig.c_str());
} }
fileRef->AddAttribute("path", this->CreateString(fullName.c_str())); fileRef->AddAttribute("path", this->CreateString(fullName.c_str()));
@ -2752,7 +2755,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget,
fileRef->SetComment(cmtarget.GetName().c_str()); fileRef->SetComment(cmtarget.GetName().c_str());
target->AddAttribute("productReference", target->AddAttribute("productReference",
this->CreateObjectReference(fileRef)); this->CreateObjectReference(fileRef));
if(const char* productType = this->GetTargetProductType(cmtarget)) if(const char* productType = this->GetTargetProductType(gtgt))
{ {
target->AddAttribute("productType", this->CreateString(productType)); target->AddAttribute("productType", this->CreateString(productType));
} }

View File

@ -137,8 +137,8 @@ private:
void ForceLinkerLanguages(); void ForceLinkerLanguages();
void ForceLinkerLanguage(cmTarget& cmtarget); void ForceLinkerLanguage(cmTarget& cmtarget);
const char* GetTargetLinkFlagsVar(cmTarget const& cmtarget) const; const char* GetTargetLinkFlagsVar(cmTarget const& cmtarget) const;
const char* GetTargetFileType(cmTarget& cmtarget); const char* GetTargetFileType(cmGeneratorTarget* target);
const char* GetTargetProductType(cmTarget& cmtarget); const char* GetTargetProductType(cmGeneratorTarget* target);
std::string AddConfigurations(cmXCodeObject* target, cmTarget& cmtarget); std::string AddConfigurations(cmXCodeObject* target, cmTarget& cmtarget);
void AppendOrAddBuildSetting(cmXCodeObject* settings, const char* attr, void AppendOrAddBuildSetting(cmXCodeObject* settings, const char* attr,
const char* value); const char* value);