diff options
author | Martin Duffy <martin.duffy@kitware.com> | 2023-09-11 13:36:12 (GMT) |
---|---|---|
committer | Martin Duffy <martin.duffy@kitware.com> | 2023-09-13 22:01:14 (GMT) |
commit | 634079b86d56e4d53240a52d80a2d3ba985ffb5f (patch) | |
tree | 790e931efd1dc5dd965bcea6309d4750250ff2a6 /Source/cmGeneratorExpressionNode.cxx | |
parent | 49e2a4a0a734f0e42e2d5717ab7c4bf4210af635 (diff) | |
download | CMake-634079b86d56e4d53240a52d80a2d3ba985ffb5f.zip CMake-634079b86d56e4d53240a52d80a2d3ba985ffb5f.tar.gz CMake-634079b86d56e4d53240a52d80a2d3ba985ffb5f.tar.bz2 |
cmGeneratorExpressionEvaluator: Short-circuit boolean operators
Diffstat (limited to 'Source/cmGeneratorExpressionNode.cxx')
-rw-r--r-- | Source/cmGeneratorExpressionNode.cxx | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 30798a3..811d53b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -128,6 +128,16 @@ struct BooleanOpNode : public cmGeneratorExpressionNode int NumExpectedParameters() const override { return OneOrMoreParameters; } + bool ShouldEvaluateNextParameter(const std::vector<std::string>& parameters, + std::string& def_value) const override + { + if (!parameters.empty() && parameters[0] == failureVal) { + def_value = failureVal; + return false; + } + return true; + } + std::string Evaluate(const std::vector<std::string>& parameters, cmGeneratorExpressionContext* context, const GeneratorExpressionContent* content, @@ -195,6 +205,13 @@ static const struct IfNode : public cmGeneratorExpressionNode int NumExpectedParameters() const override { return 3; } + bool ShouldEvaluateNextParameter(const std::vector<std::string>& parameters, + std::string&) const override + { + return (parameters.empty() || + parameters[0] != cmStrCat(parameters.size() - 1, "")); + } + std::string Evaluate(const std::vector<std::string>& parameters, cmGeneratorExpressionContext* context, const GeneratorExpressionContent* content, |