2012-09-18 15:42:23 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2012 Stephen Kelly <steveire@gmail.com>
|
|
|
|
|
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
|
|
|
|
|
|
|
#include "cmGeneratorExpressionDAGChecker.h"
|
|
|
|
|
|
|
|
#include "cmMakefile.h"
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker(
|
|
|
|
const cmListFileBacktrace &backtrace,
|
|
|
|
const std::string &target,
|
|
|
|
const std::string &property,
|
|
|
|
const GeneratorExpressionContent *content,
|
|
|
|
cmGeneratorExpressionDAGChecker *parent)
|
|
|
|
: Parent(parent), Target(target), Property(property),
|
|
|
|
Content(content), Backtrace(backtrace)
|
|
|
|
{
|
2012-12-21 18:49:19 +04:00
|
|
|
this->CheckResult = this->checkGraph();
|
2012-09-18 15:42:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2012-12-21 18:49:19 +04:00
|
|
|
cmGeneratorExpressionDAGChecker::Result
|
|
|
|
cmGeneratorExpressionDAGChecker::check() const
|
2012-09-18 15:42:23 +04:00
|
|
|
{
|
2012-12-21 18:49:19 +04:00
|
|
|
return this->CheckResult;
|
2012-09-18 15:42:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmGeneratorExpressionDAGChecker::reportError(
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const std::string &expr)
|
|
|
|
{
|
2012-12-21 18:49:19 +04:00
|
|
|
if (this->CheckResult == DAG)
|
2012-09-18 15:42:23 +04:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
context->HadError = true;
|
|
|
|
if (context->Quiet)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const cmGeneratorExpressionDAGChecker *parent = this->Parent;
|
|
|
|
|
|
|
|
if (parent && !parent->Parent)
|
|
|
|
{
|
|
|
|
cmOStringStream e;
|
|
|
|
e << "Error evaluating generator expression:\n"
|
|
|
|
<< " " << expr << "\n"
|
|
|
|
<< "Self reference on target \""
|
2012-11-06 19:06:31 +04:00
|
|
|
<< context->HeadTarget->GetName() << "\".\n";
|
2012-09-18 15:42:23 +04:00
|
|
|
context->Makefile->GetCMakeInstance()
|
|
|
|
->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(),
|
|
|
|
parent->Backtrace);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
cmOStringStream e;
|
|
|
|
e << "Error evaluating generator expression:\n"
|
|
|
|
<< " " << expr << "\n"
|
|
|
|
<< "Dependency loop found.";
|
|
|
|
context->Makefile->GetCMakeInstance()
|
|
|
|
->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(),
|
|
|
|
context->Backtrace);
|
|
|
|
}
|
|
|
|
|
|
|
|
int loopStep = 1;
|
|
|
|
while (parent)
|
|
|
|
{
|
|
|
|
cmOStringStream e;
|
|
|
|
e << "Loop step " << loopStep << "\n"
|
|
|
|
<< " "
|
|
|
|
<< (parent->Content ? parent->Content->GetOriginalExpression() : expr)
|
|
|
|
<< "\n";
|
|
|
|
context->Makefile->GetCMakeInstance()
|
|
|
|
->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(),
|
|
|
|
parent->Backtrace);
|
|
|
|
parent = parent->Parent;
|
|
|
|
++loopStep;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2012-12-21 18:49:19 +04:00
|
|
|
cmGeneratorExpressionDAGChecker::Result
|
|
|
|
cmGeneratorExpressionDAGChecker::checkGraph() const
|
2012-09-18 15:42:23 +04:00
|
|
|
{
|
|
|
|
const cmGeneratorExpressionDAGChecker *parent = this->Parent;
|
|
|
|
while (parent)
|
|
|
|
{
|
|
|
|
if (this->Target == parent->Target && this->Property == parent->Property)
|
|
|
|
{
|
2012-12-21 18:49:19 +04:00
|
|
|
return parent->Parent ? CYCLIC_REFERENCE : SELF_REFERENCE;
|
2012-09-18 15:42:23 +04:00
|
|
|
}
|
|
|
|
parent = parent->Parent;
|
|
|
|
}
|
2012-12-21 18:49:19 +04:00
|
|
|
return DAG;
|
2012-09-18 15:42:23 +04:00
|
|
|
}
|