summaryrefslogtreecommitdiffstats
path: root/Source/cmFileCommand.cxx
diff options
context:
space:
mode:
authorShane Parris <shane.lee.parris@gmail.com>2018-03-05 19:31:16 (GMT)
committerShane Parris <shane.lee.parris@gmail.com>2018-03-07 17:12:19 (GMT)
commitb688d4fd22850c287f191f142660781ded72e919 (patch)
tree936f4cb057c577ea0a089439721e890b921010fc /Source/cmFileCommand.cxx
parent49e777aeb1dbb141383faf1e5cb20c7443952302 (diff)
downloadCMake-b688d4fd22850c287f191f142660781ded72e919.zip
CMake-b688d4fd22850c287f191f142660781ded72e919.tar.gz
CMake-b688d4fd22850c287f191f142660781ded72e919.tar.bz2
file(GLOB): Ensure entire file list is sorted
Diffstat (limited to 'Source/cmFileCommand.cxx')
-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;
}