Commit d9605897 authored by Brad King's avatar Brad King
Browse files

Genex: Reject $<TARGET_FILE:...> 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.
parent c515dc57
......@@ -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(),
......
CMake Error at BadTargetTypeObject.cmake:3 \(add_custom_target\):
Error evaluating generator expression:
\$<TARGET_FILE:objlib>
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_SONAME_FILE:objlib>
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_LINKER_FILE:objlib>
Target "objlib" is not an executable or library.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
enable_language(C)
add_library(objlib OBJECT empty.c)
add_custom_target(check ALL COMMAND echo
$<TARGET_FILE:objlib>
$<TARGET_SONAME_FILE:objlib>
$<TARGET_LINKER_FILE:objlib>
)
......@@ -7,4 +7,5 @@ run_cmake(BadNOT)
run_cmake(BadStrEqual)
run_cmake(BadZero)
run_cmake(BadTargetName)
run_cmake(BadTargetTypeObject)
run_cmake(BadInstallPrefix)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment