diff options
author | Brad King <brad.king@kitware.com> | 2024-04-12 15:48:41 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2024-04-12 16:24:05 (GMT) |
commit | 895efd4e7a7090527c1e331ddbf1f8d3a06e5b7a (patch) | |
tree | 21fd8dc71fb9fb7070e5011dbf862c8c47cc6aa9 /Source | |
parent | 5f7d8192da570730040227a1a1122c1eeb8c125c (diff) | |
download | CMake-895efd4e7a7090527c1e331ddbf1f8d3a06e5b7a.zip CMake-895efd4e7a7090527c1e331ddbf1f8d3a06e5b7a.tar.gz CMake-895efd4e7a7090527c1e331ddbf1f8d3a06e5b7a.tar.bz2 |
cmGeneratorExpression: Consolidate recognition of transitive properties
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorExpressionDAGChecker.cxx | 24 | ||||
-rw-r--r-- | Source/cmGeneratorExpressionDAGChecker.h | 2 | ||||
-rw-r--r-- | Source/cmGeneratorExpressionNode.cxx | 6 |
3 files changed, 20 insertions, 12 deletions
diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 5343c98..fda7ec3 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -37,16 +37,19 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( , Content(content) , Backtrace(std::move(backtrace)) { - const auto* top = this->Top; - this->CheckResult = this->CheckGraph(); + if (parent) { + this->TopIsTransitiveProperty = parent->TopIsTransitiveProperty; + } else { +#define TEST_TRANSITIVE_PROPERTY_METHOD(METHOD) this->METHOD() || + this->TopIsTransitiveProperty = (CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD( + TEST_TRANSITIVE_PROPERTY_METHOD) false); // NOLINT(*) +#undef TEST_TRANSITIVE_PROPERTY_METHOD + } -#define TEST_TRANSITIVE_PROPERTY_METHOD(METHOD) top->METHOD() || + this->CheckResult = this->CheckGraph(); - if (this->CheckResult == DAG && - (CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD( - TEST_TRANSITIVE_PROPERTY_METHOD) false)) // NOLINT(*) -#undef TEST_TRANSITIVE_PROPERTY_METHOD - { + if (this->CheckResult == DAG && this->EvaluatingTransitiveProperty()) { + const auto* top = this->Top; auto it = top->Seen.find(this->Target); if (it != top->Seen.end()) { const std::set<std::string>& propSet = it->second; @@ -139,6 +142,11 @@ bool cmGeneratorExpressionDAGChecker::GetTransitivePropertiesOnlyCMP0131() return this->Top->CMP0131; } +bool cmGeneratorExpressionDAGChecker::EvaluatingTransitiveProperty() const +{ + return this->TopIsTransitiveProperty; +} + bool cmGeneratorExpressionDAGChecker::EvaluatingGenexExpression() const { // Corresponds to GenexEvaluator::EvaluateExpression. diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h index 2f88386..068ba6b 100644 --- a/Source/cmGeneratorExpressionDAGChecker.h +++ b/Source/cmGeneratorExpressionDAGChecker.h @@ -66,6 +66,7 @@ struct cmGeneratorExpressionDAGChecker void ReportError(cmGeneratorExpressionContext* context, const std::string& expr); + bool EvaluatingTransitiveProperty() const; bool EvaluatingGenexExpression() const; bool EvaluatingPICExpression() const; bool EvaluatingCompileExpression() const; @@ -109,4 +110,5 @@ private: Result CheckResult; bool TransitivePropertiesOnly = false; bool CMP0131 = false; + bool TopIsTransitiveProperty = false; }; diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 1ac658c..0df086b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -2916,10 +2916,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode return std::string(); } } else { -#define ASSERT_TRANSITIVE_PROPERTY_METHOD(METHOD) dagCheckerParent->METHOD() || - assert(CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD( - ASSERT_TRANSITIVE_PROPERTY_METHOD) false); // NOLINT(clang-tidy) -#undef ASSERT_TRANSITIVE_PROPERTY_METHOD + assert(dagCheckerParent + ->EvaluatingTransitiveProperty()); // NOLINT(clang-tidy) } } |