diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2005-01-27 21:11:44 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2005-01-27 21:11:44 (GMT) |
commit | 97a51d2172fec2d9d33713322bca96647bc94515 (patch) | |
tree | 8533af745e8f42b90a31cc5a0ed7bcf23082dfad /Source/cmGlobalXCodeGenerator.cxx | |
parent | c22cc421e0344074dd4db2f6003ede96a4df7160 (diff) | |
download | CMake-97a51d2172fec2d9d33713322bca96647bc94515.zip CMake-97a51d2172fec2d9d33713322bca96647bc94515.tar.gz CMake-97a51d2172fec2d9d33713322bca96647bc94515.tar.bz2 |
ENH: add more xcode stuff
Diffstat (limited to 'Source/cmGlobalXCodeGenerator.cxx')
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 157 |
1 files changed, 139 insertions, 18 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 6296e29..6f8d1d9 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -20,6 +20,7 @@ #include "cmXCodeObject.h" #include "cmake.h" #include "cmGeneratedFileStream.h" +#include "cmSourceFile.h" //---------------------------------------------------------------------------- cmGlobalXCodeGenerator::cmGlobalXCodeGenerator() @@ -78,55 +79,175 @@ void cmGlobalXCodeGenerator::ClearXCodeObjects() } //---------------------------------------------------------------------------- -cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::PBXType ptype, - cmXCodeObject::Type type) +cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::PBXType ptype) { - cmXCodeObject* obj = new cmXCodeObject(ptype, type); + cmXCodeObject* obj = new cmXCodeObject(ptype, cmXCodeObject::OBJECT); m_XCodeObjects.push_back(obj); return obj; } -cmXCodeObject* cmGlobalXCodeGenerator::CreateString(const char* s) +//---------------------------------------------------------------------------- +cmXCodeObject* cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::Type type) { - cmXCodeObject* obj = new cmXCodeObject(cmXCodeObject::None, cmXCodeObject::STRING); + cmXCodeObject* obj = new cmXCodeObject(cmXCodeObject::None, type); m_XCodeObjects.push_back(obj); + return obj; +} + +cmXCodeObject* cmGlobalXCodeGenerator::CreateString(const char* s) +{ + cmXCodeObject* obj = this->CreateObject(cmXCodeObject::STRING); obj->SetString(s); return obj; } +cmXCodeObject* +cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg, + cmSourceFile* sf) +{ + cmXCodeObject* fileRef = this->CreateObject(cmXCodeObject::PBXFileReference); + cmXCodeObject* fileRefPtr = this->CreateObject(cmXCodeObject::OBJECT_REF); + fileRefPtr->SetObject(fileRef); + cmXCodeObject* buildFile = this->CreateObject(cmXCodeObject::PBXBuildFile); + buildFile->AddAttribute("fileRef", fileRefPtr); + cmXCodeObject* settings = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); + buildFile->AddAttribute("settings", settings); + fileRef->AddAttribute("fileEncoding", this->CreateString("4")); + fileRef->AddAttribute("lastKnownFileType", this->CreateString("sourcecode.cpp.cpp;")); + fileRef->AddAttribute("path", this->CreateString( + lg->ConvertToRelativeOutputPath(sf->GetFullPath().c_str()).c_str())); + fileRef->AddAttribute("refType", this->CreateString("4")); + fileRef->AddAttribute("sourceTree", this->CreateString("<group>")); + return buildFile; +} + //---------------------------------------------------------------------------- -void cmGlobalXCodeGenerator::CreateXCodeObjects(cmLocalGenerator* , - std::vector<cmLocalGenerator*>& +void cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen, + std::vector<cmXCodeObject*>& targets) +{ + cmTargets &tgts = gen->GetMakefile()->GetTargets(); + for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++) + { + // create source build phase + cmXCodeObject* sourceBuildPhase = this->CreateObject(cmXCodeObject::PBXSourcesBuildPhase); + sourceBuildPhase->AddAttribute("buildActionMask", this->CreateString("2147483647")); + cmXCodeObject* buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); + sourceBuildPhase->AddAttribute("files", buildFiles); + sourceBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", this->CreateString("0")); + std::vector<cmSourceFile*> &classes = l->second.GetSourceFiles(); + // add all the sources + for(std::vector<cmSourceFile*>::iterator i = classes.begin(); + i != classes.end(); ++i) + { + buildFiles->AddObject(this->CreateXCodeSourceFile(gen, *i)); + } + // create header build phase + cmXCodeObject* headerBuildPhase = this->CreateObject(cmXCodeObject::PBXHeadersBuildPhase); + headerBuildPhase->AddAttribute("buildActionMask", this->CreateString("2147483647")); + buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); + headerBuildPhase->AddAttribute("files", buildFiles); + headerBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", this->CreateString("0")); + + // create framework build phase + cmXCodeObject* frameworkBuildPhase = this->CreateObject(cmXCodeObject::PBXFrameworksBuildPhase); + frameworkBuildPhase->AddAttribute("buildActionMask", this->CreateString("2147483647")); + buildFiles = this->CreateObject(cmXCodeObject::OBJECT_LIST); + frameworkBuildPhase->AddAttribute("files", buildFiles); + frameworkBuildPhase->AddAttribute("runOnlyForDeploymentPostprocessing", this->CreateString("0")); + + cmXCodeObject* buildPhases = this->CreateObject(cmXCodeObject::OBJECT_LIST); + buildPhases->AddObject(sourceBuildPhase); + buildPhases->AddObject(headerBuildPhase); + buildPhases->AddObject(frameworkBuildPhase); + + if((l->second.GetType() == cmTarget::STATIC_LIBRARY) || + (l->second.GetType() == cmTarget::SHARED_LIBRARY) || + (l->second.GetType() == cmTarget::MODULE_LIBRARY)) + { + } + else if ( l->second.GetType() == cmTarget::EXECUTABLE ) + { + cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXNativeTarget); + targets.push_back(target); + target->AddAttribute("buildPhases", buildPhases); + cmXCodeObject* buildRules = this->CreateObject(cmXCodeObject::OBJECT_LIST); + target->AddAttribute("buildRules", buildRules); + cmXCodeObject* buildSettings = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); + buildSettings->AddAttribute("INSTALL_PATH", this->CreateString("/usr/local/bin")); + buildSettings->AddAttribute("OPTIMIZATION_CFLAGS", this->CreateString("")); + buildSettings->AddAttribute("OTHER_CFLAGS", this->CreateString("")); + buildSettings->AddAttribute("OTHER_LDFLAGS", this->CreateString("")); + buildSettings->AddAttribute("OTHER_REZFLAGS", this->CreateString("")); + buildSettings->AddAttribute("PRODUCT_NAME", this->CreateString(l->first.c_str())); + buildSettings->AddAttribute("SECTORDER_FLAGS", this->CreateString("")); + buildSettings->AddAttribute("WARNING_CFLAGS", + this->CreateString("-Wmost -Wno-four-char-constants -Wno-unknown-pragmas")); + target->AddAttribute("buildSettings", buildSettings); + cmXCodeObject* dependencies = this->CreateObject(cmXCodeObject::OBJECT_LIST); + target->AddAttribute("dependencies", dependencies); + target->AddAttribute("name", this->CreateString(l->first.c_str())); + target->AddAttribute("productName",this->CreateString(l->first.c_str())); + cmXCodeObject* fileRef = this->CreateObject(cmXCodeObject::PBXFileReference); + fileRef->AddAttribute("explicitFileType", this->CreateString("compiled.mach-o.executable")); + fileRef->AddAttribute("includedInIndex", this->CreateString("0")); + fileRef->AddAttribute("path", this->CreateString(l->first.c_str())); + fileRef->AddAttribute("refType", this->CreateString("3")); + fileRef->AddAttribute("sourceTree", this->CreateString("BUILT_PRODUCTS_DIR")); + cmXCodeObject* fileRefPtr = this->CreateObject(cmXCodeObject::OBJECT_REF); + fileRefPtr->AddObject(fileRef); + target->AddAttribute("productReference", fileRefPtr); + target->AddAttribute("productReference", this->CreateString("com.apple.product-type.tool")); + } + else if (l->second.GetType() == cmTarget::UTILITY) + { + } + } + +} + +//---------------------------------------------------------------------------- +void cmGlobalXCodeGenerator::CreateXCodeObjects(cmLocalGenerator* root, + std::vector<cmLocalGenerator*>& + generators ) { delete m_RootObject; this->ClearXCodeObjects(); - cmXCodeObject* group = this->CreateObject(cmXCodeObject::None, cmXCodeObject::ATTRIBUTE_GROUP); + cmXCodeObject* group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); group->AddAttribute("COPY_PHASE_STRIP", this->CreateString("NO")); - cmXCodeObject* developBuildStyle = this->CreateObject(cmXCodeObject::PBXBuildStyle, - cmXCodeObject::OBJECT); + cmXCodeObject* developBuildStyle = this->CreateObject(cmXCodeObject::PBXBuildStyle); developBuildStyle->AddAttribute("name", this->CreateString("Development")); developBuildStyle->AddAttribute("buildSettings", group); - group = this->CreateObject(cmXCodeObject::None, cmXCodeObject::ATTRIBUTE_GROUP); + group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); group->AddAttribute("COPY_PHASE_STRIP", this->CreateString("YES")); - cmXCodeObject* deployBuildStyle = this->CreateObject(cmXCodeObject::PBXBuildStyle, - cmXCodeObject::OBJECT); + cmXCodeObject* deployBuildStyle = this->CreateObject(cmXCodeObject::PBXBuildStyle); deployBuildStyle->AddAttribute("name", this->CreateString("Deployment")); deployBuildStyle->AddAttribute("buildSettings", group); - cmXCodeObject* listObjs = this->CreateObject(cmXCodeObject::None, - cmXCodeObject::OBJECT_LIST); + cmXCodeObject* listObjs = this->CreateObject(cmXCodeObject::OBJECT_LIST); listObjs->AddObject(developBuildStyle); listObjs->AddObject(deployBuildStyle); - m_RootObject = this->CreateObject(cmXCodeObject::PBXProject, cmXCodeObject::OBJECT); - group = this->CreateObject(cmXCodeObject::None, cmXCodeObject::ATTRIBUTE_GROUP); + m_RootObject = this->CreateObject(cmXCodeObject::PBXProject); + group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP); m_RootObject->AddAttribute("buildSettings", group); m_RootObject->AddAttribute("buildSyles", listObjs); m_RootObject->AddAttribute("hasScannedForEncodings", this->CreateString("0")); - + std::vector<cmXCodeObject*> targets; + for(std::vector<cmLocalGenerator*>::iterator i = generators.begin(); + i != generators.end(); ++i) + { + this->CreateXCodeTargets(*i, targets); + } + cmXCodeObject* allTargets = this->CreateObject(cmXCodeObject::OBJECT_LIST); + for(std::vector<cmXCodeObject*>::iterator i = targets.begin(); + i != targets.end(); ++i) + { + allTargets->AddObject(*i); + } + m_RootObject->AddAttribute("targets", allTargets); } //---------------------------------------------------------------------------- |