cmGeneratorExpressionDAGChecker: Simplify finding evaluation graph root

This commit is contained in:
Brad King committed 2024-04-09 11:27:16 -04:00
1 parent 304f4c261e
commit 50840902ce
2 files changed
+12 -23

No files matched your search

+11 -22
View File
@@ -31,12 +31,13 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker(
std::string property, const GeneratorExpressionContent* content, std::string property, const GeneratorExpressionContent* content,
cmGeneratorExpressionDAGChecker* parent) cmGeneratorExpressionDAGChecker* parent)
: Parent(parent) : Parent(parent)
, Top(parent ? parent->Top : this)
, Target(target) , Target(target)
, Property(std::move(property)) , Property(std::move(property))
, Content(content) , Content(content)
, Backtrace(std::move(backtrace)) , Backtrace(std::move(backtrace))
{ {
const auto* top = this->Top(); const auto* top = this->Top;
this->CheckResult = this->CheckGraph(); this->CheckResult = this->CheckGraph();
#define TEST_TRANSITIVE_PROPERTY_METHOD(METHOD) top->METHOD() || #define TEST_TRANSITIVE_PROPERTY_METHOD(METHOD) top->METHOD() ||
@@ -129,13 +130,13 @@ cmGeneratorExpressionDAGChecker::CheckGraph() const
bool cmGeneratorExpressionDAGChecker::GetTransitivePropertiesOnly() const bool cmGeneratorExpressionDAGChecker::GetTransitivePropertiesOnly() const
{ {
return this->Top()->TransitivePropertiesOnly; return this->Top->TransitivePropertiesOnly;
} }
bool cmGeneratorExpressionDAGChecker::GetTransitivePropertiesOnlyCMP0131() bool cmGeneratorExpressionDAGChecker::GetTransitivePropertiesOnlyCMP0131()
const const
{ {
return this->Top()->CMP0131; return this->Top->CMP0131;
} }
bool cmGeneratorExpressionDAGChecker::EvaluatingGenexExpression() const bool cmGeneratorExpressionDAGChecker::EvaluatingGenexExpression() const
@@ -146,12 +147,12 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingGenexExpression() const
bool cmGeneratorExpressionDAGChecker::EvaluatingPICExpression() const bool cmGeneratorExpressionDAGChecker::EvaluatingPICExpression() const
{ {
return this->Top()->Property == "INTERFACE_POSITION_INDEPENDENT_CODE"; return this->Top->Property == "INTERFACE_POSITION_INDEPENDENT_CODE";
} }
bool cmGeneratorExpressionDAGChecker::EvaluatingCompileExpression() const bool cmGeneratorExpressionDAGChecker::EvaluatingCompileExpression() const
{ {
cm::string_view property(this->Top()->Property); cm::string_view property(this->Top->Property);
return property == "INCLUDE_DIRECTORIES"_s || return property == "INCLUDE_DIRECTORIES"_s ||
property == "COMPILE_DEFINITIONS"_s || property == "COMPILE_OPTIONS"_s; property == "COMPILE_DEFINITIONS"_s || property == "COMPILE_OPTIONS"_s;
@@ -159,7 +160,7 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingCompileExpression() const
bool cmGeneratorExpressionDAGChecker::EvaluatingLinkExpression() const bool cmGeneratorExpressionDAGChecker::EvaluatingLinkExpression() const
{ {
cm::string_view property(this->Top()->Property); cm::string_view property(this->Top->Property);
return property == "LINK_DIRECTORIES"_s || property == "LINK_OPTIONS"_s || return property == "LINK_DIRECTORIES"_s || property == "LINK_OPTIONS"_s ||
property == "LINK_DEPENDS"_s || property == "LINK_LIBRARY_OVERRIDE"_s || property == "LINK_DEPENDS"_s || property == "LINK_LIBRARY_OVERRIDE"_s ||
@@ -168,14 +169,14 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkExpression() const
bool cmGeneratorExpressionDAGChecker::EvaluatingLinkOptionsExpression() const bool cmGeneratorExpressionDAGChecker::EvaluatingLinkOptionsExpression() const
{ {
cm::string_view property(this->Top()->Property); cm::string_view property(this->Top->Property);
return property == "LINK_OPTIONS"_s || property == "LINKER_TYPE"_s; return property == "LINK_OPTIONS"_s || property == "LINKER_TYPE"_s;
} }
bool cmGeneratorExpressionDAGChecker::EvaluatingLinkerLauncher() const bool cmGeneratorExpressionDAGChecker::EvaluatingLinkerLauncher() const
{ {
cm::string_view property(this->Top()->Property); cm::string_view property(this->Top->Property);
return property.length() > cmStrLen("_LINKER_LAUNCHER") && return property.length() > cmStrLen("_LINKER_LAUNCHER") &&
property.substr(property.length() - cmStrLen("_LINKER_LAUNCHER")) == property.substr(property.length() - cmStrLen("_LINKER_LAUNCHER")) ==
@@ -185,7 +186,7 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkerLauncher() const
bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries( bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(
cmGeneratorTarget const* tgt, ForGenex genex) const cmGeneratorTarget const* tgt, ForGenex genex) const
{ {
const auto* top = this->Top(); const auto* top = this->Top;
cm::string_view prop(top->Property); cm::string_view prop(top->Property);
@@ -206,21 +207,9 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(
: (result || prop == "INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE"_s); : (result || prop == "INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE"_s);
} }
cmGeneratorExpressionDAGChecker const* cmGeneratorExpressionDAGChecker::Top()
const
{
const cmGeneratorExpressionDAGChecker* top = this;
const cmGeneratorExpressionDAGChecker* parent = this->Parent;
while (parent) {
top = parent;
parent = parent->Parent;
}
return top;
}
cmGeneratorTarget const* cmGeneratorExpressionDAGChecker::TopTarget() const cmGeneratorTarget const* cmGeneratorExpressionDAGChecker::TopTarget() const
{ {
return this->Top()->Target; return this->Top->Target;
} }
enum class TransitiveProperty enum class TransitiveProperty
+1 -1
View File
@@ -94,13 +94,13 @@ struct cmGeneratorExpressionDAGChecker
bool GetTransitivePropertiesOnlyCMP0131() const; bool GetTransitivePropertiesOnlyCMP0131() const;
void SetTransitivePropertiesOnlyCMP0131() { this->CMP0131 = true; } void SetTransitivePropertiesOnlyCMP0131() { this->CMP0131 = true; }
cmGeneratorExpressionDAGChecker const* Top() const;
cmGeneratorTarget const* TopTarget() const; cmGeneratorTarget const* TopTarget() const;
private: private:
Result CheckGraph() const; Result CheckGraph() const;
const cmGeneratorExpressionDAGChecker* const Parent; const cmGeneratorExpressionDAGChecker* const Parent;
const cmGeneratorExpressionDAGChecker* const Top;
cmGeneratorTarget const* Target; cmGeneratorTarget const* Target;
const std::string Property; const std::string Property;
mutable std::map<cmGeneratorTarget const*, std::set<std::string>> Seen; mutable std::map<cmGeneratorTarget const*, std::set<std::string>> Seen;