mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-15 20:46:37 +08:00
source_group command ensures that FILES arguments are actually files
This commit is contained in:
@@ -80,8 +80,11 @@ std::vector<std::string> prepareFilesPathsForTree(
|
|||||||
prepared.reserve(filesPaths.size());
|
prepared.reserve(filesPaths.size());
|
||||||
|
|
||||||
for (auto const& filePath : filesPaths) {
|
for (auto const& filePath : filesPaths) {
|
||||||
|
// If provided file path is actually not a file, silently ignore it.
|
||||||
|
if (cmSystemTools::FileExists(filePath, /*isFile=*/true)) {
|
||||||
prepared.push_back(prepareFilePathForTree(filePath, currentSourceDir));
|
prepared.push_back(prepareFilePathForTree(filePath, currentSourceDir));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return prepared;
|
return prepared;
|
||||||
}
|
}
|
||||||
|
@@ -42,8 +42,16 @@ set(tree_files_with_prefix ${root}/tree_prefix_foo.c
|
|||||||
set(tree_files_with_empty_prefix ${root}/tree_empty_prefix_foo.c
|
set(tree_files_with_empty_prefix ${root}/tree_empty_prefix_foo.c
|
||||||
tree_empty_prefix_bar.c)
|
tree_empty_prefix_bar.c)
|
||||||
|
|
||||||
|
set(tree_files_which_are_actually_directories ${root}
|
||||||
|
${root}/
|
||||||
|
${root}/sub1
|
||||||
|
${root}/sub1/)
|
||||||
|
|
||||||
source_group(TREE ${root} FILES ${tree_files_without_prefix})
|
source_group(TREE ${root} FILES ${tree_files_without_prefix})
|
||||||
|
|
||||||
|
# Should not crash and not add any files - just silently ignore the directories
|
||||||
|
source_group(TREE ${root} FILES ${tree_files_which_are_actually_directories})
|
||||||
|
|
||||||
source_group(FILES ${tree_files_with_prefix} PREFIX tree_root/subgroup TREE ${root})
|
source_group(FILES ${tree_files_with_prefix} PREFIX tree_root/subgroup TREE ${root})
|
||||||
|
|
||||||
source_group(PREFIX "" FILES ${tree_files_with_empty_prefix} TREE ${root})
|
source_group(PREFIX "" FILES ${tree_files_with_empty_prefix} TREE ${root})
|
||||||
|
Reference in New Issue
Block a user