Genex: Report error if a target file is needed to evaluate link libraries.
Constructs such as target_link_libraries(foo $<$<STREQUAL:$<TARGET_FILE:foo>,foo.so>:bar>) segfault before this patch.
This commit is contained in:
parent
b58aff90c5
commit
ff015ee11e
|
@ -1100,7 +1100,7 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode
|
|||
std::string Evaluate(const std::vector<std::string> ¶meters,
|
||||
cmGeneratorExpressionContext *context,
|
||||
const GeneratorExpressionContent *content,
|
||||
cmGeneratorExpressionDAGChecker *) const
|
||||
cmGeneratorExpressionDAGChecker *dagChecker) const
|
||||
{
|
||||
// Lookup the referenced target.
|
||||
std::string name = *parameters.begin();
|
||||
|
@ -1125,6 +1125,13 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode
|
|||
"Target \"" + name + "\" is not an executable or library.");
|
||||
return std::string();
|
||||
}
|
||||
if (dagChecker && dagChecker->EvaluatingLinkLibraries(name.c_str()))
|
||||
{
|
||||
::reportError(context, content->GetOriginalExpression(),
|
||||
"Expressions which require the linker language may not "
|
||||
"be used while evaluating link libraries");
|
||||
return std::string();
|
||||
}
|
||||
context->DependTargets.insert(target);
|
||||
context->AllTargets.insert(target);
|
||||
|
||||
|
|
|
@ -2,3 +2,5 @@ include(RunCMake)
|
|||
|
||||
run_cmake(NoLangSHARED)
|
||||
run_cmake(LINK_LANGUAGE-genex)
|
||||
run_cmake(link-libraries-TARGET_FILE-genex)
|
||||
run_cmake(link-libraries-TARGET_FILE-genex-ok)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
0
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
enable_language(CXX)
|
||||
|
||||
add_library(foo SHARED empty.cpp)
|
||||
add_library(bar SHARED empty.cpp)
|
||||
target_link_libraries(foo $<$<STREQUAL:$<TARGET_FILE:bar>,anything>:bar>)
|
|
@ -0,0 +1 @@
|
|||
1
|
|
@ -0,0 +1,7 @@
|
|||
CMake Error:
|
||||
Error evaluating generator expression:
|
||||
|
||||
\$<TARGET_FILE:foo>
|
||||
|
||||
Expressions which require the linker language may not be used while
|
||||
evaluating link libraries
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
add_library(foo SHARED empty.cpp)
|
||||
add_library(bar SHARED empty.cpp)
|
||||
target_link_libraries(foo $<$<STREQUAL:$<TARGET_FILE:foo>,anything>:bar>)
|
Loading…
Reference in New Issue