diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2019-05-30 14:00:19 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-06-03 14:20:23 (GMT) |
commit | 808b8180632aef06e7a3644fb4d3957722abc3f3 (patch) | |
tree | 5379256750380540b9a09e62d5e6ae0070b9787b /Source | |
parent | 9fd602bfd33479b1acecd40e5c1b76ce37d59798 (diff) | |
download | CMake-808b8180632aef06e7a3644fb4d3957722abc3f3.zip CMake-808b8180632aef06e7a3644fb4d3957722abc3f3.tar.gz CMake-808b8180632aef06e7a3644fb4d3957722abc3f3.tar.bz2 |
Genex: CompileLang and CompileLangAndId now match against a list of ids
This allows for expressions such as:
$<COMPILE_LANG_AND_ID, CXX, GNU, Clang>
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorExpressionNode.cxx | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 4744309..a60c75c 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -951,7 +951,7 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode { CompileLanguageNode() {} // NOLINT(modernize-use-equals-default) - int NumExpectedParameters() const override { return OneOrZeroParameters; } + int NumExpectedParameters() const override { return ZeroOrMoreParameters; } std::string Evaluate( const std::vector<std::string>& parameters, @@ -982,7 +982,13 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode if (parameters.empty()) { return context->Language; } - return context->Language == parameters.front() ? "1" : "0"; + + for (auto& param : parameters) { + if (context->Language == param) { + return "1"; + } + } + return "0"; } } languageNode; @@ -990,7 +996,7 @@ static const struct CompileLanguageAndIdNode : public cmGeneratorExpressionNode { CompileLanguageAndIdNode() {} // NOLINT(modernize-use-equals-default) - int NumExpectedParameters() const override { return 2; } + int NumExpectedParameters() const override { return TwoOrMoreParameters; } std::string Evaluate( const std::vector<std::string>& parameters, @@ -1023,7 +1029,8 @@ static const struct CompileLanguageAndIdNode : public cmGeneratorExpressionNode const std::string& lang = context->Language; if (lang == parameters.front()) { - std::vector<std::string> idParameter = { parameters[1] }; + std::vector<std::string> idParameter((parameters.cbegin() + 1), + parameters.cend()); return CompilerIdNode{ lang.c_str() }.EvaluateWithLanguage( idParameter, context, content, dagChecker, lang); } |