Xcode: Each target dependency edge needs a unique object (#13935)
Generate a unique PBXTargetDependency and PBXContainerItemProxy for every edge in the dependency graph as required by the Xcode format. Xcode only accidentally loads project files that re-use the same PBXTargetDependency for every edge leading to a single target. If one is removed by hand in the IDE then Xcode may crash due to dangling references from the others. Since cmGlobalXCodeGenerator::AddDependTarget is called exactly once for every edge in the target dependency graph we do not need to keep track of which edges have been visited to avoid generating duplicates.
This commit is contained in:
parent
781ea6d1ca
commit
b005140451
|
@ -2517,29 +2517,25 @@ std::string cmGlobalXCodeGenerator::GetOrCreateId(const char* name,
|
|||
void cmGlobalXCodeGenerator::AddDependTarget(cmXCodeObject* target,
|
||||
cmXCodeObject* dependTarget)
|
||||
{
|
||||
cmXCodeObject* targetdep = dependTarget->GetPBXTargetDependency();
|
||||
if(!targetdep)
|
||||
{
|
||||
cmXCodeObject* container =
|
||||
this->CreateObject(cmXCodeObject::PBXContainerItemProxy);
|
||||
container->SetComment("PBXContainerItemProxy");
|
||||
container->AddAttribute("containerPortal",
|
||||
this->CreateObjectReference(this->RootObject));
|
||||
container->AddAttribute("proxyType", this->CreateString("1"));
|
||||
container->AddAttribute("remoteGlobalIDString",
|
||||
this->CreateObjectReference(dependTarget));
|
||||
container->AddAttribute("remoteInfo",
|
||||
this->CreateString(
|
||||
dependTarget->GetTarget()->GetName()));
|
||||
targetdep =
|
||||
this->CreateObject(cmXCodeObject::PBXTargetDependency);
|
||||
targetdep->SetComment("PBXTargetDependency");
|
||||
targetdep->AddAttribute("target",
|
||||
this->CreateObjectReference(dependTarget));
|
||||
targetdep->AddAttribute("targetProxy",
|
||||
this->CreateObjectReference(container));
|
||||
dependTarget->SetPBXTargetDependency(targetdep);
|
||||
}
|
||||
// This is called once for every edge in the target dependency graph.
|
||||
cmXCodeObject* container =
|
||||
this->CreateObject(cmXCodeObject::PBXContainerItemProxy);
|
||||
container->SetComment("PBXContainerItemProxy");
|
||||
container->AddAttribute("containerPortal",
|
||||
this->CreateObjectReference(this->RootObject));
|
||||
container->AddAttribute("proxyType", this->CreateString("1"));
|
||||
container->AddAttribute("remoteGlobalIDString",
|
||||
this->CreateObjectReference(dependTarget));
|
||||
container->AddAttribute("remoteInfo",
|
||||
this->CreateString(
|
||||
dependTarget->GetTarget()->GetName()));
|
||||
cmXCodeObject* targetdep =
|
||||
this->CreateObject(cmXCodeObject::PBXTargetDependency);
|
||||
targetdep->SetComment("PBXTargetDependency");
|
||||
targetdep->AddAttribute("target",
|
||||
this->CreateObjectReference(dependTarget));
|
||||
targetdep->AddAttribute("targetProxy",
|
||||
this->CreateObjectReference(container));
|
||||
|
||||
cmXCodeObject* depends = target->GetObject("dependencies");
|
||||
if(!depends)
|
||||
|
|
|
@ -38,7 +38,6 @@ cmXCodeObject::~cmXCodeObject()
|
|||
cmXCodeObject::cmXCodeObject(PBXType ptype, Type type)
|
||||
{
|
||||
this->Version = 15;
|
||||
this->PBXTargetDependencyValue = 0;
|
||||
this->Target = 0;
|
||||
this->Object =0;
|
||||
|
||||
|
|
|
@ -120,14 +120,6 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
cmXCodeObject* GetPBXTargetDependency()
|
||||
{
|
||||
return this->PBXTargetDependencyValue;
|
||||
}
|
||||
void SetPBXTargetDependency(cmXCodeObject* d)
|
||||
{
|
||||
this->PBXTargetDependencyValue = d;
|
||||
}
|
||||
void CopyAttributes(cmXCodeObject* );
|
||||
|
||||
void AddDependLibrary(const char* configName,
|
||||
|
@ -170,7 +162,6 @@ protected:
|
|||
cmStdString Comment;
|
||||
cmStdString String;
|
||||
cmXCodeObject* Object;
|
||||
cmXCodeObject* PBXTargetDependencyValue;
|
||||
std::vector<cmXCodeObject*> List;
|
||||
std::map<cmStdString, StringVec> DependLibraries;
|
||||
std::map<cmStdString, StringVec> DependTargets;
|
||||
|
|
Loading…
Reference in New Issue