mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-24 23:49:18 -06:00
Genex: Diagnose invalid LINK_ONLY usage instead of crashing
When `$<LINK_ONLY:...>` is used outside of linking we may evaluate it without a `dagChecker`. Do not dereference the NULL pointer and issue a diagnostic instead. Closes: #16287
This commit is contained in:
@@ -672,15 +672,20 @@ static const struct LinkOnlyNode : public cmGeneratorExpressionNode
|
||||
LinkOnlyNode() {}
|
||||
|
||||
std::string Evaluate(const std::vector<std::string>& parameters,
|
||||
cmGeneratorExpressionContext* /*context*/,
|
||||
const GeneratorExpressionContent* /*content*/,
|
||||
cmGeneratorExpressionContext* context,
|
||||
const GeneratorExpressionContent* content,
|
||||
cmGeneratorExpressionDAGChecker* dagChecker) const
|
||||
CM_OVERRIDE
|
||||
{
|
||||
if (!dagChecker) {
|
||||
reportError(context, content->GetOriginalExpression(),
|
||||
"$<LINK_ONLY:...> may only be used for linking");
|
||||
return std::string();
|
||||
}
|
||||
if (!dagChecker->GetTransitivePropertiesOnly()) {
|
||||
return parameters.front();
|
||||
}
|
||||
return "";
|
||||
return std::string();
|
||||
}
|
||||
} linkOnlyNode;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user