diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 4959cac86..1f579f822 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -25,7 +25,7 @@ //TODO // per file flags -// depend info +// custom commands and clean up custom targets // do I need an ALL_BUILD // link libraries stuff // exe/lib output paths @@ -38,7 +38,8 @@ cmGlobalXCodeGenerator::cmGlobalXCodeGenerator() } //---------------------------------------------------------------------------- -void cmGlobalXCodeGenerator::EnableLanguage(std::vectorconst& lang, +void cmGlobalXCodeGenerator::EnableLanguage(std::vectorconst& + lang, cmMakefile * mf) { mf->AddDefinition("CMAKE_GENERATOR_CC", "gcc"); @@ -307,12 +308,18 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, switch(target.GetType()) { case cmTarget::STATIC_LIBRARY: + { productName += ".a"; + std::string t = "lib"; + t += productName; + productName = t; productType = "com.apple.product-type.library.static"; - fileType = "compiled.mach-o.archive.ar"; + fileType = "archive.ar"; buildSettings->AddAttribute("LIBRARY_STYLE", this->CreateString("STATIC")); break; + } + case cmTarget::MODULE_LIBRARY: buildSettings->AddAttribute("LIBRARY_STYLE", this->CreateString("DYNAMIC")); @@ -347,6 +354,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, case cmTarget::INSTALL_PROGRAMS: break; } + buildSettings->AddAttribute("GCC_OPTIMIZATION_LEVEL", + this->CreateString("0")); buildSettings->AddAttribute("INSTALL_PATH", this->CreateString("/usr/local/bin")); buildSettings->AddAttribute("OPTIMIZATION_CFLAGS", @@ -470,21 +479,28 @@ cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget* t) void cmGlobalXCodeGenerator::AddDependTarget(cmXCodeObject* target, cmXCodeObject* dependTarget) { - cmXCodeObject* container = - this->CreateObject(cmXCodeObject::PBXContainerItemProxy); - container->AddAttribute("containerPortal", - this->CreateObjectReference(m_RootObject)); - container->AddAttribute("proxyType", this->CreateString("1")); - container->AddAttribute("remoteGlobalIDString", - this->CreateObjectReference(dependTarget)); - container->AddAttribute("remoteInfo", - this->CreateString( - dependTarget->GetcmTarget()->GetName())); - cmXCodeObject* targetdep = - this->CreateObject(cmXCodeObject::PBXTargetDependency); - targetdep->AddAttribute("target", this->CreateObjectReference(dependTarget)); - targetdep->AddAttribute("targetProxy", - this->CreateObjectReference(container)); + cmXCodeObject* targetdep = dependTarget->GetPBXTargetDependency(); + if(!targetdep) + { + cmXCodeObject* container = + this->CreateObject(cmXCodeObject::PBXContainerItemProxy); + container->AddAttribute("containerPortal", + this->CreateObjectReference(m_RootObject)); + container->AddAttribute("proxyType", this->CreateString("1")); + container->AddAttribute("remoteGlobalIDString", + this->CreateObjectReference(dependTarget)); + container->AddAttribute("remoteInfo", + this->CreateString( + dependTarget->GetcmTarget()->GetName())); + targetdep = + this->CreateObject(cmXCodeObject::PBXTargetDependency); + targetdep->AddAttribute("target", + this->CreateObjectReference(dependTarget)); + targetdep->AddAttribute("targetProxy", + this->CreateObjectReference(container)); + dependTarget->SetPBXTargetDependency(targetdep); + } + cmXCodeObject* depends = target->GetObject("dependencies"); if(!depends) { @@ -496,9 +512,21 @@ void cmGlobalXCodeGenerator::AddDependTarget(cmXCodeObject* target, } } -void cmGlobalXCodeGenerator::AddLinkTarget(cmXCodeObject* , - cmXCodeObject* ) +void cmGlobalXCodeGenerator::AddLinkTarget(cmXCodeObject* target , + cmXCodeObject* dependTarget ) { + cmXCodeObject* buildfile = this->CreateObject(cmXCodeObject::PBXBuildFile); + cmXCodeObject* ref = dependTarget->GetObject("productReference"); + buildfile->AddAttribute("fileRef", ref); + cmXCodeObject* settings = + this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); + buildfile->AddAttribute("settings", settings); + + cmXCodeObject* buildPhases = target->GetObject("buildPhases"); + cmXCodeObject* frameworkBuildPhase = + buildPhases->GetObject(cmXCodeObject::PBXFrameworksBuildPhase); + cmXCodeObject* files = frameworkBuildPhase->GetObject("files"); + files->AddObject(buildfile); } void cmGlobalXCodeGenerator::AddLinkFlag(cmXCodeObject* , @@ -518,7 +546,6 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) cmTarget::LinkLibraries::const_iterator j, jend; j = cmtarget->GetLinkLibraries().begin(); jend = cmtarget->GetLinkLibraries().end(); - std::cerr << "link targets for " << cmtarget->GetName() << "\n"; for(;j!= jend; ++j) { cmTarget* t = this->FindTarget(j->first.c_str()); @@ -547,7 +574,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) } else { - std::cerr << "External Util???: " << i->c_str() << "\n"; + std::cerr << "Error External Util???: " << i->c_str() << "\n"; } } } @@ -587,17 +614,30 @@ void cmGlobalXCodeGenerator::CreateXCodeObjects(cmLocalGenerator* , listObjs->AddObject(deployBuildStyle); cmXCodeObject* mainGroup = this->CreateObject(cmXCodeObject::PBXGroup); - cmXCodeObject* mainGroupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST); + cmXCodeObject* mainGroupChildren = + this->CreateObject(cmXCodeObject::OBJECT_LIST); mainGroup->AddAttribute("children", mainGroupChildren); mainGroup->AddAttribute("refType", this->CreateString("4")); mainGroup->AddAttribute("sourceTree", this->CreateString("")); + cmXCodeObject* productGroup = this->CreateObject(cmXCodeObject::PBXGroup); + productGroup->AddAttribute("name", this->CreateString("Products")); + productGroup->AddAttribute("refType", this->CreateString("4")); + productGroup->AddAttribute("sourceTree", this->CreateString("")); + cmXCodeObject* productGroupChildren = + this->CreateObject(cmXCodeObject::OBJECT_LIST); + productGroup->AddAttribute("children", productGroupChildren); + mainGroupChildren->AddObject(productGroup); + + m_RootObject = this->CreateObject(cmXCodeObject::PBXProject); group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); - m_RootObject->AddAttribute("mainGroup", this->CreateObjectReference(mainGroup)); + m_RootObject->AddAttribute("mainGroup", + this->CreateObjectReference(mainGroup)); m_RootObject->AddAttribute("buildSettings", group); m_RootObject->AddAttribute("buildSyles", listObjs); - m_RootObject->AddAttribute("hasScannedForEncodings", this->CreateString("0")); + m_RootObject->AddAttribute("hasScannedForEncodings", + this->CreateString("0")); std::vector targets; for(std::vector::iterator i = generators.begin(); i != generators.end(); ++i) @@ -611,6 +651,11 @@ void cmGlobalXCodeGenerator::CreateXCodeObjects(cmLocalGenerator* , cmXCodeObject* t = *i; this->AddDependAndLinkInformation(t); allTargets->AddObject(t); + cmXCodeObject* productRef = t->GetObject("productReference"); + if(productRef) + { + productGroupChildren->AddObject(productRef); + } } m_RootObject->AddAttribute("targets", allTargets); } diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx index a9562d9a7..cf75a96a7 100644 --- a/Source/cmXCodeObject.cxx +++ b/Source/cmXCodeObject.cxx @@ -20,7 +20,10 @@ cmXCodeObject::~cmXCodeObject() //---------------------------------------------------------------------------- cmXCodeObject::cmXCodeObject(PBXType ptype, Type type) { -// m_cmTarget = 0; + m_PBXTargetDependency = 0; + m_cmTarget = 0; + m_Object =0; + m_IsA = ptype; cmOStringStream str; str << (void*)this; diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h index e20631f18..61cda1632 100644 --- a/Source/cmXCodeObject.h +++ b/Source/cmXCodeObject.h @@ -64,6 +64,29 @@ public: } return 0; } + // serach the attribute list for an object of the specified type + cmXCodeObject* GetObject(cmXCodeObject::PBXType t) + { + for(std::vector::iterator i = m_List.begin(); + i != m_List.end(); ++i) + { + cmXCodeObject* o = *i; + if(o->m_IsA == t) + { + return o; + } + } + return 0; + } + + cmXCodeObject* GetPBXTargetDependency() + { + return m_PBXTargetDependency; + } + void SetPBXTargetDependency(cmXCodeObject* d) + { + m_PBXTargetDependency = d; + } private: cmTarget* m_cmTarget; @@ -72,6 +95,7 @@ private: PBXType m_IsA; cmStdString m_String; cmXCodeObject* m_Object; + cmXCodeObject* m_PBXTargetDependency; std::vector m_List; std::map m_ObjectAttributes; };