summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-11-20 14:41:03 (GMT)
committerKitware Robot <kwrobot@kitware.com>2017-11-20 14:41:09 (GMT)
commit521cb89e0254323bf29395ce6bdefd6a112a009d (patch)
tree76839c5de6ed6b3ec87692ea37ac1988bdc8f26e
parenta4fd74b90a91396f316990ba056c7c6bd6034b94 (diff)
parentf26009dde6b152f1d32e676202c8982ec409938a (diff)
downloadCMake-521cb89e0254323bf29395ce6bdefd6a112a009d.zip
CMake-521cb89e0254323bf29395ce6bdefd6a112a009d.tar.gz
CMake-521cb89e0254323bf29395ce6bdefd6a112a009d.tar.bz2
Merge topic 'vs-source-group-order'
f26009dd VS: Order .vcxproj.filters files deterministically c871446a cmSourceGroup: Return strings from GetName and GetFullName Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1484
-rw-r--r--Source/cmGhsMultiTargetGenerator.cxx4
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx4
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx2
-rw-r--r--Source/cmMakefile.cxx5
-rw-r--r--Source/cmSourceGroup.cxx10
-rw-r--r--Source/cmSourceGroup.h4
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx17
7 files changed, 25 insertions, 21 deletions
diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx
index a31e415..b3e3393 100644
--- a/Source/cmGhsMultiTargetGenerator.cxx
+++ b/Source/cmGhsMultiTargetGenerator.cxx
@@ -489,7 +489,7 @@ void cmGhsMultiTargetGenerator::WriteSources(
char const* sourceFullPath = (*si)->GetFullPath().c_str();
cmSourceGroup* sourceGroup =
this->Makefile->FindSourceGroup(sourceFullPath, sourceGroups);
- std::string sgPath(sourceGroup->GetFullName());
+ std::string sgPath = sourceGroup->GetFullName();
cmSystemTools::ConvertToUnixSlashes(sgPath);
cmGlobalGhsMultiGenerator::AddFilesUpToPath(
this->GetFolderBuildStreams(), &this->FolderBuildStreams,
@@ -608,7 +608,7 @@ std::string cmGhsMultiTargetGenerator::ComputeLongestObjectDirectory(
cmSourceGroup* sourceGroup =
localGhsMultiGenerator->GetMakefile()->FindSourceGroup(sourceFullPath,
sourceGroups);
- std::string const sgPath(sourceGroup->GetFullName());
+ std::string const& sgPath = sourceGroup->GetFullName();
dir_max += sgPath;
dir_max += "/Objs/libs/";
dir_max += generatorTarget->Target->GetName();
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index dfc1bed..41fe5d2 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -2797,13 +2797,13 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateOrGetPBXGroup(
// If it's the default source group (empty name) then put the source file
// directly in the tgroup...
//
- if (std::string(sg->GetFullName()).empty()) {
+ if (sg->GetFullName().empty()) {
this->GroupNameMap[s] = tgroup;
return tgroup;
}
// It's a recursive folder structure, let's find the real parent group
- if (std::string(sg->GetFullName()) != std::string(sg->GetName())) {
+ if (sg->GetFullName() != sg->GetName()) {
std::string curr_folder = target;
curr_folder += "/";
for (auto const& folder :
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index beb80f2..f01ed7a 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1600,7 +1600,7 @@ bool cmLocalVisualStudio7Generator::WriteGroup(
}
// If the group has a name, write the header.
- std::string name = sg->GetName();
+ std::string const& name = sg->GetName();
if (!name.empty()) {
this->WriteVCProjBeginGroup(fout, name.c_str(), "");
}
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 4109b90..5a11a90 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1950,7 +1950,7 @@ cmSourceGroup* cmMakefile::GetSourceGroup(
// first look for source group starting with the same as the one we want
for (cmSourceGroup const& srcGroup : this->SourceGroups) {
- std::string sgName = srcGroup.GetName();
+ std::string const& sgName = srcGroup.GetName();
if (sgName == name[0]) {
sg = const_cast<cmSourceGroup*>(&srcGroup);
break;
@@ -2014,7 +2014,8 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
}
// build the whole source group path
for (++i; i <= lastElement; ++i) {
- sg->AddChild(cmSourceGroup(name[i].c_str(), nullptr, sg->GetFullName()));
+ sg->AddChild(
+ cmSourceGroup(name[i].c_str(), nullptr, sg->GetFullName().c_str()));
sg = sg->LookupChild(name[i].c_str());
}
diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx
index fba4c31..18bcb49 100644
--- a/Source/cmSourceGroup.cxx
+++ b/Source/cmSourceGroup.cxx
@@ -60,14 +60,14 @@ void cmSourceGroup::AddGroupFile(const std::string& name)
this->GroupFiles.insert(name);
}
-const char* cmSourceGroup::GetName() const
+std::string const& cmSourceGroup::GetName() const
{
- return this->Name.c_str();
+ return this->Name;
}
-const char* cmSourceGroup::GetFullName() const
+std::string const& cmSourceGroup::GetFullName() const
{
- return this->FullName.c_str();
+ return this->FullName;
}
bool cmSourceGroup::MatchesRegex(const char* name)
@@ -105,7 +105,7 @@ cmSourceGroup* cmSourceGroup::LookupChild(const char* name) const
// st
for (; iter != end; ++iter) {
- std::string sgName = iter->GetName();
+ std::string const& sgName = iter->GetName();
// look if descenened is the one were looking for
if (sgName == name) {
diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h
index e8bd697..7c7c35f 100644
--- a/Source/cmSourceGroup.h
+++ b/Source/cmSourceGroup.h
@@ -55,12 +55,12 @@ public:
/**
* Get the name of this group.
*/
- const char* GetName() const;
+ std::string const& GetName() const;
/**
* Get the full path name for group.
*/
- const char* GetFullName() const;
+ std::string const& GetFullName() const;
/**
* Check if the given name matches this group's regex.
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 6486c8b..caeeeb9 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1469,11 +1469,14 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
}
this->WriteString("<ItemGroup>\n", 1);
- for (std::set<cmSourceGroup*>::iterator g = groupsUsed.begin();
- g != groupsUsed.end(); ++g) {
- cmSourceGroup* sg = *g;
- const char* name = sg->GetFullName();
- if (strlen(name) != 0) {
+ std::vector<cmSourceGroup*> groupsVec(groupsUsed.begin(), groupsUsed.end());
+ std::sort(groupsVec.begin(), groupsVec.end(),
+ [](cmSourceGroup* l, cmSourceGroup* r) {
+ return l->GetFullName() < r->GetFullName();
+ });
+ for (cmSourceGroup* sg : groupsVec) {
+ std::string const& name = sg->GetFullName();
+ if (!name.empty()) {
this->WriteString("<Filter Include=\"", 2);
(*this->BuildFileStream) << name << "\">\n";
std::string guidName = "SG_Filter_";
@@ -1558,12 +1561,12 @@ void cmVisualStudio10TargetGenerator::WriteGroupSources(
std::string const& source = sf->GetFullPath();
cmSourceGroup* sourceGroup =
this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
- const char* filter = sourceGroup->GetFullName();
+ std::string const& filter = sourceGroup->GetFullName();
this->WriteString("<", 2);
std::string path = this->ConvertPath(source, s->RelativePath);
this->ConvertToWindowsSlash(path);
(*this->BuildFileStream) << name << " Include=\"" << cmVS10EscapeXML(path);
- if (strlen(filter)) {
+ if (!filter.empty()) {
(*this->BuildFileStream) << "\">\n";
this->WriteString("<Filter>", 3);
(*this->BuildFileStream) << filter << "</Filter>\n";