From e429e9af4259f924f4f8329f9f994e2f6a6e824a Mon Sep 17 00:00:00 2001 From: Marc Chevrier Date: Tue, 12 Feb 2019 16:25:56 +0100 Subject: genex: Fix erroneous handling of recursion for $ Fixes: #18894 --- Source/cmGeneratorExpressionDAGChecker.cxx | 10 ++-------- Source/cmGeneratorExpressionNode.cxx | 4 ++-- .../GeneratorExpression/GENEX_EVAL-recursion2-stderr.txt | 6 +++--- Tests/RunCMake/GeneratorExpression/GENEX_EVAL.cmake | 3 ++- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index 0f26e70..728f2a4 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -157,14 +157,8 @@ bool cmGeneratorExpressionDAGChecker::GetTransitivePropertiesOnly() bool cmGeneratorExpressionDAGChecker::EvaluatingGenexExpression() { - const cmGeneratorExpressionDAGChecker* top = this; - const cmGeneratorExpressionDAGChecker* parent = this->Parent; - while (parent) { - top = parent; - parent = parent->Parent; - } - - return top->Property == "TARGET_GENEX_EVAL" || top->Property == "GENEX_EVAL"; + return this->Property.find("TARGET_GENEX_EVAL:") == 0 || + this->Property.find("GENEX_EVAL:", 0) == 0; } bool cmGeneratorExpressionDAGChecker::EvaluatingPICExpression() diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index aac188e..70c80c9 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -404,8 +404,8 @@ protected: { if (context->HeadTarget) { cmGeneratorExpressionDAGChecker dagChecker( - context->Backtrace, context->HeadTarget, genexOperator, content, - dagCheckerParent); + context->Backtrace, context->HeadTarget, + genexOperator + ":" + expression, content, dagCheckerParent); switch (dagChecker.Check()) { case cmGeneratorExpressionDAGChecker::SELF_REFERENCE: case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE: { diff --git a/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion2-stderr.txt b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion2-stderr.txt index fd954e6..ed68400 100644 --- a/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion2-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL-recursion2-stderr.txt @@ -1,7 +1,7 @@ ^CMake Error at GENEX_EVAL-recursion2.cmake:8 \(add_custom_target\): Error evaluating generator expression: - \$> + \$> Dependency loop found. Call Stack \(most recent call first\): @@ -11,7 +11,7 @@ Call Stack \(most recent call first\): CMake Error at GENEX_EVAL-recursion2.cmake:8 \(add_custom_target\): Loop step 1 - \$> + \$> Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) @@ -20,7 +20,7 @@ Call Stack \(most recent call first\): CMake Error at GENEX_EVAL-recursion2.cmake:8 \(add_custom_target\): Loop step 2 - \$> + \$> Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/GENEX_EVAL.cmake b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL.cmake index ab8988b..153cd17 100644 --- a/Tests/RunCMake/GeneratorExpression/GENEX_EVAL.cmake +++ b/Tests/RunCMake/GeneratorExpression/GENEX_EVAL.cmake @@ -7,5 +7,6 @@ add_library (example SHARED empty.c) set_property (TARGET example PROPERTY CUSTOM_PROPERTY1 "PROPERTY1") set_property (TARGET example PROPERTY CUSTOM_PROPERTY2 "$") set_property (TARGET example PROPERTY CUSTOM_PROPERTY3 "$_AFTER>") +set_property (TARGET example PROPERTY CUSTOM_PROPERTY4 "$>") -file(GENERATE OUTPUT "GENEX_EVAL-generated.txt" CONTENT "$>") +file(GENERATE OUTPUT "GENEX_EVAL-generated.txt" CONTENT "$>") -- cgit v0.12