diff options
author | Brad King <brad.king@kitware.com> | 2019-04-04 15:27:18 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-04-04 15:27:28 (GMT) |
commit | a63a50c77af65092d82b9c3a6de3ea34c63605d4 (patch) | |
tree | 2edcd8c11d855af2578bffca1efe3a1505688307 /Source | |
parent | 3d6d7c170ca9ad291a0deedd125b8f9ce82d15bb (diff) | |
parent | abbb8a7b1d40b98fb1841a76efb676eea7771cf0 (diff) | |
download | CMake-a63a50c77af65092d82b9c3a6de3ea34c63605d4.zip CMake-a63a50c77af65092d82b9c3a6de3ea34c63605d4.tar.gz CMake-a63a50c77af65092d82b9c3a6de3ea34c63605d4.tar.bz2 |
Merge topic 'remove_duplicates'
abbb8a7b1d Genex: Add $<REMOVE_DUPLICATES:list>
11338389e5 Help: Fix description in cmake-generator-expressions(7) manual
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3154
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorExpressionNode.cxx | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 50413c8..19d2b3a 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -15,6 +15,7 @@ #include "cmMessageType.h" #include "cmOutputConverter.h" #include "cmPolicies.h" +#include "cmRange.h" #include "cmState.h" #include "cmStateSnapshot.h" #include "cmStateTypes.h" @@ -326,6 +327,34 @@ static const struct InListNode : public cmGeneratorExpressionNode } } inListNode; +static const struct RemoveDuplicatesNode : public cmGeneratorExpressionNode +{ + RemoveDuplicatesNode() {} // NOLINT(modernize-use-equals-default) + + int NumExpectedParameters() const override { return 1; } + + std::string Evaluate( + const std::vector<std::string>& parameters, + cmGeneratorExpressionContext* context, + const GeneratorExpressionContent* content, + cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override + { + if (parameters.size() != 1) { + reportError( + context, content->GetOriginalExpression(), + "$<REMOVE_DUPLICATES:...> expression requires one parameter"); + } + + std::vector<std::string> values; + cmSystemTools::ExpandListArgument(parameters.front(), values, true); + + auto valuesEnd = cmRemoveDuplicates(values); + auto valuesBegin = values.cbegin(); + return cmJoin(cmMakeRange(valuesBegin, valuesEnd), ";"); + } + +} removeDuplicatesNode; + static const struct TargetExistsNode : public cmGeneratorExpressionNode { TargetExistsNode() {} // NOLINT(modernize-use-equals-default) @@ -2158,6 +2187,7 @@ const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode( { "STREQUAL", &strEqualNode }, { "EQUAL", &equalNode }, { "IN_LIST", &inListNode }, + { "REMOVE_DUPLICATES", &removeDuplicatesNode }, { "LOWER_CASE", &lowerCaseNode }, { "UPPER_CASE", &upperCaseNode }, { "MAKE_C_IDENTIFIER", &makeCIdentifierNode }, |