Attached Files | cmake-xcode-3.patch [^] (10,739 bytes) 2009-06-29 00:38 [Show Content] [Hide Content]Index: Source/cmGlobalXCode21Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalXCode21Generator.cxx,v
retrieving revision 1.7
diff -u -p -r1.7 cmGlobalXCode21Generator.cxx
--- Source/cmGlobalXCode21Generator.cxx 14 Aug 2007 15:45:14 -0000 1.7
+++ Source/cmGlobalXCode21Generator.cxx 29 Jun 2009 04:24:28 -0000
@@ -38,7 +38,12 @@ cmGlobalXCode21Generator::WriteXCodePBXP
cmXCode21Object::Indent(1, fout);
fout << "};\n";
cmXCode21Object::Indent(1, fout);
- fout << "objectVersion = 42;\n";
+ if (this->XcodeVersion >= 31)
+ fout << "objectVersion = 45;\n";
+ else if (this->XcodeVersion >= 30)
+ fout << "objectVersion = 44;\n";
+ else
+ fout << "objectVersion = 42;\n";
cmXCode21Object::PrintList(this->XCodeObjects, fout);
cmXCode21Object::Indent(1, fout);
fout << "rootObject = " << this->RootObject->GetId()
Index: Source/cmGlobalXCodeGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.cxx,v
retrieving revision 1.210
diff -u -p -r1.210 cmGlobalXCodeGenerator.cxx
--- Source/cmGlobalXCodeGenerator.cxx 16 Mar 2009 18:30:24 -0000 1.210
+++ Source/cmGlobalXCodeGenerator.cxx 29 Jun 2009 04:24:29 -0000
@@ -451,6 +451,55 @@ cmStdString GetGroupMapKey(cmTarget& cmt
return key;
}
+// Builds either an object list or a space-separated string from the
+// given inputs.
+class cmGlobalXCodeGenerator::BuildObjectListOrString {
+ cmGlobalXCodeGenerator *Generator;
+ cmXCodeObject *Group;
+ bool Empty;
+ std::string String;
+
+public:
+ BuildObjectListOrString(cmGlobalXCodeGenerator *Gen, bool BuildObjectList)
+ : Generator(Gen), Group(0), Empty(true)
+ {
+ if (BuildObjectList)
+ {
+ this->Group = this->Generator->CreateObject(cmXCodeObject::OBJECT_LIST);
+ }
+ }
+
+ bool IsEmpty() const { return Empty; }
+
+ void Add(const char *NewString)
+ {
+ Empty = false;
+
+ if (this->Group)
+ {
+ this->Group->AddObject(this->Generator->CreateString(NewString));
+ }
+ else
+ {
+ this->String += NewString;
+ this->String += ' ';
+ }
+ }
+
+ const std::string &GetString() const { return this->String; }
+
+ cmXCodeObject *CreateList() {
+ if (this->Group)
+ {
+ return this->Group;
+ }
+ else
+ {
+ return this->Generator->CreateString(this->String.c_str());
+ }
+ }
+};
+
//----------------------------------------------------------------------------
cmXCodeObject*
cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
@@ -466,7 +515,16 @@ cmGlobalXCodeGenerator::CreateXCodeSourc
lg->AppendFlags(flags, sf->GetProperty("COMPILE_FLAGS"));
// Add per-source definitions.
- this->AppendDefines(flags, sf->GetProperty("COMPILE_DEFINITIONS"), true);
+ BuildObjectListOrString flagsBuild(this, false);
+ this->AppendDefines(flagsBuild, sf->GetProperty("COMPILE_DEFINITIONS"), true);
+ if (!flagsBuild.IsEmpty())
+ {
+ if (flags.size())
+ {
+ flags += ' ';
+ }
+ flags += flagsBuild.GetString();
+ }
// Using a map and the full path guarantees that we will always get the same
// fileRef object for any given full path.
@@ -1348,7 +1406,7 @@ void cmGlobalXCodeGenerator::CreateBuild
this->CurrentMakefile->GetDefineFlags());
// Add preprocessor definitions for this target and configuration.
- std::string ppDefs;
+ BuildObjectListOrString ppDefs(this, this->XcodeVersion >= 30);
if(this->XcodeVersion > 15)
{
this->AppendDefines(ppDefs, "CMAKE_INTDIR=\"$(CONFIGURATION)\"");
@@ -1370,7 +1428,7 @@ void cmGlobalXCodeGenerator::CreateBuild
this->AppendDefines(ppDefs, target.GetProperty(defVarName.c_str()));
}
buildSettings->AddAttribute
- ("GCC_PREPROCESSOR_DEFINITIONS", this->CreateString(ppDefs.c_str()));
+ ("GCC_PREPROCESSOR_DEFINITIONS", ppDefs.CreateList());
std::string extraLinkOptions;
if(target.GetType() == cmTarget::EXECUTABLE)
@@ -1563,10 +1621,11 @@ void cmGlobalXCodeGenerator::CreateBuild
buildSettings->AddAttribute("PREBINDING",
this->CreateString("NO"));
}
- std::string dirs;
+
+ BuildObjectListOrString dirs(this, this->XcodeVersion >= 30);
+ BuildObjectListOrString fdirs(this, this->XcodeVersion >= 30);
std::vector<std::string> includes;
this->CurrentLocalGenerator->GetIncludeDirectories(includes);
- std::string fdirs;
std::set<cmStdString> emitted;
emitted.insert("/System/Library/Frameworks");
for(std::vector<std::string>::iterator i = includes.begin();
@@ -1579,15 +1638,14 @@ void cmGlobalXCodeGenerator::CreateBuild
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str());
if(emitted.insert(frameworkDir).second)
{
- fdirs += this->XCodeEscapePath(frameworkDir.c_str());
- fdirs += " ";
+ fdirs.Add(this->XCodeEscapePath(frameworkDir.c_str()).c_str());
}
}
else
{
std::string incpath =
this->XCodeEscapePath(i->c_str());
- dirs += incpath + " ";
+ dirs.Add(incpath.c_str());
}
}
std::vector<std::string>& frameworks = target.GetFrameworks();
@@ -1598,20 +1656,19 @@ void cmGlobalXCodeGenerator::CreateBuild
{
if(emitted.insert(*fmIt).second)
{
- fdirs += this->XCodeEscapePath(fmIt->c_str());
- fdirs += " ";
+ fdirs.Add(this->XCodeEscapePath(fmIt->c_str()).c_str());
}
}
}
- if(fdirs.size())
+ if(!fdirs.IsEmpty())
{
buildSettings->AddAttribute("FRAMEWORK_SEARCH_PATHS",
- this->CreateString(fdirs.c_str()));
+ fdirs.CreateList());
}
- if(dirs.size())
+ if(!dirs.IsEmpty())
{
buildSettings->AddAttribute("HEADER_SEARCH_PATHS",
- this->CreateString(dirs.c_str()));
+ dirs.CreateList());
}
std::string oflagc = this->ExtractFlag("-O", cflags);
char optLevel[2];
@@ -1714,10 +1771,21 @@ void cmGlobalXCodeGenerator::CreateBuild
this->CreateString(""));
buildSettings->AddAttribute("USE_HEADERMAP",
this->CreateString("NO"));
- buildSettings->AddAttribute("WARNING_CFLAGS",
- this->CreateString(
- "-Wmost -Wno-four-char-constants"
- " -Wno-unknown-pragmas"));
+ if (this->XcodeVersion >= 30)
+ {
+ cmXCodeObject *group = this->CreateObject(cmXCodeObject::OBJECT_LIST);
+ group->AddObject(this->CreateString("-Wmost"));
+ group->AddObject(this->CreateString("-Wno-four-char-constants"));
+ group->AddObject(this->CreateString("-Wno-unknown-pragmas"));
+ buildSettings->AddAttribute("WARNING_CFLAGS", group);
+ }
+ else
+ {
+ buildSettings->AddAttribute("WARNING_CFLAGS",
+ this->CreateString(
+ "-Wmost -Wno-four-char-constants"
+ " -Wno-unknown-pragmas"));
+ }
// Runtime version information.
if(target.GetType() == cmTarget::SHARED_LIBRARY)
@@ -2432,6 +2500,19 @@ void cmGlobalXCodeGenerator
this->RootObject->AddAttribute("buildStyles", listObjs);
this->RootObject->AddAttribute("hasScannedForEncodings",
this->CreateString("0"));
+ if (this->XcodeVersion >= 30) {
+ group = this->CreateObject(cmXCodeObject::ATTRIBUTE_GROUP);
+ group->AddAttribute("BuildIndependentTargetsInParallel",
+ this->CreateString("YES"));
+ this->RootObject->AddAttribute("attributes", group);
+ if (this->XcodeVersion >= 31)
+ this->RootObject->AddAttribute("compatibilityVersion",
+ this->CreateString("Xcode 3.1"));
+ else
+ this->RootObject->AddAttribute("compatibilityVersion",
+ this->CreateString("Xcode 3.0"));
+ this->RootObject->AddAttribute("projectDirPath", this->CreateString(""));
+ }
// Point Xcode at the top of the source tree.
{
std::string proot = root->GetMakefile()->GetCurrentDirectory();
@@ -2946,7 +3027,7 @@ std::string cmGlobalXCodeGenerator::Look
}
//----------------------------------------------------------------------------
-void cmGlobalXCodeGenerator::AppendDefines(std::string& defs,
+void cmGlobalXCodeGenerator::AppendDefines(BuildObjectListOrString& defs,
const char* defines_list,
bool dflag)
{
@@ -2967,21 +3048,18 @@ void cmGlobalXCodeGenerator::AppendDefin
// - Escape a backslash as \\\\ since it itself is an escape
// Note that in the code below we need one more level of escapes for
// C string syntax in this source file.
- const char* sep = defs.empty()? "" : " ";
for(std::vector<std::string>::const_iterator di = defines.begin();
di != defines.end(); ++di)
{
- // Separate from previous definition.
- defs += sep;
- sep = " ";
+ std::string def;
// Open single quote.
- defs += "'";
+ def += "'";
// Add -D flag if requested.
if(dflag)
{
- defs += "-D";
+ def += "-D";
}
// Escaped definition string.
@@ -2989,20 +3067,22 @@ void cmGlobalXCodeGenerator::AppendDefin
{
if(*c == '\'')
{
- defs += "\\\\'";
+ def += "\\\\'";
}
else if(*c == '\\')
{
- defs += "\\\\\\\\";
+ def += "\\\\\\\\";
}
else
{
- defs += *c;
+ def += *c;
}
}
// Close single quote.
- defs += "'";
+ def += "'";
+
+ defs.Add(def.c_str());
}
}
Index: Source/cmGlobalXCodeGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalXCodeGenerator.h,v
retrieving revision 1.56
diff -u -p -r1.56 cmGlobalXCodeGenerator.h
--- Source/cmGlobalXCodeGenerator.h 16 Mar 2009 18:30:24 -0000 1.56
+++ Source/cmGlobalXCodeGenerator.h 29 Jun 2009 04:24:29 -0000
@@ -178,7 +178,10 @@ private:
const char* varNameSuffix,
const char* default_flags);
- void AppendDefines(std::string& defs, const char* defines_list,
+ class BuildObjectListOrString;
+ friend class BuildObjectListOrString;
+
+ void AppendDefines(BuildObjectListOrString& defs, const char* defines_list,
bool dflag = false);
protected:
|