From a4985a9af9ed9762c1a51c369981609dd24f7425 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 4 Oct 2012 00:32:39 +0200 Subject: GenEx: Report actual target name not found, not "0" each time. --- Source/cmGeneratorExpressionEvaluator.cxx | 5 +++-- .../TargetPropertyGeneratorExpressions/BadNonTarget-result.txt | 1 + .../TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt | 6 ++++++ .../RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget.cmake | 7 +++++++ .../RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake | 1 + 5 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-result.txt create mode 100644 Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt create mode 100644 Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget.cmake diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index ad5f83c..80cffe9 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -278,14 +278,15 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode std::string propertyName = *parameters.begin(); if (parameters.size() == 2) { + std::string targetName = parameters.front(); target = context->Makefile->FindGeneratorTargetToUse( - parameters.begin()->c_str()); + targetName.c_str()); if (!target) { cmOStringStream e; e << "Target \"" - << target + << targetName << "\" not found."; reportError(context, content->GetOriginalExpression(), e.str()); return std::string(); diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-result.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt new file mode 100644 index 0000000..d2ac7a9 --- /dev/null +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget-stderr.txt @@ -0,0 +1,6 @@ +CMake Error: + Error evaluating generator expression: + + \$ + + Target "NonExistant" not found.$ diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget.cmake new file mode 100644 index 0000000..b020c08 --- /dev/null +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadNonTarget.cmake @@ -0,0 +1,7 @@ + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" + "int main(int, char **) { return 0; }\n") + +add_executable(TargetPropertyGeneratorExpressions + "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") +include_directories("$") diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake index f2ff05b..e2abd56 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake @@ -6,3 +6,4 @@ run_cmake(BadSelfReference3) run_cmake(BadSelfReference4) run_cmake(BadSelfReference5) run_cmake(BadSelfReference6) +run_cmake(BadNonTarget) -- cgit v0.12