Make all relevant targets available in the genex context.

The current node being evaluated transitively in the generator
expression must be available to resolve mapped configs.
This commit is contained in:
Stephen Kelly 2012-11-06 16:06:31 +01:00
parent 0c657dc637
commit 26def1771d
5 changed files with 29 additions and 6 deletions

View File

@ -53,7 +53,22 @@ cmGeneratorExpression::~cmGeneratorExpression()
//----------------------------------------------------------------------------
const char *cmCompiledGeneratorExpression::Evaluate(
cmMakefile* mf, const char* config, bool quiet,
cmTarget *target,
cmTarget *headTarget,
cmGeneratorExpressionDAGChecker *dagChecker) const
{
return this->Evaluate(mf,
config,
quiet,
headTarget,
headTarget,
dagChecker);
}
//----------------------------------------------------------------------------
const char *cmCompiledGeneratorExpression::Evaluate(
cmMakefile* mf, const char* config, bool quiet,
cmTarget *headTarget,
cmTarget *currentTarget,
cmGeneratorExpressionDAGChecker *dagChecker) const
{
if (!this->NeedsParsing)
@ -73,7 +88,8 @@ const char *cmCompiledGeneratorExpression::Evaluate(
context.Config = config;
context.Quiet = quiet;
context.HadError = false;
context.Target = target;
context.HeadTarget = headTarget;
context.CurrentTarget = currentTarget ? currentTarget : headTarget;
context.Backtrace = this->Backtrace;
for ( ; it != end; ++it)

View File

@ -71,8 +71,13 @@ class cmCompiledGeneratorExpression
public:
const char* Evaluate(cmMakefile* mf, const char* config,
bool quiet = false,
cmTarget *target = 0,
cmTarget *headTarget = 0,
cmTarget *currentTarget = 0,
cmGeneratorExpressionDAGChecker *dagChecker = 0) const;
const char* Evaluate(cmMakefile* mf, const char* config,
bool quiet,
cmTarget *headTarget,
cmGeneratorExpressionDAGChecker *dagChecker) const;
/** Get set of targets found during evaluations. */
std::set<cmTarget*> const& GetTargets() const

View File

@ -57,7 +57,7 @@ void cmGeneratorExpressionDAGChecker::reportError(
e << "Error evaluating generator expression:\n"
<< " " << expr << "\n"
<< "Self reference on target \""
<< context->Target->GetName() << "\".\n";
<< context->HeadTarget->GetName() << "\".\n";
context->Makefile->GetCMakeInstance()
->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(),
parent->Backtrace);

View File

@ -297,7 +297,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
cmsys::RegularExpression propertyNameValidator;
propertyNameValidator.compile("^[A-Za-z0-9_]+$");
cmTarget* target = context->Target;
cmTarget* target = context->HeadTarget;
std::string propertyName = *parameters.begin();
if (parameters.size() == 2)
{

View File

@ -26,7 +26,9 @@ struct cmGeneratorExpressionContext
std::set<cmTarget*> Targets;
cmMakefile *Makefile;
const char *Config;
cmTarget *Target;
cmTarget *HeadTarget; // The target whose property is being evaluated.
cmTarget *CurrentTarget; // The dependent of HeadTarget which appears
// directly or indirectly in the property.
bool Quiet;
bool HadError;
};