summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-04-20 18:02:48 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-04-20 18:02:48 (GMT)
commitda65528c36fd071117d4e1aa13fa1a71c09312d8 (patch)
treefbdc872db7be10d69e04483cfb80d40bb3426b80
parent73ff279d07712d6293126e7488960db054ce51be (diff)
parent6693590f8144a905b423ca03fa8ed98df4468bae (diff)
downloadCMake-da65528c36fd071117d4e1aa13fa1a71c09312d8.zip
CMake-da65528c36fd071117d4e1aa13fa1a71c09312d8.tar.gz
CMake-da65528c36fd071117d4e1aa13fa1a71c09312d8.tar.bz2
Merge topic 'stable-xcode-projects'
6693590f Xcode: Refine quoting rules for Strings a6331eb8 Xcode: Let PrintComment decide if the comment is non-empty 6e8952c1 Xcode: PrintComment will prepend a whitespace itself before the comment 4bd2544b Xcode: Do not add whitespace after attribute group opening brace 5cb4c838 Xcode: Properly indent PBXFileReference and PBXBuildFile a723427b Xcode: Remove extra space in PBXProject comment 2fe8bca5 Xcode: Add comment after root object 2e0e205e Xcode: Indent using tabs 7b68c8df Xcode: Sort Xcode objects by Id
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx21
-rw-r--r--Source/cmGlobalXCodeGenerator.h1
-rw-r--r--Source/cmXCode21Object.cxx6
-rw-r--r--Source/cmXCodeObject.cxx22
-rw-r--r--Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake4
5 files changed, 38 insertions, 16 deletions
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 7488386..8c37338 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -592,6 +592,20 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
}
//----------------------------------------------------------------------------
+
+static bool objectIdLessThan(cmXCodeObject* l, cmXCodeObject* r)
+{
+ return l->GetId() < r->GetId();
+}
+
+//----------------------------------------------------------------------------
+void cmGlobalXCodeGenerator::SortXCodeObjects()
+{
+ std::sort(this->XCodeObjects.begin(), this->XCodeObjects.end(),
+ objectIdLessThan);
+}
+
+//----------------------------------------------------------------------------
void cmGlobalXCodeGenerator::ClearXCodeObjects()
{
this->TargetDoneSet.clear();
@@ -3372,7 +3386,7 @@ bool cmGlobalXCodeGenerator
}
configlist->AddAttribute("buildConfigurations", buildConfigurations);
- std::string comment = "Build configuration list for PBXProject ";
+ std::string comment = "Build configuration list for PBXProject";
comment += " \"";
comment += this->CurrentProject;
comment += "\"";
@@ -3713,6 +3727,8 @@ cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout,
cmLocalGenerator* ,
std::vector<cmLocalGenerator*>& )
{
+ SortXCodeObjects();
+
fout << "// !$*UTF8*$!\n";
fout << "{\n";
cmXCodeObject::Indent(1, fout);
@@ -3740,7 +3756,8 @@ cmGlobalXCodeGenerator::WriteXCodePBXProj(std::ostream& fout,
cmXCodeObject::PrintList(this->XCodeObjects, fout);
}
cmXCodeObject::Indent(1, fout);
- fout << "rootObject = " << this->RootObject->GetId() << ";\n";
+ fout << "rootObject = " << this->RootObject->GetId()
+ << " /* Project object */;\n";
fout << "}\n";
}
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index b272f6a..1a69fce 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -150,6 +150,7 @@ private:
cmXCodeObject* buildSettings,
const std::string& buildType);
std::string ExtractFlag(const char* flag, std::string& flags);
+ void SortXCodeObjects();
// delete all objects in the this->XCodeObjects vector.
void ClearXCodeObjects();
bool CreateXCodeObjects(cmLocalGenerator* root,
diff --git a/Source/cmXCode21Object.cxx b/Source/cmXCode21Object.cxx
index 855e1ad..f30f700 100644
--- a/Source/cmXCode21Object.cxx
+++ b/Source/cmXCode21Object.cxx
@@ -31,7 +31,11 @@ void cmXCode21Object::PrintComment(std::ostream& out)
cmSystemTools::ReplaceString(this->Comment, "\"", "");
}
}
- out << "/* ";
+ if(this->Comment.empty())
+ {
+ return;
+ }
+ out << " /* ";
out << this->Comment;
out << " */";
}
diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx
index 5a90fd9..e72d315 100644
--- a/Source/cmXCodeObject.cxx
+++ b/Source/cmXCodeObject.cxx
@@ -81,7 +81,7 @@ void cmXCodeObject::Indent(int level, std::ostream& out)
{
while(level)
{
- out << " ";
+ out << "\t";
level--;
}
}
@@ -91,18 +91,15 @@ void cmXCodeObject::Print(std::ostream& out)
{
std::string separator = "\n";
int indentFactor = 1;
+ cmXCodeObject::Indent(2*indentFactor, out);
if(this->Version > 15
&& (this->IsA == PBXFileReference || this->IsA == PBXBuildFile))
{
separator = " ";
indentFactor = 0;
}
- cmXCodeObject::Indent(2*indentFactor, out);
- out << this->Id << " ";
- if(!(this->IsA == PBXGroup && this->Comment.size() == 0))
- {
- this->PrintComment(out);
- }
+ out << this->Id;
+ this->PrintComment(out);
out << " = {";
if(separator == "\n")
{
@@ -129,7 +126,7 @@ void cmXCodeObject::Print(std::ostream& out)
for(unsigned int k = 0; k < i->second->List.size(); k++)
{
cmXCodeObject::Indent(4*indentFactor, out);
- out << i->second->List[k]->Id << " ";
+ out << i->second->List[k]->Id;
i->second->List[k]->PrintComment(out);
out << "," << separator;
}
@@ -139,7 +136,11 @@ void cmXCodeObject::Print(std::ostream& out)
else if(object->TypeValue == ATTRIBUTE_GROUP)
{
std::map<std::string, cmXCodeObject*>::iterator j;
- out << i->first << " = {" << separator;
+ out << i->first << " = {";
+ if(separator == "\n")
+ {
+ out << separator;
+ }
for(j = object->ObjectAttributes.begin(); j !=
object->ObjectAttributes.end(); ++j)
{
@@ -188,7 +189,6 @@ void cmXCodeObject::Print(std::ostream& out)
out << " = " << object->Object->Id;
if(object->Object->HasComment() && i->first != "remoteGlobalIDString")
{
- out << " ";
object->Object->PrintComment(out);
}
out << ";" << separator;
@@ -243,7 +243,7 @@ void cmXCodeObject::PrintString(std::ostream& os,std::string String)
bool needQuote =
(String.empty() ||
String.find("//") != String.npos ||
- String.find_first_of(" <>.+-=@$[],") != String.npos);
+ String.find_first_of(" <>+-*=@[](){},") != String.npos);
const char* quote = needQuote? "\"" : "";
// Print the string, quoted and escaped as necessary.
diff --git a/Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake b/Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake
index 7882d7f..1847bc9 100644
--- a/Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake
+++ b/Tests/RunCMake/XcodeProject/XcodeFileType-check.cmake
@@ -1,6 +1,6 @@
set(expect-default "explicitFileType = sourcecode")
-set(expect-explicit "explicitFileType = \"sourcecode.c.h\"")
-set(expect-lastKnown "lastKnownFileType = \"sourcecode.c.h\"")
+set(expect-explicit "explicitFileType = sourcecode.c.h")
+set(expect-lastKnown "lastKnownFileType = sourcecode.c.h")
foreach(src default explicit lastKnown)
file(STRINGS ${RunCMake_TEST_BINARY_DIR}/XcodeFileType.xcodeproj/project.pbxproj actual-${src}
REGEX "PBXFileReference.*src-${src}")