summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-03-09 12:37:57 (GMT)
committerKitware Robot <kwrobot@kitware.com>2018-03-09 12:38:07 (GMT)
commitf8adde152f768660211e3e7e5990bc79a5de0458 (patch)
tree5e64ac2b7565d18764082a5167f22a1698c21f26 /Source
parent72abc75519e498e75f29a96577474277d4dd5da5 (diff)
parent87a6816bafdf545e81a468b393173353164039a5 (diff)
downloadCMake-f8adde152f768660211e3e7e5990bc79a5de0458.zip
CMake-f8adde152f768660211e3e7e5990bc79a5de0458.tar.gz
CMake-f8adde152f768660211e3e7e5990bc79a5de0458.tar.bz2
Merge topic 'sort_glob_output'
87a6816baf Add test for sorting and deduping of file(GLOB) result b688d4fd22 file(GLOB): Ensure entire file list is sorted Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1821
Diffstat (limited to 'Source')
-rw-r--r--Source/cmFileCommand.cxx19
1 files changed, 7 insertions, 12 deletions
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index b5215a5..90b943b 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -757,8 +757,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
}
}
- std::ostringstream outputStream;
- bool first = true;
+ std::vector<std::string> files;
bool warnFollowedSymlinks = false;
while (i != args.end()) {
if (*i == "LIST_DIRECTORIES") {
@@ -848,15 +847,8 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
warnFollowedSymlinks = true;
}
- std::vector<std::string>& files = g.GetFiles();
- std::sort(files.begin(), files.end());
- for (std::string const& file : files) {
- if (!first) {
- outputStream << ";";
- }
- outputStream << file;
- first = false;
- }
+ std::vector<std::string>& foundFiles = g.GetFiles();
+ files.insert(files.end(), foundFiles.begin(), foundFiles.end());
++i;
}
}
@@ -880,7 +872,10 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
}
break;
}
- this->Makefile->AddDefinition(variable, outputStream.str().c_str());
+
+ std::sort(files.begin(), files.end());
+ files.erase(std::unique(files.begin(), files.end()), files.end());
+ this->Makefile->AddDefinition(variable, cmJoin(files, ";").c_str());
return true;
}