summaryrefslogtreecommitdiff
path: root/Source/cmParseArgumentsCommand.cxx
diff options
context:
space:
mode:
authorMatthias Maennich <matthias@maennich.net>2015-12-05 19:02:19 +0100
committerBrad King <brad.king@kitware.com>2015-12-17 10:45:19 -0500
commitab8a280857da5cf8545bd2a6f69b7378f53449a5 (patch)
tree10f014de571d24188cce4d16ef31b2b31186445d /Source/cmParseArgumentsCommand.cxx
parente8b148318f1fab26b2289cadc2d0c5e12201169d (diff)
downloadcmake-ab8a280857da5cf8545bd2a6f69b7378f53449a5.tar.gz
cmake_parse_arguments: consider duplicate keyword as warning
The behaviour of double specified keywords is rather undefined or at least not clearly documented. This change introduces a strict check and emits a warning in case a keyword has been specified more than once.
Diffstat (limited to 'Source/cmParseArgumentsCommand.cxx')
-rw-r--r--Source/cmParseArgumentsCommand.cxx16
1 files changed, 16 insertions, 0 deletions
diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx
index ce7a7b3cd0..a861965155 100644
--- a/Source/cmParseArgumentsCommand.cxx
+++ b/Source/cmParseArgumentsCommand.cxx
@@ -43,6 +43,10 @@ bool cmParseArgumentsCommand
// anything else is put into a vector of unparsed strings
std::vector<std::string> unparsed;
+ // remember already defined keywords
+ std::set<std::string> used_keywords;
+ const std::string dup_warning = "keyword defined more than once: ";
+
// the second argument is a (cmake) list of options without argument
std::vector<std::string> list;
cmSystemTools::ExpandListArgument(*argIter++, list);
@@ -50,6 +54,10 @@ bool cmParseArgumentsCommand
end = list.end();
iter != end; ++iter)
{
+ if (!used_keywords.insert(*iter).second)
+ {
+ this->GetMakefile()->IssueMessage(cmake::WARNING, dup_warning + *iter);
+ }
options[*iter]; // default initialize
}
@@ -60,6 +68,10 @@ bool cmParseArgumentsCommand
end = list.end();
iter != end; ++iter)
{
+ if (!used_keywords.insert(*iter).second)
+ {
+ this->GetMakefile()->IssueMessage(cmake::WARNING, dup_warning + *iter);
+ }
single[*iter]; // default initialize
}
@@ -70,6 +82,10 @@ bool cmParseArgumentsCommand
end = list.end();
iter != end; ++iter)
{
+ if (!used_keywords.insert(*iter).second)
+ {
+ this->GetMakefile()->IssueMessage(cmake::WARNING, dup_warning + *iter);
+ }
multi[*iter]; // default initialize
}