diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 1f579f822..d587f899a 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -29,6 +29,7 @@ // do I need an ALL_BUILD // link libraries stuff // exe/lib output paths +// PBXBuildFile can not be reused, or error occurs //---------------------------------------------------------------------------- cmGlobalXCodeGenerator::cmGlobalXCodeGenerator() @@ -443,14 +444,18 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, target->AddAttribute("dependencies", dependencies); target->AddAttribute("name", this->CreateString(cmtarget.GetName())); target->AddAttribute("productName",this->CreateString(cmtarget.GetName())); + cmXCodeObject* fileRef = this->CreateObject(cmXCodeObject::PBXFileReference); fileRef->AddAttribute("explicitFileType", this->CreateString(fileTypeString.c_str())); - fileRef->AddAttribute("includedInIndex", this->CreateString("0")); +// fileRef->AddAttribute("includedInIndex", this->CreateString("0")); fileRef->AddAttribute("path", this->CreateString(productName.c_str())); fileRef->AddAttribute("refType", this->CreateString("3")); - fileRef->AddAttribute("sourceTree", this->CreateString("BUILT_PRODUCTS_DIR")); - target->AddAttribute("productReference", this->CreateObjectReference(fileRef)); + fileRef->AddAttribute("sourceTree", + this->CreateString("BUILT_PRODUCTS_DIR")); + + target->AddAttribute("productReference", + this->CreateObjectReference(fileRef)); target->AddAttribute("productType", this->CreateString(productTypeString.c_str())); target->SetcmTarget(&cmtarget); @@ -515,8 +520,9 @@ void cmGlobalXCodeGenerator::AddDependTarget(cmXCodeObject* target, void cmGlobalXCodeGenerator::AddLinkTarget(cmXCodeObject* target , cmXCodeObject* dependTarget ) { - cmXCodeObject* buildfile = this->CreateObject(cmXCodeObject::PBXBuildFile); cmXCodeObject* ref = dependTarget->GetObject("productReference"); + + cmXCodeObject* buildfile = this->CreateObject(cmXCodeObject::PBXBuildFile); buildfile->AddAttribute("fileRef", ref); cmXCodeObject* settings = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); @@ -553,7 +559,10 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) if(dptarget) { this->AddDependTarget(target, dptarget); - this->AddLinkTarget(target, dptarget); + if(cmtarget->GetType() != cmTarget::STATIC_LIBRARY) + { + this->AddLinkTarget(target, dptarget); + } } else { @@ -654,7 +663,7 @@ void cmGlobalXCodeGenerator::CreateXCodeObjects(cmLocalGenerator* , cmXCodeObject* productRef = t->GetObject("productReference"); if(productRef) { - productGroupChildren->AddObject(productRef); + productGroupChildren->AddObject(productRef->GetObject()); } } m_RootObject->AddAttribute("targets", allTargets); diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index cf75a96a7..b315b23ff 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -25,12 +25,20 @@ cmXCodeObject::cmXCodeObject(PBXType ptype, Type type) m_Object =0; m_IsA = ptype; - cmOStringStream str; - str << (void*)this; - str << (void*)this; - str << (void*)this; - m_Id = str.str(); + if(type == OBJECT) + { + cmOStringStream str; + str << (void*)this; + str << (void*)this; + str << (void*)this; + m_Id = str.str(); + } + else + { + m_Id = "Temporary cmake object, should not be refered to in xcode file"; + } cmSystemTools::ReplaceString(m_Id, "0x", ""); + m_Id = cmSystemTools::UpperCase(m_Id); if(m_Id.size() < 24) { int diff = 24 - m_Id.size(); @@ -126,3 +134,13 @@ void cmXCodeObject::PrintList(std::vector const& objs, cmXCodeObject::Indent(1, out); out << "};\n"; } + + +void cmXCodeObject::CopyAttributes(cmXCodeObject* copy) +{ + this->m_ObjectAttributes = copy->m_ObjectAttributes; + this->m_List = copy->m_List; + this->m_String = copy->m_String; + this->m_Object = copy->m_Object; +} + diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index 61cda1632..89990737f 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -37,6 +37,10 @@ public: { m_Object = value; } + cmXCodeObject* GetObject() + { + return m_Object; + } void AddObject(cmXCodeObject* value) { m_List.push_back(value); @@ -87,6 +91,7 @@ public: { m_PBXTargetDependency = d; } + void CopyAttributes(cmXCodeObject* ); private: cmTarget* m_cmTarget;