From d9605897788d800e892de0d201a305046510d089 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 1 Nov 2013 10:14:47 -0400 Subject: Genex: Reject $ for object libraries (#14532) Teach the cmGeneratorExpressionEvaluator filesystem artifact logic to reject OBJECT_LIBRARY targets since they have no main artifact. Without the explicit rejection evaluation falls through to an internal CMake error message in cmTarget::GetOutputInfo. Extend the RunCMake.GeneratorExpression test to cover these cases. --- Source/cmGeneratorExpressionEvaluator.cxx | 2 +- .../BadTargetTypeObject-result.txt | 1 + .../BadTargetTypeObject-stderr.txt | 26 ++++++++++++++++++++++ .../GeneratorExpression/BadTargetTypeObject.cmake | 7 ++++++ .../GeneratorExpression/RunCMakeTest.cmake | 1 + Tests/RunCMake/GeneratorExpression/empty.c | 0 6 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-result.txt create mode 100644 Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-stderr.txt create mode 100644 Tests/RunCMake/GeneratorExpression/BadTargetTypeObject.cmake create mode 100644 Tests/RunCMake/GeneratorExpression/empty.c diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index abe4e70..8b31354 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -1277,7 +1277,7 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode "No target \"" + name + "\""); return std::string(); } - if(target->GetType() >= cmTarget::UTILITY && + if(target->GetType() >= cmTarget::OBJECT_LIBRARY && target->GetType() != cmTarget::UNKNOWN_LIBRARY) { ::reportError(context, content->GetOriginalExpression(), diff --git a/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-result.txt b/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-stderr.txt new file mode 100644 index 0000000..533d38c --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject-stderr.txt @@ -0,0 +1,26 @@ +CMake Error at BadTargetTypeObject.cmake:3 \(add_custom_target\): + Error evaluating generator expression: + + \$ + + Target "objlib" is not an executable or library. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at BadTargetTypeObject.cmake:3 \(add_custom_target\): + Error evaluating generator expression: + + \$ + + Target "objlib" is not an executable or library. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) ++ +CMake Error at BadTargetTypeObject.cmake:3 \(add_custom_target\): + Error evaluating generator expression: + + \$ + + Target "objlib" is not an executable or library. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject.cmake b/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject.cmake new file mode 100644 index 0000000..c47ee2b --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/BadTargetTypeObject.cmake @@ -0,0 +1,7 @@ +enable_language(C) +add_library(objlib OBJECT empty.c) +add_custom_target(check ALL COMMAND echo + $ + $ + $ + ) diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 62bf29b..54d5064 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -7,4 +7,5 @@ run_cmake(BadNOT) run_cmake(BadStrEqual) run_cmake(BadZero) run_cmake(BadTargetName) +run_cmake(BadTargetTypeObject) run_cmake(BadInstallPrefix) diff --git a/Tests/RunCMake/GeneratorExpression/empty.c b/Tests/RunCMake/GeneratorExpression/empty.c new file mode 100644 index 0000000..e69de29 -- cgit v0.12