diff options
Diffstat (limited to 'Source/cmGeneratorExpressionDAGChecker.cxx')
-rw-r--r-- | Source/cmGeneratorExpressionDAGChecker.cxx | 83 |
1 files changed, 41 insertions, 42 deletions
diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 643ba34..4f379cd 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -6,6 +6,9 @@ #include <sstream> #include <utility> +#include <cm/string_view> +#include <cmext/string_view> + #include "cmGeneratorExpressionContext.h" #include "cmGeneratorExpressionEvaluator.h" #include "cmGeneratorTarget.h" @@ -44,12 +47,7 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker( void cmGeneratorExpressionDAGChecker::Initialize() { - const cmGeneratorExpressionDAGChecker* top = this; - const cmGeneratorExpressionDAGChecker* p = this->Parent; - while (p) { - top = p; - p = p->Parent; - } + const auto* top = this->Top(); this->CheckResult = this->CheckGraph(); #define TEST_TRANSITIVE_PROPERTY_METHOD(METHOD) top->METHOD() || @@ -140,61 +138,57 @@ cmGeneratorExpressionDAGChecker::CheckGraph() const return DAG; } -bool cmGeneratorExpressionDAGChecker::GetTransitivePropertiesOnly() +bool cmGeneratorExpressionDAGChecker::GetTransitivePropertiesOnly() const { - const cmGeneratorExpressionDAGChecker* top = this; - const cmGeneratorExpressionDAGChecker* parent = this->Parent; - while (parent) { - top = parent; - parent = parent->Parent; - } + return this->Top()->TransitivePropertiesOnly; +} - return top->TransitivePropertiesOnly; +bool cmGeneratorExpressionDAGChecker::EvaluatingGenexExpression() const +{ + return cmHasLiteralPrefix(this->Property, "TARGET_GENEX_EVAL:") || + cmHasLiteralPrefix(this->Property, "GENEX_EVAL:"); } -bool cmGeneratorExpressionDAGChecker::EvaluatingGenexExpression() +bool cmGeneratorExpressionDAGChecker::EvaluatingPICExpression() const { - return this->Property.find("TARGET_GENEX_EVAL:") == 0 || - this->Property.find("GENEX_EVAL:", 0) == 0; + return this->Top()->Property == "INTERFACE_POSITION_INDEPENDENT_CODE"; } -bool cmGeneratorExpressionDAGChecker::EvaluatingPICExpression() +bool cmGeneratorExpressionDAGChecker::EvaluatingLinkExpression() const { - const cmGeneratorExpressionDAGChecker* top = this; - const cmGeneratorExpressionDAGChecker* parent = this->Parent; - while (parent) { - top = parent; - parent = parent->Parent; - } + cm::string_view property(this->Top()->Property); + + return property == "LINK_DIRECTORIES"_s || property == "LINK_OPTIONS"_s || + property == "LINK_DEPENDS"_s; +} + +bool cmGeneratorExpressionDAGChecker::EvaluatingLinkOptionsExpression() const +{ + cm::string_view property(this->Top()->Property); - return top->Property == "INTERFACE_POSITION_INDEPENDENT_CODE"; + return property == "LINK_OPTIONS"_s; } bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries( - cmGeneratorTarget const* tgt) + cmGeneratorTarget const* tgt) const { - const cmGeneratorExpressionDAGChecker* top = this; - const cmGeneratorExpressionDAGChecker* parent = this->Parent; - while (parent) { - top = parent; - parent = parent->Parent; - } + const auto* top = this->Top(); - const char* prop = top->Property.c_str(); + cm::string_view prop(top->Property); if (tgt) { - return top->Target == tgt && strcmp(prop, "LINK_LIBRARIES") == 0; + return top->Target == tgt && prop == "LINK_LIBRARIES"_s; } - return (strcmp(prop, "LINK_LIBRARIES") == 0 || - strcmp(prop, "LINK_INTERFACE_LIBRARIES") == 0 || - strcmp(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES") == 0 || - cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES_") || - cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES_")) || - strcmp(prop, "INTERFACE_LINK_LIBRARIES") == 0; + return prop == "LINK_LIBRARIES"_s || prop == "LINK_INTERFACE_LIBRARIES"_s || + prop == "IMPORTED_LINK_INTERFACE_LIBRARIES"_s || + cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES_") || + cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES_") || + prop == "INTERFACE_LINK_LIBRARIES"_s; } -cmGeneratorTarget const* cmGeneratorExpressionDAGChecker::TopTarget() const +cmGeneratorExpressionDAGChecker const* cmGeneratorExpressionDAGChecker::Top() + const { const cmGeneratorExpressionDAGChecker* top = this; const cmGeneratorExpressionDAGChecker* parent = this->Parent; @@ -202,7 +196,12 @@ cmGeneratorTarget const* cmGeneratorExpressionDAGChecker::TopTarget() const top = parent; parent = parent->Parent; } - return top->Target; + return top; +} + +cmGeneratorTarget const* cmGeneratorExpressionDAGChecker::TopTarget() const +{ + return this->Top()->Target; } enum TransitiveProperty |