diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-07-13 14:22:10 (GMT) |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2020-07-13 15:43:17 (GMT) |
commit | f6969b917d5d74c11207b977e7a8168f24b797dc (patch) | |
tree | 9c4eb06e1b2e1dbfbe6c5f9946b37d53dcb59d8f /Source | |
parent | 46f1fa01dad3253fd7a748a765dc46b000ea67d4 (diff) | |
download | CMake-f6969b917d5d74c11207b977e7a8168f24b797dc.zip CMake-f6969b917d5d74c11207b977e7a8168f24b797dc.tar.gz CMake-f6969b917d5d74c11207b977e7a8168f24b797dc.tar.bz2 |
set_property: Deduplicate source file directory scopes
A user could specify the same directory scope to set_property()
multiple times, which in conjunction with APPEND would append the
property multiple times.
Make sure to deduplicate scopes across both DIRECTORY and
TARGET_DIRECTORY options, so that a property is only appended
once in such a scenario.
Fixes: #20941
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmSetPropertyCommand.cxx | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index 51509fd..6ca763b 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -4,6 +4,7 @@ #include <set> #include <sstream> +#include <unordered_set> #include "cmExecutionStatus.h" #include "cmGlobalGenerator.h" @@ -82,6 +83,8 @@ bool HandleSourceFileDirectoryScopes( std::vector<std::string>& source_file_target_directories, std::vector<cmMakefile*>& directory_makefiles) { + std::unordered_set<cmMakefile*> directory_makefiles_set; + cmMakefile* current_dir_mf = &status.GetMakefile(); if (!source_file_directories.empty()) { for (const std::string& dir_path : source_file_directories) { @@ -94,7 +97,11 @@ bool HandleSourceFileDirectoryScopes( status.SetError(cmStrCat("given non-existent DIRECTORY ", dir_path)); return false; } - directory_makefiles.push_back(dir_mf); + if (directory_makefiles_set.find(dir_mf) == + directory_makefiles_set.end()) { + directory_makefiles.push_back(dir_mf); + directory_makefiles_set.insert(dir_mf); + } } } @@ -110,7 +117,12 @@ bool HandleSourceFileDirectoryScopes( cmMakefile* target_dir_mf = status.GetMakefile().GetGlobalGenerator()->FindMakefile( *target_source_dir); - directory_makefiles.push_back(target_dir_mf); + + if (directory_makefiles_set.find(target_dir_mf) == + directory_makefiles_set.end()) { + directory_makefiles.push_back(target_dir_mf); + directory_makefiles_set.insert(target_dir_mf); + } } } |