Merge topic 'fix-genex-with-no-target'

e767ffc Don't crash when a target is expected but is not available.
This commit is contained in:
Brad King 2013-01-07 14:19:47 -05:00 committed by CMake Topic Stage
commit 34f959e5b1
1 changed files with 15 additions and 0 deletions

View File

@ -18,6 +18,8 @@
#include <cmsys/String.h> #include <cmsys/String.h>
#include <assert.h>
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
#if !defined(__SUNPRO_CC) || __SUNPRO_CC > 0x510 #if !defined(__SUNPRO_CC) || __SUNPRO_CC > 0x510
static static
@ -291,6 +293,17 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
cmTarget* target = context->Target; cmTarget* target = context->Target;
std::string propertyName = *parameters.begin(); 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.size() == 2)
{ {
if (parameters.begin()->empty() && parameters[1].empty()) if (parameters.begin()->empty() && parameters[1].empty())
@ -351,6 +364,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
return std::string(); return std::string();
} }
assert(target);
cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace,
target->GetName(), target->GetName(),
propertyName, propertyName,