summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2005-02-02 22:16:07 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2005-02-02 22:16:07 (GMT)
commit68c419c780a954c48a91291fbc1dcf038d99e7f3 (patch)
tree5c9fb3ca07ff9bfe819b1abb12c20a52cdec433c
parenta9af1c23efa81fd6386904c61386bb45e380348c (diff)
downloadCMake-68c419c780a954c48a91291fbc1dcf038d99e7f3.zip
CMake-68c419c780a954c48a91291fbc1dcf038d99e7f3.tar.gz
CMake-68c419c780a954c48a91291fbc1dcf038d99e7f3.tar.bz2
ENH: getting closer
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx247
-rw-r--r--Source/cmGlobalXCodeGenerator.h13
-rw-r--r--Source/cmLocalGenerator.h3
-rw-r--r--Source/cmXCodeObject.cxx18
-rw-r--r--Source/cmXCodeObject.h4
5 files changed, 121 insertions, 164 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 7968f7d..5d854f2 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -196,7 +196,7 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
fileRef->AddAttribute("path", this->CreateString(
lg->ConvertToRelativeOutputPath(sf->GetFullPath().c_str()).c_str()));
fileRef->AddAttribute("refType", this->CreateString("4"));
- fileRef->AddAttribute("sourceTree", this->CreateString("\"<absolute>\""));
+ fileRef->AddAttribute("sourceTree", this->CreateString("<absolute>"));
return buildFile;
}
@@ -205,6 +205,7 @@ void cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
std::vector<cmXCodeObject*>& targets,
cmXCodeObject* mainGroupChildren)
{
+ m_CurrentLocalGenerator = gen;
m_CurrentMakefile = gen->GetMakefile();
cmTargets &tgts = gen->GetMakefile()->GetTargets();
for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++)
@@ -250,133 +251,103 @@ void cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
buildPhases->AddObject(sourceBuildPhase);
buildPhases->AddObject(headerBuildPhase);
buildPhases->AddObject(frameworkBuildPhase);
- switch(l->second.GetType())
- {
- case cmTarget::STATIC_LIBRARY:
- targets.push_back(this->CreateStaticLibrary(l->second, buildPhases));
- break;
- case cmTarget::SHARED_LIBRARY:
- targets.push_back(this->CreateSharedLibrary(l->second, buildPhases));
- break;
- case cmTarget::MODULE_LIBRARY:
- targets.push_back(this->CreateSharedLibrary(l->second, buildPhases));
- break;
- case cmTarget::EXECUTABLE:
- targets.push_back(this->CreateExecutable(l->second, buildPhases));
- break;
- case cmTarget::UTILITY:
- break;
- case cmTarget::INSTALL_FILES:
- break;
- case cmTarget::INSTALL_PROGRAMS:
- break;
- }
+ targets.push_back(this->CreateXCodeTarget(l->second, buildPhases));
}
+
}
-// to force the location of a target
-//6FE4372B07AAF276004FB461 = {
-//buildSettings = {
-//COPY_PHASE_STRIP = NO;
-//SYMROOT = "/Users/kitware/Bill/CMake-build/test/build/bin";
-//};
-//isa = PBXBuildStyle;
-//name = Development;
-//};
-cmXCodeObject* cmGlobalXCodeGenerator::CreateExecutable(cmTarget& cmtarget,
- cmXCodeObject* buildPhases)
-{
- cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXNativeTarget);
- 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(""));
- std::cerr << m_CurrentMakefile->GetDefineFlags() << "\n";
- buildSettings->AddAttribute("OTHER_CFLAGS",
- this->CreateString(m_CurrentMakefile->GetDefineFlags()));
- buildSettings->AddAttribute("OTHER_LDFLAGS",
- this->CreateString(""));
- buildSettings->AddAttribute("OTHER_REZFLAGS",
- this->CreateString(""));
- buildSettings->AddAttribute("PRODUCT_NAME",
- this->CreateString(cmtarget.GetName()));
- 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(cmtarget.GetName()));
- target->AddAttribute("productName",this->CreateString(cmtarget.GetName()));
- 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(cmtarget.GetName()));
- fileRef->AddAttribute("refType", this->CreateString("3"));
- fileRef->AddAttribute("sourceTree", this->CreateString("BUILT_PRODUCTS_DIR"));
- target->AddAttribute("productReference", this->CreateObjectReference(fileRef));
- target->AddAttribute("productType",
- this->CreateString("\"com.apple.product-type.tool\""));
- return target;
-}
-//----------------------------------------------------------------------------
-cmXCodeObject* cmGlobalXCodeGenerator::CreateStaticLibrary(cmTarget& cmtarget,
- cmXCodeObject* buildPhases)
+void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
+ cmXCodeObject* buildSettings,
+ std::string& fileType,
+ std::string& productType,
+ std::string& productName)
{
- cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXNativeTarget);
- target->AddAttribute("buildPhases", buildPhases);
- cmXCodeObject* buildRules = this->CreateObject(cmXCodeObject::OBJECT_LIST);
- target->AddAttribute("buildRules", buildRules);
- cmXCodeObject* buildSettings =
- this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
+ std::string flags;
+ bool shared = ((target.GetType() == cmTarget::SHARED_LIBRARY) ||
+ (target.GetType() == cmTarget::MODULE_LIBRARY));
+ const char* lang = target.GetLinkerLanguage(this);
+ if(lang)
+ {
+ // Add language-specific flags.
+ m_CurrentLocalGenerator->AddLanguageFlags(flags, lang);
+
+ // Add shared-library flags if needed.
+ m_CurrentLocalGenerator->AddSharedFlags(flags, lang, shared);
+ }
+ // Add include directory flags.
+// this->AppendFlags(flags, this->GetIncludeFlags(lang));
+
+ // Add include directory flags.
+ m_CurrentLocalGenerator->AppendFlags(flags,
+ m_CurrentMakefile->GetDefineFlags());
+ cmSystemTools::ReplaceString(flags, "\"", "\\\"");
+ productName = target.GetName();
+ switch(target.GetType())
+ {
+ case cmTarget::STATIC_LIBRARY:
+ productName += ".a";
+ productType = "com.apple.product-type.library.static";
+ fileType = "compiled.mach-o.archive.ar";
+ buildSettings->AddAttribute("LIBRARY_STYLE",
+ this->CreateString("STATIC"));
+ break;
+ case cmTarget::MODULE_LIBRARY:
+ buildSettings->AddAttribute("LIBRARY_STYLE",
+ this->CreateString("DYNAMIC"));
+ productName += ".so";
+ buildSettings->AddAttribute("OTHER_LDFLAGS",
+ this->CreateString("-bundle"));
+ productType = "com.apple.product-type.library.dynamic";
+ fileType = "compiled.mach-o.dylib";
+ break;
+ case cmTarget::SHARED_LIBRARY:
+ buildSettings->AddAttribute("LIBRARY_STYLE",
+ this->CreateString("DYNAMIC"));
+ productName += ".dylib";
+ buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION",
+ this->CreateString("1"));
+ buildSettings->AddAttribute("DYLIB_CURRENT_VERSION",
+ this->CreateString("1"));
+ buildSettings->AddAttribute("OTHER_LDFLAGS",
+ this->CreateString("-dynamiclib"));
+ productType = "com.apple.product-type.library.dynamic";
+ fileType = "compiled.mach-o.dylib";
+ break;
+ case cmTarget::EXECUTABLE:
+ fileType = "compiled.mach-o.executable";
+ productType = "com.apple.product-type.tool";
+ break;
+ case cmTarget::UTILITY:
+ break;
+ case cmTarget::INSTALL_FILES:
+ break;
+ case cmTarget::INSTALL_PROGRAMS:
+ break;
+ }
buildSettings->AddAttribute("INSTALL_PATH",
this->CreateString("/usr/local/bin"));
- buildSettings->AddAttribute("LIBRARY_STYLE",
- this->CreateString("STATIC"));
buildSettings->AddAttribute("OPTIMIZATION_CFLAGS",
this->CreateString(""));
- std::cerr << m_CurrentMakefile->GetDefineFlags() << "\n";
buildSettings->AddAttribute("OTHER_CFLAGS",
- this->CreateString(m_CurrentMakefile->GetDefineFlags()));
+ this->CreateString(flags.c_str()));
buildSettings->AddAttribute("OTHER_LDFLAGS",
this->CreateString(""));
buildSettings->AddAttribute("OTHER_REZFLAGS",
this->CreateString(""));
- buildSettings->AddAttribute("PRODUCT_NAME",
- this->CreateString(cmtarget.GetName()));
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(cmtarget.GetName()));
- target->AddAttribute("productName",this->CreateString(cmtarget.GetName()));
- cmXCodeObject* fileRef = this->CreateObject(cmXCodeObject::PBXFileReference);
- fileRef->AddAttribute("explicitFileType",
- this->CreateString("\"compiled.mach-o.archive.ar\""));
- fileRef->AddAttribute("includedInIndex", this->CreateString("0"));
- fileRef->AddAttribute("path", this->CreateString(cmtarget.GetName()));
- fileRef->AddAttribute("refType", this->CreateString("3"));
- fileRef->AddAttribute("sourceTree", this->CreateString("BUILT_PRODUCTS_DIR"));
- target->AddAttribute("productReference", this->CreateObjectReference(fileRef));
- target->AddAttribute("productType",
- this->CreateString("\"com.apple.product-type.library.static\""));
- return target;
+ buildSettings->AddAttribute("WARNING_CFLAGS",
+ this->CreateString(
+ "-Wmost -Wno-four-char-constants"
+ " -Wno-unknown-pragmas"));
+ buildSettings->AddAttribute("PRODUCT_NAME",
+ this->CreateString(target.GetName()));
}
-//----------------------------------------------------------------------------
-cmXCodeObject* cmGlobalXCodeGenerator::CreateSharedLibrary(cmTarget& cmtarget,
- cmXCodeObject* buildPhases)
+cmXCodeObject*
+cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget,
+ cmXCodeObject* buildPhases)
{
cmXCodeObject* target = this->CreateObject(cmXCodeObject::PBXNativeTarget);
target->AddAttribute("buildPhases", buildPhases);
@@ -384,35 +355,12 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateSharedLibrary(cmTarget& cmtarget,
target->AddAttribute("buildRules", buildRules);
cmXCodeObject* buildSettings =
this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
- buildSettings->AddAttribute("DYLIB_COMPATIBILITY_VERSION",
- this->CreateString("1"));
- buildSettings->AddAttribute("DYLIB_CURRENT_VERSION",
- this->CreateString("1"));
- buildSettings->AddAttribute("INSTALL_PATH",
- this->CreateString("/usr/local/lib"));
- buildSettings->AddAttribute("LIBRARY_STYLE",
- this->CreateString("DYNAMIC"));
- buildSettings->AddAttribute("OPTIMIZATION_CFLAGS",
- this->CreateString(""));
- std::cerr << m_CurrentMakefile->GetDefineFlags() << "\n" ;
- buildSettings->AddAttribute("OTHER_CFLAGS",
- this->CreateString(m_CurrentMakefile->GetDefineFlags()));
- const char* libFlag = "-dynamiclib";
- if(cmtarget.GetType() == cmTarget::MODULE_LIBRARY)
- {
- libFlag = "-bundle";
- }
- buildSettings->AddAttribute("OTHER_LDFLAGS",
- this->CreateString(libFlag));
-
- buildSettings->AddAttribute("OTHER_REZFLAGS",
- this->CreateString(""));
- buildSettings->AddAttribute("PRODUCT_NAME",
- this->CreateString(cmtarget.GetName()));
- buildSettings->AddAttribute("SECTORDER_FLAGS",
- this->CreateString(""));
- buildSettings->AddAttribute("WARNING_CFLAGS",
- this->CreateString("-Wmost -Wno-four-char-constants -Wno-unknown-pragmas"));
+ std::string fileTypeString;
+ std::string productTypeString;
+ std::string productName;
+ this->CreateBuildSettings(cmtarget,
+ buildSettings, fileTypeString,
+ productTypeString, productName);
target->AddAttribute("buildSettings", buildSettings);
cmXCodeObject* dependencies = this->CreateObject(cmXCodeObject::OBJECT_LIST);
target->AddAttribute("dependencies", dependencies);
@@ -420,19 +368,28 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateSharedLibrary(cmTarget& cmtarget,
target->AddAttribute("productName",this->CreateString(cmtarget.GetName()));
cmXCodeObject* fileRef = this->CreateObject(cmXCodeObject::PBXFileReference);
fileRef->AddAttribute("explicitFileType",
- this->CreateString("\"compiled.mach-o.dylib\""));
+ this->CreateString(fileTypeString.c_str()));
fileRef->AddAttribute("includedInIndex", this->CreateString("0"));
- std::string path = cmtarget.GetName();
- path += ".dylib";
- fileRef->AddAttribute("path", this->CreateString(path.c_str()));
+ 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));
target->AddAttribute("productType",
- this->CreateString("\"com.apple.product-type.library.dynamic\""));
+ this->CreateString(productTypeString.c_str()));
return target;
}
+
+// to force the location of a target
+//6FE4372B07AAF276004FB461 = {
+//buildSettings = {
+//COPY_PHASE_STRIP = NO;
+//SYMROOT = "/Users/kitware/Bill/CMake-build/test/build/bin";
+//};
+//isa = PBXBuildStyle;
+//name = Development;
+//};
+
//----------------------------------------------------------------------------
void cmGlobalXCodeGenerator::CreateXCodeObjects(cmLocalGenerator* ,
std::vector<cmLocalGenerator*>&
@@ -461,7 +418,7 @@ void cmGlobalXCodeGenerator::CreateXCodeObjects(cmLocalGenerator* ,
cmXCodeObject* mainGroupChildren = this->CreateObject(cmXCodeObject::OBJECT_LIST);
mainGroup->AddAttribute("children", mainGroupChildren);
mainGroup->AddAttribute("refType", this->CreateString("4"));
- mainGroup->AddAttribute("sourceTree", this->CreateString("\"<group>\""));
+ mainGroup->AddAttribute("sourceTree", this->CreateString("<group>"));
m_RootObject = this->CreateObject(cmXCodeObject::PBXProject);
group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 97c50af..57a9c6c 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -48,7 +48,8 @@ public:
* Try to determine system infomation such as shared library
* extension, pthreads, byte order etc.
*/
- virtual void EnableLanguage(std::vector<std::string>const& languages, cmMakefile *);
+ virtual void EnableLanguage(std::vector<std::string>const& languages,
+ cmMakefile *);
/**
* Try running cmake and building a file. This is used for dynalically
* loaded commands, not as part of the usual build process.
@@ -71,6 +72,15 @@ private:
cmXCodeObject* CreateObject(cmXCodeObject::Type type);
cmXCodeObject* CreateString(const char* s);
cmXCodeObject* CreateObjectReference(cmXCodeObject*);
+ cmXCodeObject* CreateXCodeTarget(cmTarget& target,
+ cmXCodeObject* buildPhases);
+ void CreateBuildSettings(cmTarget& target,
+ cmXCodeObject* buildSettings,
+ std::string& fileType,
+ std::string& productType,
+ std::string& projectName);
+
+ // deprecated TODO FIXME
cmXCodeObject* CreateExecutable(cmTarget& cmtarget,
cmXCodeObject* buildPhases);
cmXCodeObject* CreateStaticLibrary(cmTarget& cmtarget,
@@ -94,6 +104,7 @@ private:
std::vector<cmXCodeObject*> m_XCodeObjects;
cmXCodeObject* m_RootObject;
cmMakefile* m_CurrentMakefile;
+ cmLocalGenerator* m_CurrentLocalGenerator;
};
#endif
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 6f96149..479e3eb 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -93,12 +93,13 @@ public:
cmLocalGenerator* GetParent(){return m_Parent;}
void SetParent(cmLocalGenerator* g) { m_Parent = g;}
-protected:
void AddLanguageFlags(std::string& flags, const char* lang);
void AddSharedFlags(std::string& flags, const char* lang, bool shared);
void AddConfigVariableFlags(std::string& flags, const char* var);
void AppendFlags(std::string& flags, const char* newFlags);
+protected:
+
///! Fill out these strings for the given target. Libraries to link, flags, and linkflags.
void GetTargetFlags(std::string& linkLibs,
std::string& flags,
diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx
index b4ecee9..78006ba 100644
--- a/Source/cmXCodeObject.cxx
+++ b/Source/cmXCodeObject.cxx
@@ -77,14 +77,7 @@ void cmXCodeObject::Print(std::ostream& out)
for(j = object->m_ObjectAttributes.begin(); j != object->m_ObjectAttributes.end(); ++j)
{
cmXCodeObject::Indent(4, out);
- if(object->m_String.size() )
- {
- out << j->first << " = " << j->second->m_String << ";\n";
- }
- else
- {
- out << j->first << " = " << "\"\";\n";
- }
+ out << j->first << " = " << j->second->m_String << ";\n";
}
cmXCodeObject::Indent(3, out);
out << "};\n";
@@ -95,14 +88,7 @@ void cmXCodeObject::Print(std::ostream& out)
}
else if(object->m_Type == STRING)
{
- if(object->m_String.size() )
- {
- out << i->first << " = " << object->m_String << ";\n";
- }
- else
- {
- out << i->first << " = " << "\"\";\n";
- }
+ out << i->first << " = " << object->m_String << ";\n";
}
else
{
diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h
index a3ca650..d69d8c0 100644
--- a/Source/cmXCodeObject.h
+++ b/Source/cmXCodeObject.h
@@ -19,7 +19,9 @@ public:
cmXCodeObject(PBXType ptype, Type type);
void SetString(const char* s)
{
- m_String = s;
+ m_String = "\"";
+ m_String += s;
+ m_String += "\"";
}
void AddAttribute(const char* name, cmXCodeObject* value)