Don't crash when a target is expected but is not available.

This commit is contained in:
Stephen Kelly 2013-01-03 20:56:32 +01:00
parent 2c4969a131
commit e767ffcda5
1 changed files with 15 additions and 0 deletions

View File

@ -18,6 +18,8 @@
#include <cmsys/String.h>
#include <assert.h>
//----------------------------------------------------------------------------
#if !defined(__SUNPRO_CC) || __SUNPRO_CC > 0x510
static
@ -291,6 +293,17 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
cmTarget* target = context->Target;
std::string propertyName = *parameters.begin();
if (!target && parameters.size() == 1)
{
reportError(context, content->GetOriginalExpression(),
"$<TARGET_PROPERTY:prop> may only be used with targets. It may not "
"be used with add_custom_command. Specify the target to read a "
"property from using the $<TARGET_PROPERTY:tgt,prop> signature "
"instead.");
return std::string();
}
if (parameters.size() == 2)
{
if (parameters.begin()->empty() && parameters[1].empty())
@ -351,6 +364,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
return std::string();
}
assert(target);
cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace,
target->GetName(),
propertyName,