summaryrefslogtreecommitdiffstats
path: root/Source/cmSourceGroupCommand.cxx
diff options
context:
space:
mode:
authorMateusz Janek <stryku2393@gmail.com>2019-11-02 17:16:58 (GMT)
committerBrad King <brad.king@kitware.com>2019-11-04 18:37:41 (GMT)
commit3c0ca5a9d9d538da41e99207da22f55496bdf553 (patch)
tree070018b22bc79c60a274c6e454cee6637a5e6a29 /Source/cmSourceGroupCommand.cxx
parentc1d5d5eb11e0260ffadda0851ac844ab46b6b179 (diff)
downloadCMake-3c0ca5a9d9d538da41e99207da22f55496bdf553.zip
CMake-3c0ca5a9d9d538da41e99207da22f55496bdf553.tar.gz
CMake-3c0ca5a9d9d538da41e99207da22f55496bdf553.tar.bz2
source_group: ensure that passed file is not a directory
Fixes: #19769
Diffstat (limited to 'Source/cmSourceGroupCommand.cxx')
-rw-r--r--Source/cmSourceGroupCommand.cxx14
1 files changed, 11 insertions, 3 deletions
diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx
index 3a13e57..cc62952 100644
--- a/Source/cmSourceGroupCommand.cxx
+++ b/Source/cmSourceGroupCommand.cxx
@@ -78,10 +78,18 @@ std::vector<std::string> prepareFilesPathsForTree(
for (auto const& filePath : filesPaths) {
std::string fullPath =
cmSystemTools::CollapseFullPath(filePath, currentSourceDir);
- // If provided file path is actually not a file, silently ignore it.
- if (cmSystemTools::FileExists(fullPath, /*isFile=*/true)) {
- prepared.emplace_back(std::move(fullPath));
+ // If provided file path is actually not a directory, silently ignore it.
+ if (cmSystemTools::FileIsDirectory(fullPath)) {
+ continue;
}
+
+ // Handle directory that doesn't exist yet.
+ if (!fullPath.empty() &&
+ (fullPath.back() == '/' || fullPath.back() == '\\')) {
+ continue;
+ }
+
+ prepared.emplace_back(std::move(fullPath));
}
return prepared;