diff options
author | Stephen Kelly <steveire@gmail.com> | 2013-02-08 19:20:53 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2013-02-08 20:44:11 (GMT) |
commit | 9712362b4580fb92394ecf8ff57be186571f4319 (patch) | |
tree | b043d6b3e90e5026b9bb7afdd8b03f79971a523c | |
parent | faa927e273e04b9aadc13fb1f2b8b307b7383cd2 (diff) | |
download | CMake-9712362b4580fb92394ecf8ff57be186571f4319.zip CMake-9712362b4580fb92394ecf8ff57be186571f4319.tar.gz CMake-9712362b4580fb92394ecf8ff57be186571f4319.tar.bz2 |
Don't allow utility or global targets in the LINKED expression.
The LINKED expression is exclusively for handling INTERFACE content
and it does not make sense for utility targets to have INTERFACE
content.
6 files changed, 26 insertions, 0 deletions
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index d2dbf11..98e0ada 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -702,6 +702,14 @@ private: { return std::string(); } + if(target->GetType() >= cmTarget::UTILITY && + target->GetType() != cmTarget::UNKNOWN_LIBRARY) + { + ::reportError(context, content->GetOriginalExpression(), + "Target \"" + item + + "\" is not an executable or library."); + return std::string(); + } std::string propertyName = "INTERFACE_" + prop; const char *propContent = target->GetProperty(propertyName.c_str()); if (!propContent) diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget-result.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget-stderr.txt new file mode 100644 index 0000000..fb06554 --- /dev/null +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget-stderr.txt @@ -0,0 +1,8 @@ +CMake Error at BadLinked-UtilityTarget.cmake:7 \(set_property\): + Error evaluating generator expression: + + \$<LINKED:check> + + Target "check" is not an executable or library. +Call Stack \(most recent call first\): + CMakeLists.txt:8 \(include\) diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget.cmake new file mode 100644 index 0000000..d114c8f --- /dev/null +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/BadLinked-UtilityTarget.cmake @@ -0,0 +1,7 @@ + +add_custom_target(check ALL + COMMAND ${CMAKE_COMMAND} -E echo check +) + +add_library(foo STATIC empty.cpp) +set_property(TARGET foo PROPERTY INCLUDE_DIRECTORIES $<LINKED:check>) diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake b/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake index ea48f61..84039c4 100644 --- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/RunCMakeTest.cmake @@ -16,3 +16,4 @@ run_cmake(BadInvalidName6) run_cmake(BadInvalidName7) run_cmake(BadInvalidName8) run_cmake(BadLinked) +run_cmake(BadLinked-UtilityTarget) diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/empty.cpp b/Tests/RunCMake/TargetPropertyGeneratorExpressions/empty.cpp new file mode 100644 index 0000000..8b1a393 --- /dev/null +++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/empty.cpp @@ -0,0 +1 @@ +// empty |