2012-09-11 21:53:38 +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 "cmMakefile.h"
|
|
|
|
|
|
|
|
#include "cmGeneratorExpressionEvaluator.h"
|
|
|
|
#include "cmGeneratorExpressionParser.h"
|
2012-09-18 15:42:23 +04:00
|
|
|
#include "cmGeneratorExpressionDAGChecker.h"
|
2012-09-18 15:53:39 +04:00
|
|
|
#include "cmGeneratorExpression.h"
|
2014-02-26 18:59:18 +04:00
|
|
|
#include "cmLocalGenerator.h"
|
|
|
|
#include "cmSourceFile.h"
|
2012-09-11 21:53:38 +04:00
|
|
|
|
2012-11-01 17:21:25 +04:00
|
|
|
#include <cmsys/String.h>
|
|
|
|
|
2013-01-03 23:56:32 +04:00
|
|
|
#include <assert.h>
|
2013-12-27 15:42:37 +04:00
|
|
|
#include <errno.h>
|
2013-01-03 23:56:32 +04:00
|
|
|
|
2012-09-11 21:53:38 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2012-10-12 00:31:35 +04:00
|
|
|
#if !defined(__SUNPRO_CC) || __SUNPRO_CC > 0x510
|
|
|
|
static
|
|
|
|
#endif
|
|
|
|
void reportError(cmGeneratorExpressionContext *context,
|
2012-09-11 21:53:38 +04:00
|
|
|
const std::string &expr, const std::string &result)
|
|
|
|
{
|
|
|
|
context->HadError = true;
|
|
|
|
if (context->Quiet)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmOStringStream e;
|
|
|
|
e << "Error evaluating generator expression:\n"
|
|
|
|
<< " " << expr << "\n"
|
|
|
|
<< result;
|
|
|
|
context->Makefile->GetCMakeInstance()
|
2014-03-11 03:04:11 +04:00
|
|
|
->IssueMessage(cmake::FATAL_ERROR, e.str(),
|
2012-09-11 21:53:38 +04:00
|
|
|
context->Backtrace);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
struct cmGeneratorExpressionNode
|
|
|
|
{
|
2013-05-16 17:52:25 +04:00
|
|
|
enum {
|
|
|
|
DynamicParameters = 0,
|
|
|
|
OneOrMoreParameters = -1,
|
2013-12-31 17:28:52 +04:00
|
|
|
OneOrZeroParameters = -2
|
2013-05-16 17:52:25 +04:00
|
|
|
};
|
2012-09-11 21:53:38 +04:00
|
|
|
virtual ~cmGeneratorExpressionNode() {}
|
|
|
|
|
|
|
|
virtual bool GeneratesContent() const { return true; }
|
|
|
|
|
2012-12-10 14:31:59 +04:00
|
|
|
virtual bool RequiresLiteralInput() const { return false; }
|
|
|
|
|
2013-04-25 15:28:57 +04:00
|
|
|
virtual bool AcceptsArbitraryContentParameter() const
|
2012-09-11 21:53:38 +04:00
|
|
|
{ return false; }
|
|
|
|
|
|
|
|
virtual int NumExpectedParameters() const { return 1; }
|
|
|
|
|
|
|
|
virtual std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *context,
|
2012-09-18 15:42:23 +04:00
|
|
|
const GeneratorExpressionContent *content,
|
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker
|
2012-09-11 21:53:38 +04:00
|
|
|
) const = 0;
|
2014-11-26 23:29:05 +03:00
|
|
|
|
|
|
|
static std::string EvaluateDependentExpression(
|
|
|
|
std::string const& prop, cmMakefile *makefile,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
cmTarget const* headTarget, cmTarget const* currentTarget,
|
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker);
|
2012-09-11 21:53:38 +04:00
|
|
|
};
|
|
|
|
|
2014-11-26 23:29:05 +03:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
|
|
|
|
std::string const& prop, cmMakefile *makefile,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
cmTarget const* headTarget, cmTarget const* currentTarget,
|
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker)
|
|
|
|
{
|
|
|
|
cmGeneratorExpression ge(&context->Backtrace);
|
|
|
|
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
|
|
|
|
cge->SetEvaluateForBuildsystem(context->EvaluateForBuildsystem);
|
|
|
|
std::string result = cge->Evaluate(makefile,
|
|
|
|
context->Config,
|
|
|
|
context->Quiet,
|
|
|
|
headTarget,
|
|
|
|
currentTarget,
|
|
|
|
dagChecker);
|
|
|
|
if (cge->GetHadContextSensitiveCondition())
|
|
|
|
{
|
|
|
|
context->HadContextSensitiveCondition = true;
|
|
|
|
}
|
|
|
|
if (cge->GetHadHeadSensitiveCondition())
|
|
|
|
{
|
|
|
|
context->HadHeadSensitiveCondition = true;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-09-11 21:53:38 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct ZeroNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
ZeroNode() {}
|
|
|
|
|
|
|
|
virtual bool GeneratesContent() const { return false; }
|
|
|
|
|
2013-04-25 15:28:57 +04:00
|
|
|
virtual bool AcceptsArbitraryContentParameter() const { return true; }
|
2012-11-27 01:43:13 +04:00
|
|
|
|
2012-09-11 21:53:38 +04:00
|
|
|
std::string Evaluate(const std::vector<std::string> &,
|
|
|
|
cmGeneratorExpressionContext *,
|
2012-09-18 15:42:23 +04:00
|
|
|
const GeneratorExpressionContent *,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
} zeroNode;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct OneNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
OneNode() {}
|
|
|
|
|
2013-04-25 15:28:57 +04:00
|
|
|
virtual bool AcceptsArbitraryContentParameter() const { return true; }
|
2012-09-11 21:53:38 +04:00
|
|
|
|
2013-12-18 03:32:35 +04:00
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
2012-09-11 21:53:38 +04:00
|
|
|
cmGeneratorExpressionContext *,
|
2012-09-18 15:42:23 +04:00
|
|
|
const GeneratorExpressionContent *,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
2013-12-18 03:32:35 +04:00
|
|
|
return parameters.front();
|
2012-09-11 21:53:38 +04:00
|
|
|
}
|
|
|
|
} oneNode;
|
|
|
|
|
2012-09-23 15:16:44 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct OneNode buildInterfaceNode;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct ZeroNode installInterfaceNode;
|
|
|
|
|
2012-09-11 21:53:38 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
#define BOOLEAN_OP_NODE(OPNAME, OP, SUCCESS_VALUE, FAILURE_VALUE) \
|
|
|
|
static const struct OP ## Node : public cmGeneratorExpressionNode \
|
|
|
|
{ \
|
|
|
|
OP ## Node () {} \
|
2013-05-16 17:52:25 +04:00
|
|
|
virtual int NumExpectedParameters() const { return OneOrMoreParameters; } \
|
2012-09-11 21:53:38 +04:00
|
|
|
\
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters, \
|
|
|
|
cmGeneratorExpressionContext *context, \
|
2012-09-18 15:42:23 +04:00
|
|
|
const GeneratorExpressionContent *content, \
|
|
|
|
cmGeneratorExpressionDAGChecker *) const \
|
2012-09-11 21:53:38 +04:00
|
|
|
{ \
|
|
|
|
std::vector<std::string>::const_iterator it = parameters.begin(); \
|
|
|
|
const std::vector<std::string>::const_iterator end = parameters.end(); \
|
|
|
|
for ( ; it != end; ++it) \
|
|
|
|
{ \
|
|
|
|
if (*it == #FAILURE_VALUE) \
|
|
|
|
{ \
|
|
|
|
return #FAILURE_VALUE; \
|
|
|
|
} \
|
|
|
|
else if (*it != #SUCCESS_VALUE) \
|
|
|
|
{ \
|
|
|
|
reportError(context, content->GetOriginalExpression(), \
|
|
|
|
"Parameters to $<" #OP "> must resolve to either '0' or '1'."); \
|
|
|
|
return std::string(); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
return #SUCCESS_VALUE; \
|
|
|
|
} \
|
|
|
|
} OPNAME;
|
|
|
|
|
|
|
|
BOOLEAN_OP_NODE(andNode, AND, 1, 0)
|
|
|
|
BOOLEAN_OP_NODE(orNode, OR, 0, 1)
|
|
|
|
|
|
|
|
#undef BOOLEAN_OP_NODE
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct NotNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
NotNode() {}
|
2012-09-18 15:42:23 +04:00
|
|
|
|
2012-09-11 21:53:38 +04:00
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *context,
|
2012-09-18 15:42:23 +04:00
|
|
|
const GeneratorExpressionContent *content,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
|
|
|
if (*parameters.begin() != "0" && *parameters.begin() != "1")
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<NOT> parameter must resolve to exactly one '0' or '1' value.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
return *parameters.begin() == "0" ? "1" : "0";
|
|
|
|
}
|
|
|
|
} notNode;
|
|
|
|
|
2012-09-12 06:20:42 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct BoolNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
BoolNode() {}
|
|
|
|
|
|
|
|
virtual int NumExpectedParameters() const { return 1; }
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *,
|
2012-09-18 15:42:23 +04:00
|
|
|
const GeneratorExpressionContent *,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
2012-09-12 06:20:42 +04:00
|
|
|
{
|
|
|
|
return !cmSystemTools::IsOff(parameters.begin()->c_str()) ? "1" : "0";
|
|
|
|
}
|
|
|
|
} boolNode;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct StrEqualNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
StrEqualNode() {}
|
|
|
|
|
|
|
|
virtual int NumExpectedParameters() const { return 2; }
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *,
|
2012-09-18 15:42:23 +04:00
|
|
|
const GeneratorExpressionContent *,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
2012-09-12 06:20:42 +04:00
|
|
|
{
|
2012-10-04 13:21:05 +04:00
|
|
|
return *parameters.begin() == parameters[1] ? "1" : "0";
|
2012-09-12 06:20:42 +04:00
|
|
|
}
|
|
|
|
} strEqualNode;
|
|
|
|
|
2013-12-27 15:42:37 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct EqualNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
EqualNode() {}
|
|
|
|
|
|
|
|
virtual int NumExpectedParameters() const { return 2; }
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *content,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
|
|
|
{
|
|
|
|
char *pEnd;
|
|
|
|
|
|
|
|
int base = 0;
|
|
|
|
bool flipSign = false;
|
|
|
|
|
|
|
|
const char *lhs = parameters[0].c_str();
|
2014-01-04 22:38:23 +04:00
|
|
|
if (cmHasLiteralPrefix(lhs, "0b") || cmHasLiteralPrefix(lhs, "0B"))
|
2013-12-27 15:42:37 +04:00
|
|
|
{
|
|
|
|
base = 2;
|
|
|
|
lhs += 2;
|
|
|
|
}
|
2014-01-04 22:38:23 +04:00
|
|
|
if (cmHasLiteralPrefix(lhs, "-0b") || cmHasLiteralPrefix(lhs, "-0B"))
|
2013-12-27 15:42:37 +04:00
|
|
|
{
|
|
|
|
base = 2;
|
|
|
|
lhs += 3;
|
|
|
|
flipSign = true;
|
|
|
|
}
|
2014-01-04 22:38:23 +04:00
|
|
|
if (cmHasLiteralPrefix(lhs, "+0b") || cmHasLiteralPrefix(lhs, "+0B"))
|
2013-12-27 15:42:37 +04:00
|
|
|
{
|
|
|
|
base = 2;
|
|
|
|
lhs += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
long lnum = strtol(lhs, &pEnd, base);
|
|
|
|
if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<EQUAL> parameter " + parameters[0] + " is not a valid integer.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flipSign)
|
|
|
|
{
|
|
|
|
lnum = -lnum;
|
|
|
|
}
|
|
|
|
|
|
|
|
base = 0;
|
|
|
|
flipSign = false;
|
|
|
|
|
|
|
|
const char *rhs = parameters[1].c_str();
|
2014-01-04 22:38:23 +04:00
|
|
|
if (cmHasLiteralPrefix(rhs, "0b") || cmHasLiteralPrefix(rhs, "0B"))
|
2013-12-27 15:42:37 +04:00
|
|
|
{
|
|
|
|
base = 2;
|
|
|
|
rhs += 2;
|
|
|
|
}
|
2014-01-04 22:38:23 +04:00
|
|
|
if (cmHasLiteralPrefix(rhs, "-0b") || cmHasLiteralPrefix(rhs, "-0B"))
|
2013-12-27 15:42:37 +04:00
|
|
|
{
|
|
|
|
base = 2;
|
|
|
|
rhs += 3;
|
|
|
|
flipSign = true;
|
|
|
|
}
|
2014-01-04 22:38:23 +04:00
|
|
|
if (cmHasLiteralPrefix(rhs, "+0b") || cmHasLiteralPrefix(rhs, "+0B"))
|
2013-12-27 15:42:37 +04:00
|
|
|
{
|
|
|
|
base = 2;
|
|
|
|
rhs += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
long rnum = strtol(rhs, &pEnd, base);
|
|
|
|
if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<EQUAL> parameter " + parameters[1] + " is not a valid integer.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flipSign)
|
|
|
|
{
|
|
|
|
rnum = -rnum;
|
|
|
|
}
|
|
|
|
|
|
|
|
return lnum == rnum ? "1" : "0";
|
|
|
|
}
|
|
|
|
} equalNode;
|
|
|
|
|
2013-11-21 00:40:29 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct LowerCaseNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
LowerCaseNode() {}
|
|
|
|
|
2013-12-15 14:02:56 +04:00
|
|
|
bool AcceptsArbitraryContentParameter() const { return true; }
|
|
|
|
|
2013-11-21 00:40:29 +04:00
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *,
|
|
|
|
const GeneratorExpressionContent *,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
|
|
|
{
|
|
|
|
return cmSystemTools::LowerCase(parameters.front());
|
|
|
|
}
|
|
|
|
} lowerCaseNode;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct UpperCaseNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
UpperCaseNode() {}
|
|
|
|
|
2013-12-15 14:02:56 +04:00
|
|
|
bool AcceptsArbitraryContentParameter() const { return true; }
|
|
|
|
|
2013-11-21 00:40:29 +04:00
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *,
|
|
|
|
const GeneratorExpressionContent *,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
|
|
|
{
|
|
|
|
return cmSystemTools::UpperCase(parameters.front());
|
|
|
|
}
|
|
|
|
} upperCaseNode;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct MakeCIdentifierNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
MakeCIdentifierNode() {}
|
|
|
|
|
2013-12-15 14:02:56 +04:00
|
|
|
bool AcceptsArbitraryContentParameter() const { return true; }
|
|
|
|
|
2013-11-21 00:40:29 +04:00
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *,
|
|
|
|
const GeneratorExpressionContent *,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
|
|
|
{
|
|
|
|
return cmSystemTools::MakeCidentifier(parameters.front().c_str());
|
|
|
|
}
|
|
|
|
} makeCIdentifierNode;
|
|
|
|
|
2012-09-12 06:20:42 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct Angle_RNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
Angle_RNode() {}
|
|
|
|
|
|
|
|
virtual int NumExpectedParameters() const { return 0; }
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> &,
|
|
|
|
cmGeneratorExpressionContext *,
|
2012-09-18 15:42:23 +04:00
|
|
|
const GeneratorExpressionContent *,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
2012-09-12 06:20:42 +04:00
|
|
|
{
|
|
|
|
return ">";
|
|
|
|
}
|
|
|
|
} angle_rNode;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct CommaNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
CommaNode() {}
|
|
|
|
|
|
|
|
virtual int NumExpectedParameters() const { return 0; }
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> &,
|
|
|
|
cmGeneratorExpressionContext *,
|
2012-09-18 15:42:23 +04:00
|
|
|
const GeneratorExpressionContent *,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
2012-09-12 06:20:42 +04:00
|
|
|
{
|
|
|
|
return ",";
|
|
|
|
}
|
|
|
|
} commaNode;
|
|
|
|
|
2013-03-12 10:52:01 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct SemicolonNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
SemicolonNode() {}
|
|
|
|
|
|
|
|
virtual int NumExpectedParameters() const { return 0; }
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> &,
|
|
|
|
cmGeneratorExpressionContext *,
|
|
|
|
const GeneratorExpressionContent *,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
|
|
|
{
|
|
|
|
return ";";
|
|
|
|
}
|
|
|
|
} semicolonNode;
|
|
|
|
|
2013-05-28 14:17:25 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
struct CompilerIdNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
CompilerIdNode() {}
|
|
|
|
|
2013-12-31 17:28:52 +04:00
|
|
|
virtual int NumExpectedParameters() const { return OneOrZeroParameters; }
|
2013-05-28 14:17:25 +04:00
|
|
|
|
|
|
|
std::string EvaluateWithLanguage(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *content,
|
|
|
|
cmGeneratorExpressionDAGChecker *,
|
|
|
|
const std::string &lang) const
|
|
|
|
{
|
2014-08-06 17:11:41 +04:00
|
|
|
const char *compilerId =
|
|
|
|
context->Makefile->GetSafeDefinition("CMAKE_" + lang + "_COMPILER_ID");
|
2013-05-28 14:17:25 +04:00
|
|
|
if (parameters.size() == 0)
|
|
|
|
{
|
|
|
|
return compilerId ? compilerId : "";
|
|
|
|
}
|
2014-04-30 21:12:29 +04:00
|
|
|
static cmsys::RegularExpression compilerIdValidator("^[A-Za-z0-9_]*$");
|
2014-04-30 21:13:21 +04:00
|
|
|
if (!compilerIdValidator.find(*parameters.begin()))
|
2013-05-28 14:17:25 +04:00
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Expression syntax not recognized.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
if (!compilerId)
|
|
|
|
{
|
|
|
|
return parameters.front().empty() ? "1" : "0";
|
|
|
|
}
|
|
|
|
|
2013-12-26 18:59:55 +04:00
|
|
|
if (strcmp(parameters.begin()->c_str(), compilerId) == 0)
|
2013-05-28 14:17:25 +04:00
|
|
|
{
|
|
|
|
return "1";
|
|
|
|
}
|
2013-12-26 18:59:55 +04:00
|
|
|
|
|
|
|
if (cmsysString_strcasecmp(parameters.begin()->c_str(), compilerId) == 0)
|
|
|
|
{
|
|
|
|
switch(context->Makefile->GetPolicyStatus(cmPolicies::CMP0044))
|
|
|
|
{
|
|
|
|
case cmPolicies::WARN:
|
|
|
|
{
|
|
|
|
cmOStringStream e;
|
|
|
|
e << context->Makefile->GetPolicies()
|
|
|
|
->GetPolicyWarning(cmPolicies::CMP0044);
|
|
|
|
context->Makefile->GetCMakeInstance()
|
|
|
|
->IssueMessage(cmake::AUTHOR_WARNING,
|
2014-03-11 03:04:11 +04:00
|
|
|
e.str(), context->Backtrace);
|
2013-12-26 18:59:55 +04:00
|
|
|
}
|
|
|
|
case cmPolicies::OLD:
|
|
|
|
return "1";
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-05-28 14:17:25 +04:00
|
|
|
return "0";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct CCompilerIdNode : public CompilerIdNode
|
|
|
|
{
|
|
|
|
CCompilerIdNode() {}
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *content,
|
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker) const
|
|
|
|
{
|
|
|
|
if (!context->HeadTarget)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
2014-05-29 00:02:57 +04:00
|
|
|
"$<C_COMPILER_ID> may only be used with binary targets. It may "
|
|
|
|
"not be used with add_custom_command or add_custom_target.");
|
2013-12-18 21:47:37 +04:00
|
|
|
return std::string();
|
2013-05-28 14:17:25 +04:00
|
|
|
}
|
|
|
|
return this->EvaluateWithLanguage(parameters, context, content,
|
|
|
|
dagChecker, "C");
|
|
|
|
}
|
|
|
|
} cCompilerIdNode;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct CXXCompilerIdNode : public CompilerIdNode
|
|
|
|
{
|
|
|
|
CXXCompilerIdNode() {}
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *content,
|
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker) const
|
|
|
|
{
|
|
|
|
if (!context->HeadTarget)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
2014-05-29 00:02:57 +04:00
|
|
|
"$<CXX_COMPILER_ID> may only be used with binary targets. It may "
|
|
|
|
"not be used with add_custom_command or add_custom_target.");
|
2013-12-18 21:47:37 +04:00
|
|
|
return std::string();
|
2013-05-28 14:17:25 +04:00
|
|
|
}
|
|
|
|
return this->EvaluateWithLanguage(parameters, context, content,
|
|
|
|
dagChecker, "CXX");
|
|
|
|
}
|
|
|
|
} cxxCompilerIdNode;
|
|
|
|
|
2013-06-11 12:48:47 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
struct CompilerVersionNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
CompilerVersionNode() {}
|
|
|
|
|
2013-12-31 17:28:52 +04:00
|
|
|
virtual int NumExpectedParameters() const { return OneOrZeroParameters; }
|
2013-06-11 12:48:47 +04:00
|
|
|
|
|
|
|
std::string EvaluateWithLanguage(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *content,
|
|
|
|
cmGeneratorExpressionDAGChecker *,
|
|
|
|
const std::string &lang) const
|
|
|
|
{
|
2014-08-06 17:11:41 +04:00
|
|
|
const char *compilerVersion = context->Makefile->GetSafeDefinition(
|
|
|
|
"CMAKE_" + lang + "_COMPILER_VERSION");
|
2013-06-11 12:48:47 +04:00
|
|
|
if (parameters.size() == 0)
|
|
|
|
{
|
|
|
|
return compilerVersion ? compilerVersion : "";
|
|
|
|
}
|
|
|
|
|
2014-04-30 21:12:29 +04:00
|
|
|
static cmsys::RegularExpression compilerIdValidator("^[0-9\\.]*$");
|
2014-04-30 21:13:21 +04:00
|
|
|
if (!compilerIdValidator.find(*parameters.begin()))
|
2013-06-11 12:48:47 +04:00
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Expression syntax not recognized.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
if (!compilerVersion)
|
|
|
|
{
|
|
|
|
return parameters.front().empty() ? "1" : "0";
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
|
|
|
|
parameters.begin()->c_str(),
|
|
|
|
compilerVersion) ? "1" : "0";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct CCompilerVersionNode : public CompilerVersionNode
|
|
|
|
{
|
|
|
|
CCompilerVersionNode() {}
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *content,
|
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker) const
|
|
|
|
{
|
|
|
|
if (!context->HeadTarget)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
2014-05-29 00:02:57 +04:00
|
|
|
"$<C_COMPILER_VERSION> may only be used with binary targets. It "
|
|
|
|
"may not be used with add_custom_command or add_custom_target.");
|
2013-12-18 21:47:37 +04:00
|
|
|
return std::string();
|
2013-06-11 12:48:47 +04:00
|
|
|
}
|
|
|
|
return this->EvaluateWithLanguage(parameters, context, content,
|
|
|
|
dagChecker, "C");
|
|
|
|
}
|
|
|
|
} cCompilerVersionNode;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct CxxCompilerVersionNode : public CompilerVersionNode
|
|
|
|
{
|
|
|
|
CxxCompilerVersionNode() {}
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *content,
|
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker) const
|
|
|
|
{
|
|
|
|
if (!context->HeadTarget)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
2014-05-29 00:02:57 +04:00
|
|
|
"$<CXX_COMPILER_VERSION> may only be used with binary targets. It "
|
|
|
|
"may not be used with add_custom_command or add_custom_target.");
|
2013-12-18 21:47:37 +04:00
|
|
|
return std::string();
|
2013-06-11 12:48:47 +04:00
|
|
|
}
|
|
|
|
return this->EvaluateWithLanguage(parameters, context, content,
|
|
|
|
dagChecker, "CXX");
|
|
|
|
}
|
|
|
|
} cxxCompilerVersionNode;
|
|
|
|
|
|
|
|
|
2013-08-27 12:57:16 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
struct PlatformIdNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
PlatformIdNode() {}
|
|
|
|
|
2013-12-31 17:28:52 +04:00
|
|
|
virtual int NumExpectedParameters() const { return OneOrZeroParameters; }
|
2013-08-27 12:57:16 +04:00
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
|
|
|
{
|
2014-08-06 17:11:41 +04:00
|
|
|
const char *platformId =
|
|
|
|
context->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME");
|
2013-08-27 12:57:16 +04:00
|
|
|
if (parameters.size() == 0)
|
|
|
|
{
|
|
|
|
return platformId ? platformId : "";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!platformId)
|
|
|
|
{
|
|
|
|
return parameters.front().empty() ? "1" : "0";
|
|
|
|
}
|
|
|
|
|
2013-12-18 21:48:07 +04:00
|
|
|
if (strcmp(parameters.begin()->c_str(), platformId) == 0)
|
2013-08-27 12:57:16 +04:00
|
|
|
{
|
|
|
|
return "1";
|
|
|
|
}
|
|
|
|
return "0";
|
|
|
|
}
|
|
|
|
} platformIdNode;
|
|
|
|
|
2013-06-11 11:53:10 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct VersionGreaterNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
VersionGreaterNode() {}
|
|
|
|
|
|
|
|
virtual int NumExpectedParameters() const { return 2; }
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *,
|
|
|
|
const GeneratorExpressionContent *,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
|
|
|
{
|
|
|
|
return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER,
|
|
|
|
parameters.front().c_str(),
|
|
|
|
parameters[1].c_str()) ? "1" : "0";
|
|
|
|
}
|
|
|
|
} versionGreaterNode;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct VersionLessNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
VersionLessNode() {}
|
|
|
|
|
|
|
|
virtual int NumExpectedParameters() const { return 2; }
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *,
|
|
|
|
const GeneratorExpressionContent *,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
|
|
|
{
|
|
|
|
return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
|
|
|
|
parameters.front().c_str(),
|
|
|
|
parameters[1].c_str()) ? "1" : "0";
|
|
|
|
}
|
|
|
|
} versionLessNode;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct VersionEqualNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
VersionEqualNode() {}
|
|
|
|
|
|
|
|
virtual int NumExpectedParameters() const { return 2; }
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *,
|
|
|
|
const GeneratorExpressionContent *,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
|
|
|
{
|
|
|
|
return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
|
|
|
|
parameters.front().c_str(),
|
|
|
|
parameters[1].c_str()) ? "1" : "0";
|
|
|
|
}
|
|
|
|
} versionEqualNode;
|
|
|
|
|
2013-06-05 15:43:54 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct LinkOnlyNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
LinkOnlyNode() {}
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *,
|
|
|
|
const GeneratorExpressionContent *,
|
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker) const
|
|
|
|
{
|
|
|
|
if(!dagChecker->GetTransitivePropertiesOnly())
|
|
|
|
{
|
|
|
|
return parameters.front();
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
} linkOnlyNode;
|
|
|
|
|
2012-09-11 21:53:38 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct ConfigurationNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
ConfigurationNode() {}
|
2012-09-18 15:42:23 +04:00
|
|
|
|
2012-09-11 21:53:38 +04:00
|
|
|
virtual int NumExpectedParameters() const { return 0; }
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> &,
|
|
|
|
cmGeneratorExpressionContext *context,
|
2012-09-18 15:42:23 +04:00
|
|
|
const GeneratorExpressionContent *,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
2013-02-03 10:33:15 +04:00
|
|
|
context->HadContextSensitiveCondition = true;
|
2014-02-10 07:48:34 +04:00
|
|
|
return context->Config;
|
2012-09-11 21:53:38 +04:00
|
|
|
}
|
|
|
|
} configurationNode;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
ConfigurationTestNode() {}
|
|
|
|
|
2013-12-31 18:57:25 +04:00
|
|
|
virtual int NumExpectedParameters() const { return OneOrZeroParameters; }
|
2012-09-11 21:53:38 +04:00
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *context,
|
2012-09-18 15:42:23 +04:00
|
|
|
const GeneratorExpressionContent *content,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
2013-12-31 18:57:25 +04:00
|
|
|
if (parameters.empty())
|
|
|
|
{
|
|
|
|
return configurationNode.Evaluate(parameters, context, content, 0);
|
|
|
|
}
|
2014-04-30 21:12:29 +04:00
|
|
|
static cmsys::RegularExpression configValidator("^[A-Za-z0-9_]*$");
|
2014-04-30 21:13:21 +04:00
|
|
|
if (!configValidator.find(*parameters.begin()))
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Expression syntax not recognized.");
|
|
|
|
return std::string();
|
|
|
|
}
|
2013-02-03 10:33:15 +04:00
|
|
|
context->HadContextSensitiveCondition = true;
|
2014-02-10 07:48:34 +04:00
|
|
|
if (context->Config.empty())
|
2012-10-04 02:36:23 +04:00
|
|
|
{
|
|
|
|
return parameters.front().empty() ? "1" : "0";
|
|
|
|
}
|
|
|
|
|
2012-12-23 14:20:37 +04:00
|
|
|
if (cmsysString_strcasecmp(parameters.begin()->c_str(),
|
2014-02-10 07:48:34 +04:00
|
|
|
context->Config.c_str()) == 0)
|
2012-12-23 14:20:37 +04:00
|
|
|
{
|
|
|
|
return "1";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (context->CurrentTarget
|
|
|
|
&& context->CurrentTarget->IsImported())
|
|
|
|
{
|
|
|
|
const char* loc = 0;
|
|
|
|
const char* imp = 0;
|
|
|
|
std::string suffix;
|
2013-07-15 20:33:49 +04:00
|
|
|
if (context->CurrentTarget->GetMappedConfig(context->Config,
|
2012-12-23 14:20:37 +04:00
|
|
|
&loc,
|
|
|
|
&imp,
|
2013-07-15 20:33:49 +04:00
|
|
|
suffix))
|
|
|
|
{
|
|
|
|
// This imported target has an appropriate location
|
|
|
|
// for this (possibly mapped) config.
|
|
|
|
// Check if there is a proper config mapping for the tested config.
|
|
|
|
std::vector<std::string> mappedConfigs;
|
|
|
|
std::string mapProp = "MAP_IMPORTED_CONFIG_";
|
2013-08-27 17:36:57 +04:00
|
|
|
mapProp += cmSystemTools::UpperCase(context->Config);
|
2013-07-15 20:33:49 +04:00
|
|
|
if(const char* mapValue =
|
2014-03-11 03:04:11 +04:00
|
|
|
context->CurrentTarget->GetProperty(mapProp))
|
2013-07-15 20:33:49 +04:00
|
|
|
{
|
|
|
|
cmSystemTools::ExpandListArgument(cmSystemTools::UpperCase(mapValue),
|
|
|
|
mappedConfigs);
|
|
|
|
return std::find(mappedConfigs.begin(), mappedConfigs.end(),
|
2013-08-27 17:36:57 +04:00
|
|
|
cmSystemTools::UpperCase(parameters.front()))
|
|
|
|
!= mappedConfigs.end() ? "1" : "0";
|
2013-07-15 20:33:49 +04:00
|
|
|
}
|
|
|
|
}
|
2012-12-23 14:20:37 +04:00
|
|
|
}
|
|
|
|
return "0";
|
2012-09-11 21:53:38 +04:00
|
|
|
}
|
|
|
|
} configurationTestNode;
|
|
|
|
|
2013-02-26 03:50:49 +04:00
|
|
|
static const struct JoinNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
JoinNode() {}
|
|
|
|
|
|
|
|
virtual int NumExpectedParameters() const { return 2; }
|
|
|
|
|
|
|
|
virtual bool AcceptsArbitraryContentParameter() const { return true; }
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *,
|
|
|
|
const GeneratorExpressionContent *,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
|
|
|
{
|
|
|
|
std::string result;
|
|
|
|
|
|
|
|
std::vector<std::string> list;
|
|
|
|
cmSystemTools::ExpandListArgument(parameters.front(), list);
|
|
|
|
std::string sep;
|
|
|
|
for(std::vector<std::string>::const_iterator li = list.begin();
|
|
|
|
li != list.end(); ++li)
|
|
|
|
{
|
|
|
|
result += sep + *li;
|
|
|
|
sep = parameters[1];
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
} joinNode;
|
|
|
|
|
2013-06-10 18:01:59 +04:00
|
|
|
#define TRANSITIVE_PROPERTY_NAME(PROPERTY) \
|
2013-10-29 12:22:32 +04:00
|
|
|
, "INTERFACE_" #PROPERTY
|
2013-06-10 18:01:59 +04:00
|
|
|
|
2012-09-23 15:45:17 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const char* targetPropertyTransitiveWhitelist[] = {
|
2013-06-10 18:01:59 +04:00
|
|
|
0
|
|
|
|
CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(TRANSITIVE_PROPERTY_NAME)
|
2012-09-23 15:45:17 +04:00
|
|
|
};
|
|
|
|
|
2013-12-31 17:34:16 +04:00
|
|
|
#undef TRANSITIVE_PROPERTY_NAME
|
|
|
|
|
2014-07-15 19:50:32 +04:00
|
|
|
template <typename T>
|
2014-06-30 18:31:01 +04:00
|
|
|
std::string
|
|
|
|
getLinkedTargetsContent(
|
2014-07-15 19:50:32 +04:00
|
|
|
std::vector<T> const &libraries,
|
2014-06-30 18:31:01 +04:00
|
|
|
cmTarget const* target,
|
|
|
|
cmTarget const* headTarget,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker,
|
|
|
|
const std::string &interfacePropertyName)
|
2013-05-29 02:34:30 +04:00
|
|
|
{
|
2014-07-15 19:50:32 +04:00
|
|
|
std::string linkedTargetsContent;
|
2013-05-29 02:34:30 +04:00
|
|
|
std::string sep;
|
|
|
|
std::string depString;
|
2014-07-15 19:50:32 +04:00
|
|
|
for (typename std::vector<T>::const_iterator it = libraries.begin();
|
|
|
|
it != libraries.end(); ++it)
|
2013-05-29 02:34:30 +04:00
|
|
|
{
|
2014-07-15 19:50:32 +04:00
|
|
|
// Broken code can have a target in its own link interface.
|
|
|
|
// Don't follow such link interface entries so as not to create a
|
|
|
|
// self-referencing loop.
|
|
|
|
if (it->Target && it->Target != target)
|
2013-05-29 02:34:30 +04:00
|
|
|
{
|
2014-07-15 19:50:32 +04:00
|
|
|
depString +=
|
|
|
|
sep + "$<TARGET_PROPERTY:" +
|
|
|
|
it->Target->GetName() + "," + interfacePropertyName + ">";
|
|
|
|
sep = ";";
|
2013-05-29 02:34:30 +04:00
|
|
|
}
|
|
|
|
}
|
2014-07-15 19:50:32 +04:00
|
|
|
if(!depString.empty())
|
2014-02-13 12:53:27 +04:00
|
|
|
{
|
2014-11-26 23:29:05 +03:00
|
|
|
linkedTargetsContent =
|
|
|
|
cmGeneratorExpressionNode::EvaluateDependentExpression(depString,
|
|
|
|
target->GetMakefile(), context,
|
|
|
|
headTarget, target, dagChecker);
|
2014-02-13 12:53:27 +04:00
|
|
|
}
|
2014-07-15 23:22:08 +04:00
|
|
|
linkedTargetsContent =
|
|
|
|
cmGeneratorExpression::StripEmptyListElements(linkedTargetsContent);
|
2014-07-15 19:50:32 +04:00
|
|
|
return linkedTargetsContent;
|
2014-02-13 12:53:27 +04:00
|
|
|
}
|
|
|
|
|
2012-09-12 06:23:31 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2012-09-18 15:42:23 +04:00
|
|
|
static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
2012-09-12 06:23:31 +04:00
|
|
|
{
|
|
|
|
TargetPropertyNode() {}
|
|
|
|
|
|
|
|
// This node handles errors on parameter count itself.
|
2013-05-16 17:52:25 +04:00
|
|
|
virtual int NumExpectedParameters() const { return OneOrMoreParameters; }
|
2012-09-12 06:23:31 +04:00
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *context,
|
2012-09-18 15:42:23 +04:00
|
|
|
const GeneratorExpressionContent *content,
|
2012-09-18 15:53:39 +04:00
|
|
|
cmGeneratorExpressionDAGChecker *dagCheckerParent
|
|
|
|
) const
|
2012-09-12 06:23:31 +04:00
|
|
|
{
|
|
|
|
if (parameters.size() != 1 && parameters.size() != 2)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<TARGET_PROPERTY:...> expression requires one or two parameters");
|
|
|
|
return std::string();
|
|
|
|
}
|
2014-04-30 21:12:29 +04:00
|
|
|
static cmsys::RegularExpression propertyNameValidator("^[A-Za-z0-9_]+$");
|
2012-10-04 02:31:24 +04:00
|
|
|
|
2013-10-30 01:21:20 +04:00
|
|
|
cmTarget const* target = context->HeadTarget;
|
2012-09-12 06:23:31 +04:00
|
|
|
std::string propertyName = *parameters.begin();
|
2013-01-03 23:56:32 +04:00
|
|
|
|
2014-07-21 21:02:22 +04:00
|
|
|
if (parameters.size() == 1)
|
|
|
|
{
|
|
|
|
context->HadHeadSensitiveCondition = true;
|
|
|
|
}
|
2013-01-03 23:56:32 +04:00
|
|
|
if (!target && parameters.size() == 1)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
2014-05-29 00:02:57 +04:00
|
|
|
"$<TARGET_PROPERTY:prop> may only be used with binary targets. "
|
|
|
|
"It may not be used with add_custom_command or add_custom_target. "
|
|
|
|
"Specify the target to read a property from using the "
|
|
|
|
"$<TARGET_PROPERTY:tgt,prop> signature instead.");
|
2013-01-03 23:56:32 +04:00
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
2012-09-12 06:23:31 +04:00
|
|
|
if (parameters.size() == 2)
|
|
|
|
{
|
2012-10-04 13:21:05 +04:00
|
|
|
if (parameters.begin()->empty() && parameters[1].empty())
|
2012-10-04 02:31:24 +04:00
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty "
|
|
|
|
"target name and property name.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
if (parameters.begin()->empty())
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty "
|
|
|
|
"target name.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
2012-10-04 02:32:39 +04:00
|
|
|
std::string targetName = parameters.front();
|
2012-10-04 13:21:05 +04:00
|
|
|
propertyName = parameters[1];
|
2013-02-06 16:32:15 +04:00
|
|
|
if (!cmGeneratorExpression::IsValidTargetName(targetName))
|
2012-10-04 02:31:24 +04:00
|
|
|
{
|
2012-10-19 15:11:59 +04:00
|
|
|
if (!propertyNameValidator.find(propertyName.c_str()))
|
2012-10-04 02:31:24 +04:00
|
|
|
{
|
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Target name and property name not supported.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Target name not supported.");
|
|
|
|
return std::string();
|
|
|
|
}
|
2013-07-12 11:14:31 +04:00
|
|
|
if(propertyName == "ALIASED_TARGET")
|
|
|
|
{
|
2014-01-16 02:56:38 +04:00
|
|
|
if(context->Makefile->IsAlias(targetName))
|
2013-07-12 11:14:31 +04:00
|
|
|
{
|
2014-01-16 02:56:38 +04:00
|
|
|
if(cmTarget* tgt = context->Makefile->FindTargetToUse(targetName))
|
2013-07-12 11:14:31 +04:00
|
|
|
{
|
|
|
|
return tgt->GetName();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
2014-01-16 02:56:38 +04:00
|
|
|
target = context->Makefile->FindTargetToUse(targetName);
|
2012-09-12 06:23:31 +04:00
|
|
|
|
|
|
|
if (!target)
|
|
|
|
{
|
|
|
|
cmOStringStream e;
|
|
|
|
e << "Target \""
|
2012-10-04 02:32:39 +04:00
|
|
|
<< targetName
|
2012-09-12 06:23:31 +04:00
|
|
|
<< "\" not found.";
|
|
|
|
reportError(context, content->GetOriginalExpression(), e.str());
|
2012-10-04 02:32:22 +04:00
|
|
|
return std::string();
|
2012-09-12 06:23:31 +04:00
|
|
|
}
|
2013-02-09 14:12:20 +04:00
|
|
|
context->AllTargets.insert(target);
|
2012-10-04 02:31:24 +04:00
|
|
|
}
|
|
|
|
|
2012-11-05 17:48:42 +04:00
|
|
|
if (target == context->HeadTarget)
|
|
|
|
{
|
|
|
|
// Keep track of the properties seen while processing.
|
|
|
|
// The evaluation of the LINK_LIBRARIES generator expressions
|
2013-02-07 16:04:46 +04:00
|
|
|
// will check this to ensure that properties have one consistent
|
|
|
|
// value for all evaluations.
|
2012-11-05 17:48:42 +04:00
|
|
|
context->SeenTargetProperties.insert(propertyName);
|
|
|
|
}
|
|
|
|
|
2012-10-04 02:31:24 +04:00
|
|
|
if (propertyName.empty())
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<TARGET_PROPERTY:...> expression requires a non-empty property "
|
|
|
|
"name.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
2014-04-30 21:13:21 +04:00
|
|
|
if (!propertyNameValidator.find(propertyName))
|
2012-10-04 02:31:24 +04:00
|
|
|
{
|
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Property name not supported.");
|
|
|
|
return std::string();
|
2012-09-12 06:23:31 +04:00
|
|
|
}
|
2012-09-18 15:53:39 +04:00
|
|
|
|
2013-01-03 23:56:32 +04:00
|
|
|
assert(target);
|
|
|
|
|
2013-07-18 14:58:48 +04:00
|
|
|
if (propertyName == "LINKER_LANGUAGE")
|
|
|
|
{
|
2013-07-25 11:12:28 +04:00
|
|
|
if (target->LinkLanguagePropagatesToDependents() &&
|
2014-02-13 23:52:21 +04:00
|
|
|
dagCheckerParent && (dagCheckerParent->EvaluatingLinkLibraries()
|
|
|
|
|| dagCheckerParent->EvaluatingSources()))
|
2013-07-18 14:58:48 +04:00
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"LINKER_LANGUAGE target property can not be used while evaluating "
|
2013-07-25 11:12:28 +04:00
|
|
|
"link libraries for a static library");
|
2013-07-18 14:58:48 +04:00
|
|
|
return std::string();
|
|
|
|
}
|
2014-02-04 06:20:56 +04:00
|
|
|
return target->GetLinkerLanguage(context->Config);
|
2013-07-18 14:58:48 +04:00
|
|
|
}
|
|
|
|
|
2012-09-18 15:53:39 +04:00
|
|
|
cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace,
|
|
|
|
target->GetName(),
|
|
|
|
propertyName,
|
|
|
|
content,
|
|
|
|
dagCheckerParent);
|
|
|
|
|
2014-01-05 08:25:09 +04:00
|
|
|
switch (dagChecker.Check())
|
2012-09-18 15:53:39 +04:00
|
|
|
{
|
2012-12-21 18:49:19 +04:00
|
|
|
case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
|
2014-01-05 08:25:09 +04:00
|
|
|
dagChecker.ReportError(context, content->GetOriginalExpression());
|
2012-09-18 15:53:39 +04:00
|
|
|
return std::string();
|
2012-12-21 18:49:19 +04:00
|
|
|
case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE:
|
|
|
|
// No error. We just skip cyclic references.
|
|
|
|
return std::string();
|
2013-02-01 12:38:40 +04:00
|
|
|
case cmGeneratorExpressionDAGChecker::ALREADY_SEEN:
|
2013-06-10 18:01:59 +04:00
|
|
|
for (size_t i = 1;
|
2013-10-22 03:12:24 +04:00
|
|
|
i < cmArraySize(targetPropertyTransitiveWhitelist);
|
2013-02-07 15:33:20 +04:00
|
|
|
++i)
|
|
|
|
{
|
|
|
|
if (targetPropertyTransitiveWhitelist[i] == propertyName)
|
|
|
|
{
|
|
|
|
// No error. We're not going to find anything new here.
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
}
|
2012-12-21 18:49:19 +04:00
|
|
|
case cmGeneratorExpressionDAGChecker::DAG:
|
|
|
|
break;
|
2012-09-18 15:53:39 +04:00
|
|
|
}
|
|
|
|
|
2014-03-11 03:04:11 +04:00
|
|
|
const char *prop = target->GetProperty(propertyName);
|
2013-02-12 14:29:09 +04:00
|
|
|
|
|
|
|
if (dagCheckerParent)
|
2012-09-23 15:45:17 +04:00
|
|
|
{
|
2013-02-12 14:29:09 +04:00
|
|
|
if (dagCheckerParent->EvaluatingLinkLibraries())
|
2013-01-19 14:21:14 +04:00
|
|
|
{
|
2014-05-11 18:04:53 +04:00
|
|
|
#define TRANSITIVE_PROPERTY_COMPARE(PROPERTY) \
|
|
|
|
(#PROPERTY == propertyName || "INTERFACE_" #PROPERTY == propertyName) ||
|
|
|
|
if (CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(TRANSITIVE_PROPERTY_COMPARE)
|
|
|
|
false)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<TARGET_PROPERTY:...> expression in link libraries "
|
|
|
|
"evaluation depends on target property which is transitive "
|
|
|
|
"over the link libraries, creating a recursion.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
#undef TRANSITIVE_PROPERTY_COMPARE
|
|
|
|
|
2013-02-12 14:29:09 +04:00
|
|
|
if(!prop)
|
|
|
|
{
|
|
|
|
return std::string();
|
|
|
|
}
|
2013-01-19 14:21:14 +04:00
|
|
|
}
|
2013-02-12 14:29:09 +04:00
|
|
|
else
|
2013-01-19 14:21:14 +04:00
|
|
|
{
|
2013-06-10 18:01:59 +04:00
|
|
|
#define ASSERT_TRANSITIVE_PROPERTY_METHOD(METHOD) \
|
|
|
|
dagCheckerParent->METHOD () ||
|
|
|
|
|
|
|
|
assert(
|
|
|
|
CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(
|
|
|
|
ASSERT_TRANSITIVE_PROPERTY_METHOD)
|
|
|
|
false);
|
2013-12-31 17:34:16 +04:00
|
|
|
#undef ASSERT_TRANSITIVE_PROPERTY_METHOD
|
2014-07-15 23:19:44 +04:00
|
|
|
}
|
2013-02-13 15:35:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string linkedTargetsContent;
|
|
|
|
|
|
|
|
std::string interfacePropertyName;
|
2014-07-15 23:18:05 +04:00
|
|
|
bool isInterfaceProperty = false;
|
2013-02-12 14:29:09 +04:00
|
|
|
|
2013-10-25 17:55:40 +04:00
|
|
|
#define POPULATE_INTERFACE_PROPERTY_NAME(prop) \
|
2014-07-15 23:18:05 +04:00
|
|
|
if (propertyName == #prop) \
|
2013-10-25 17:55:40 +04:00
|
|
|
{ \
|
|
|
|
interfacePropertyName = "INTERFACE_" #prop; \
|
|
|
|
} \
|
2014-07-15 23:18:05 +04:00
|
|
|
else if (propertyName == "INTERFACE_" #prop) \
|
|
|
|
{ \
|
|
|
|
interfacePropertyName = "INTERFACE_" #prop; \
|
|
|
|
isInterfaceProperty = true; \
|
|
|
|
} \
|
2013-10-25 17:55:40 +04:00
|
|
|
else
|
|
|
|
|
|
|
|
CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(POPULATE_INTERFACE_PROPERTY_NAME)
|
|
|
|
// Note that the above macro terminates with an else
|
2013-11-20 05:12:00 +04:00
|
|
|
/* else */ if (cmHasLiteralPrefix(propertyName.c_str(),
|
|
|
|
"COMPILE_DEFINITIONS_"))
|
2013-02-13 15:35:31 +04:00
|
|
|
{
|
2013-12-30 16:33:02 +04:00
|
|
|
cmPolicies::PolicyStatus polSt =
|
|
|
|
context->Makefile->GetPolicyStatus(cmPolicies::CMP0043);
|
|
|
|
if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD)
|
|
|
|
{
|
|
|
|
interfacePropertyName = "INTERFACE_COMPILE_DEFINITIONS";
|
|
|
|
}
|
2013-02-13 15:35:31 +04:00
|
|
|
}
|
2013-10-25 17:55:40 +04:00
|
|
|
#undef POPULATE_INTERFACE_PROPERTY_NAME
|
2014-08-06 17:51:08 +04:00
|
|
|
cmTarget const* headTarget = context->HeadTarget && isInterfaceProperty
|
2013-10-30 01:21:20 +04:00
|
|
|
? context->HeadTarget : target;
|
2013-06-04 01:53:29 +04:00
|
|
|
|
2014-07-15 23:18:05 +04:00
|
|
|
if(isInterfaceProperty)
|
2013-02-13 15:35:31 +04:00
|
|
|
{
|
2014-07-15 19:42:43 +04:00
|
|
|
if(cmTarget::LinkInterfaceLibraries const* iface =
|
|
|
|
target->GetLinkInterfaceLibraries(context->Config, headTarget, true))
|
|
|
|
{
|
2013-05-29 02:34:30 +04:00
|
|
|
linkedTargetsContent =
|
2014-07-15 19:50:32 +04:00
|
|
|
getLinkedTargetsContent(iface->Libraries, target,
|
|
|
|
headTarget,
|
|
|
|
context, &dagChecker,
|
|
|
|
interfacePropertyName);
|
2013-02-12 14:29:09 +04:00
|
|
|
}
|
|
|
|
}
|
2014-07-15 23:18:05 +04:00
|
|
|
else if(!interfacePropertyName.empty())
|
GenexEval: Fix evaluation of INCLUDE_DIRECTORIES target property.
This property should come from the content of the property itself,
plus the INTERFACE_INCLUDE_DIRECTORIES of the link *implementation*.
In contrast, when the INTERFACE_INCLUDE_DIRECTORIES is evaluated for
a target, the INTERFACE_INCLUDE_DIRECTORIES of the link *interface*
is used.
Similar logic applies for the COMPILE_DEFINITIONS target properties.
If the propertyName is already an INTERFACE_ variant of the property,
ie, the expression is similar to
$<TARGET_PROPERTY:foo,INTERFACE_INCLUDE_DIRECTORIES>
then the INTERFACE_INCLUDE_DIRECTORIES of the link *interface* of foo
is used.
However, if the propertyName is not an INTERFACE_ variant, and the
interfacePropertyName is, ie, the expression is similar to:
$<TARGET_PROPERTY:foo,INCLUDE_DIRECTORIES>
then the INTERFACE_INCLUDE_DIRECTORIES of the link *implementation*
of foo is used.
2013-05-30 17:30:24 +04:00
|
|
|
{
|
2014-07-15 23:19:44 +04:00
|
|
|
if(cmTarget::LinkImplementationLibraries const* impl =
|
|
|
|
target->GetLinkImplementationLibraries(context->Config))
|
GenexEval: Fix evaluation of INCLUDE_DIRECTORIES target property.
This property should come from the content of the property itself,
plus the INTERFACE_INCLUDE_DIRECTORIES of the link *implementation*.
In contrast, when the INTERFACE_INCLUDE_DIRECTORIES is evaluated for
a target, the INTERFACE_INCLUDE_DIRECTORIES of the link *interface*
is used.
Similar logic applies for the COMPILE_DEFINITIONS target properties.
If the propertyName is already an INTERFACE_ variant of the property,
ie, the expression is similar to
$<TARGET_PROPERTY:foo,INTERFACE_INCLUDE_DIRECTORIES>
then the INTERFACE_INCLUDE_DIRECTORIES of the link *interface* of foo
is used.
However, if the propertyName is not an INTERFACE_ variant, and the
interfacePropertyName is, ie, the expression is similar to:
$<TARGET_PROPERTY:foo,INCLUDE_DIRECTORIES>
then the INTERFACE_INCLUDE_DIRECTORIES of the link *implementation*
of foo is used.
2013-05-30 17:30:24 +04:00
|
|
|
{
|
|
|
|
linkedTargetsContent =
|
2014-07-15 23:18:05 +04:00
|
|
|
getLinkedTargetsContent(impl->Libraries, target,
|
2014-08-06 17:51:08 +04:00
|
|
|
target,
|
2014-07-15 23:18:05 +04:00
|
|
|
context, &dagChecker,
|
|
|
|
interfacePropertyName);
|
2013-02-12 14:29:09 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!prop)
|
|
|
|
{
|
2013-11-20 15:44:04 +04:00
|
|
|
if (target->IsImported()
|
|
|
|
|| target->GetType() == cmTarget::INTERFACE_LIBRARY)
|
2013-02-12 14:29:09 +04:00
|
|
|
{
|
|
|
|
return linkedTargetsContent;
|
2013-01-19 14:21:14 +04:00
|
|
|
}
|
|
|
|
if (target->IsLinkInterfaceDependentBoolProperty(propertyName,
|
|
|
|
context->Config))
|
|
|
|
{
|
2013-02-03 10:33:15 +04:00
|
|
|
context->HadContextSensitiveCondition = true;
|
2013-01-19 14:21:14 +04:00
|
|
|
return target->GetLinkInterfaceDependentBoolProperty(
|
|
|
|
propertyName,
|
|
|
|
context->Config) ? "1" : "0";
|
|
|
|
}
|
2013-01-06 16:49:20 +04:00
|
|
|
if (target->IsLinkInterfaceDependentStringProperty(propertyName,
|
|
|
|
context->Config))
|
|
|
|
{
|
2013-02-03 10:33:15 +04:00
|
|
|
context->HadContextSensitiveCondition = true;
|
2013-01-31 14:18:49 +04:00
|
|
|
const char *propContent =
|
|
|
|
target->GetLinkInterfaceDependentStringProperty(
|
2013-01-06 16:49:20 +04:00
|
|
|
propertyName,
|
|
|
|
context->Config);
|
2013-01-31 14:18:49 +04:00
|
|
|
return propContent ? propContent : "";
|
2013-01-06 16:49:20 +04:00
|
|
|
}
|
cmTarget: Add interface for compatible numeric properties
When using the boost MPL library, one can set a define to increase
the limit of how many variadic elements should be supported. The
default for BOOST_MPL_LIMIT_VECTOR_SIZE is 20:
http://www.boost.org/doc/libs/1_36_0/libs/mpl/doc/refmanual/limit-vector-size.html
If the foo library requires that to be set to 30, and the independent
bar library requires it to be set to 40, consumers of both need to set
it to 40.
add_library(foo INTERFACE)
set_property(TARGET foo PROPERTY INTERFACE_boost_mpl_vector_size 30)
set_property(TARGET foo PROPERTY COMPATIBLE_INTERFACE_NUMBER_MAX boost_mpl_vector_size)
target_compile_definitions(foo INTERFACE BOOST_MPL_LIMIT_VECTOR_SIZE=$<TARGET_PROPERTY:boost_mpl_vector_size>)
add_library(bar INTERFACE)
set_property(TARGET bar PROPERTY INTERFACE_boost_mpl_vector_size 40)
# Technically the next two lines are redundant, but as foo and bar are
# independent, they both set these interfaces.
set_property(TARGET bar PROPERTY COMPATIBLE_INTERFACE_NUMBER_MAX boost_mpl_vector_size)
target_compile_definitions(bar INTERFACE BOOST_MPL_LIMIT_VECTOR_SIZE=$<TARGET_PROPERTY:boost_mpl_vector_size>)
add_executable(user)
target_link_libraries(user foo bar)
Because the TARGET_PROPERTY reads the boost_mpl_vector_size property
from the HEAD of the dependency graph (the user target), and because
that property appears in the COMPATIBLE_INTERFACE_NUMBER_MAX of
the dependencies of the user target, the maximum value for it is
chosen for the compile definition, ie, 40.
There are also use-cases for choosing the minimum value of a number.
In Qt, deprecated API can be disabled by version. Setting the
definition QT_DISABLE_DEPRECATED_BEFORE=0 disables no deprecated
API. Setting it to 0x501000 disables API which was deprecated before
Qt 5.1 etc.
If two dependencies require the use of API which was deprecated in
different Qt versions, then COMPATIBLE_INTERFACE_NUMBER_MIN can be
used to ensure that both can compile.
2013-10-22 21:51:36 +04:00
|
|
|
if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName,
|
|
|
|
context->Config))
|
|
|
|
{
|
|
|
|
context->HadContextSensitiveCondition = true;
|
|
|
|
const char *propContent =
|
|
|
|
target->GetLinkInterfaceDependentNumberMinProperty(
|
|
|
|
propertyName,
|
|
|
|
context->Config);
|
|
|
|
return propContent ? propContent : "";
|
|
|
|
}
|
|
|
|
if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName,
|
|
|
|
context->Config))
|
|
|
|
{
|
|
|
|
context->HadContextSensitiveCondition = true;
|
|
|
|
const char *propContent =
|
|
|
|
target->GetLinkInterfaceDependentNumberMaxProperty(
|
|
|
|
propertyName,
|
|
|
|
context->Config);
|
|
|
|
return propContent ? propContent : "";
|
|
|
|
}
|
2013-01-19 14:21:14 +04:00
|
|
|
|
2013-02-12 14:29:09 +04:00
|
|
|
return linkedTargetsContent;
|
2012-09-23 15:45:17 +04:00
|
|
|
}
|
|
|
|
|
cmTarget: Add interface for compatible numeric properties
When using the boost MPL library, one can set a define to increase
the limit of how many variadic elements should be supported. The
default for BOOST_MPL_LIMIT_VECTOR_SIZE is 20:
http://www.boost.org/doc/libs/1_36_0/libs/mpl/doc/refmanual/limit-vector-size.html
If the foo library requires that to be set to 30, and the independent
bar library requires it to be set to 40, consumers of both need to set
it to 40.
add_library(foo INTERFACE)
set_property(TARGET foo PROPERTY INTERFACE_boost_mpl_vector_size 30)
set_property(TARGET foo PROPERTY COMPATIBLE_INTERFACE_NUMBER_MAX boost_mpl_vector_size)
target_compile_definitions(foo INTERFACE BOOST_MPL_LIMIT_VECTOR_SIZE=$<TARGET_PROPERTY:boost_mpl_vector_size>)
add_library(bar INTERFACE)
set_property(TARGET bar PROPERTY INTERFACE_boost_mpl_vector_size 40)
# Technically the next two lines are redundant, but as foo and bar are
# independent, they both set these interfaces.
set_property(TARGET bar PROPERTY COMPATIBLE_INTERFACE_NUMBER_MAX boost_mpl_vector_size)
target_compile_definitions(bar INTERFACE BOOST_MPL_LIMIT_VECTOR_SIZE=$<TARGET_PROPERTY:boost_mpl_vector_size>)
add_executable(user)
target_link_libraries(user foo bar)
Because the TARGET_PROPERTY reads the boost_mpl_vector_size property
from the HEAD of the dependency graph (the user target), and because
that property appears in the COMPATIBLE_INTERFACE_NUMBER_MAX of
the dependencies of the user target, the maximum value for it is
chosen for the compile definition, ie, 40.
There are also use-cases for choosing the minimum value of a number.
In Qt, deprecated API can be disabled by version. Setting the
definition QT_DISABLE_DEPRECATED_BEFORE=0 disables no deprecated
API. Setting it to 0x501000 disables API which was deprecated before
Qt 5.1 etc.
If two dependencies require the use of API which was deprecated in
different Qt versions, then COMPATIBLE_INTERFACE_NUMBER_MIN can be
used to ensure that both can compile.
2013-10-22 21:51:36 +04:00
|
|
|
if (!target->IsImported()
|
|
|
|
&& dagCheckerParent && !dagCheckerParent->EvaluatingLinkLibraries())
|
|
|
|
{
|
|
|
|
if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName,
|
|
|
|
context->Config))
|
|
|
|
{
|
|
|
|
context->HadContextSensitiveCondition = true;
|
|
|
|
const char *propContent =
|
|
|
|
target->GetLinkInterfaceDependentNumberMinProperty(
|
|
|
|
propertyName,
|
|
|
|
context->Config);
|
|
|
|
return propContent ? propContent : "";
|
|
|
|
}
|
|
|
|
if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName,
|
|
|
|
context->Config))
|
|
|
|
{
|
|
|
|
context->HadContextSensitiveCondition = true;
|
|
|
|
const char *propContent =
|
|
|
|
target->GetLinkInterfaceDependentNumberMaxProperty(
|
|
|
|
propertyName,
|
|
|
|
context->Config);
|
|
|
|
return propContent ? propContent : "";
|
|
|
|
}
|
|
|
|
}
|
2014-07-15 23:18:05 +04:00
|
|
|
if(!interfacePropertyName.empty())
|
2012-09-23 15:45:17 +04:00
|
|
|
{
|
2014-11-26 23:29:05 +03:00
|
|
|
std::string result = this->EvaluateDependentExpression(prop,
|
|
|
|
context->Makefile, context,
|
|
|
|
headTarget, target, &dagChecker);
|
2014-07-15 23:18:05 +04:00
|
|
|
if (!linkedTargetsContent.empty())
|
|
|
|
{
|
|
|
|
result += (result.empty() ? "" : ";") + linkedTargetsContent;
|
2012-09-23 15:45:17 +04:00
|
|
|
}
|
2014-07-15 23:18:05 +04:00
|
|
|
return result;
|
2012-09-23 15:45:17 +04:00
|
|
|
}
|
|
|
|
return prop;
|
2012-09-12 06:23:31 +04:00
|
|
|
}
|
|
|
|
} targetPropertyNode;
|
|
|
|
|
2012-12-10 14:33:23 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct TargetNameNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
TargetNameNode() {}
|
|
|
|
|
|
|
|
virtual bool GeneratesContent() const { return true; }
|
|
|
|
|
2013-04-25 15:28:57 +04:00
|
|
|
virtual bool AcceptsArbitraryContentParameter() const { return true; }
|
2012-12-10 14:33:23 +04:00
|
|
|
virtual bool RequiresLiteralInput() const { return true; }
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *,
|
|
|
|
const GeneratorExpressionContent *,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
|
|
|
{
|
|
|
|
return parameters.front();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual int NumExpectedParameters() const { return 1; }
|
|
|
|
|
|
|
|
} targetNameNode;
|
|
|
|
|
2014-02-26 18:59:18 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct TargetObjectsNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
TargetObjectsNode() {}
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *content,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
|
|
|
{
|
2014-03-20 18:37:12 +04:00
|
|
|
if (!context->EvaluateForBuildsystem)
|
|
|
|
{
|
|
|
|
cmOStringStream e;
|
|
|
|
e << "The evaluation of the TARGET_OBJECTS generator expression "
|
|
|
|
"is only suitable for consumption by CMake. It is not suitable "
|
|
|
|
"for writing out elsewhere.";
|
|
|
|
reportError(context, content->GetOriginalExpression(), e.str());
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
2014-02-26 18:59:18 +04:00
|
|
|
std::string tgtName = parameters.front();
|
|
|
|
cmGeneratorTarget* gt =
|
|
|
|
context->Makefile->FindGeneratorTargetToUse(tgtName.c_str());
|
|
|
|
if (!gt)
|
|
|
|
{
|
|
|
|
cmOStringStream e;
|
|
|
|
e << "Objects of target \"" << tgtName
|
|
|
|
<< "\" referenced but no such target exists.";
|
|
|
|
reportError(context, content->GetOriginalExpression(), e.str());
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
if (gt->GetType() != cmTarget::OBJECT_LIBRARY)
|
|
|
|
{
|
|
|
|
cmOStringStream e;
|
|
|
|
e << "Objects of target \"" << tgtName
|
|
|
|
<< "\" referenced but is not an OBJECT library.";
|
|
|
|
reportError(context, content->GetOriginalExpression(), e.str());
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<cmSourceFile const*> objectSources;
|
2014-02-13 20:25:00 +04:00
|
|
|
gt->GetObjectSources(objectSources, context->Config);
|
2014-02-26 18:59:18 +04:00
|
|
|
std::map<cmSourceFile const*, std::string> mapping;
|
|
|
|
|
|
|
|
for(std::vector<cmSourceFile const*>::const_iterator it
|
|
|
|
= objectSources.begin(); it != objectSources.end(); ++it)
|
|
|
|
{
|
|
|
|
mapping[*it];
|
|
|
|
}
|
|
|
|
|
|
|
|
gt->LocalGenerator->ComputeObjectFilenames(mapping, gt);
|
|
|
|
|
|
|
|
std::string obj_dir = gt->ObjectDirectory;
|
|
|
|
std::string result;
|
|
|
|
const char* sep = "";
|
2014-11-07 06:56:50 +03:00
|
|
|
for(std::vector<cmSourceFile const*>::const_iterator it
|
|
|
|
= objectSources.begin(); it != objectSources.end(); ++it)
|
2014-02-26 18:59:18 +04:00
|
|
|
{
|
2014-11-07 06:56:50 +03:00
|
|
|
// Find the object file name corresponding to this source file.
|
|
|
|
std::map<cmSourceFile const*, std::string>::const_iterator
|
|
|
|
map_it = mapping.find(*it);
|
|
|
|
// It must exist because we populated the mapping just above.
|
|
|
|
assert(!map_it->second.empty());
|
2014-02-26 18:59:18 +04:00
|
|
|
result += sep;
|
2014-11-07 06:56:50 +03:00
|
|
|
std::string objFile = obj_dir + map_it->second;
|
2014-02-26 18:59:18 +04:00
|
|
|
cmSourceFile* sf = context->Makefile->GetOrCreateSource(objFile, true);
|
|
|
|
sf->SetObjectLibrary(tgtName);
|
|
|
|
sf->SetProperty("EXTERNAL_OBJECT", "1");
|
|
|
|
result += objFile;
|
|
|
|
sep = ";";
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
} targetObjectsNode;
|
|
|
|
|
2014-05-15 13:32:30 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
CompileFeaturesNode() {}
|
|
|
|
|
|
|
|
virtual int NumExpectedParameters() const { return OneOrMoreParameters; }
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *content,
|
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker) const
|
|
|
|
{
|
|
|
|
cmTarget const* target = context->HeadTarget;
|
|
|
|
if (!target)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<COMPILE_FEATURE> may only be used with binary targets. It may "
|
|
|
|
"not be used with add_custom_command or add_custom_target.");
|
|
|
|
return std::string();
|
|
|
|
}
|
2014-07-21 21:02:22 +04:00
|
|
|
context->HadHeadSensitiveCondition = true;
|
2014-05-15 13:32:30 +04:00
|
|
|
|
|
|
|
typedef std::map<std::string, std::vector<std::string> > LangMap;
|
|
|
|
static LangMap availableFeatures;
|
|
|
|
|
|
|
|
LangMap testedFeatures;
|
|
|
|
|
|
|
|
for (std::vector<std::string>::const_iterator it = parameters.begin();
|
|
|
|
it != parameters.end(); ++it)
|
|
|
|
{
|
|
|
|
std::string error;
|
|
|
|
std::string lang;
|
|
|
|
if (!context->Makefile->CompileFeatureKnown(context->HeadTarget,
|
|
|
|
*it, lang, &error))
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(), error);
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
testedFeatures[lang].push_back(*it);
|
|
|
|
|
|
|
|
if (availableFeatures.find(lang) == availableFeatures.end())
|
|
|
|
{
|
|
|
|
const char* featuresKnown
|
|
|
|
= context->Makefile->CompileFeaturesAvailable(lang, &error);
|
|
|
|
if (!featuresKnown)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(), error);
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
cmSystemTools::ExpandListArgument(featuresKnown,
|
|
|
|
availableFeatures[lang]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool evalLL = dagChecker && dagChecker->EvaluatingLinkLibraries();
|
|
|
|
|
|
|
|
std::string result;
|
|
|
|
|
|
|
|
for (LangMap::const_iterator lit = testedFeatures.begin();
|
|
|
|
lit != testedFeatures.end(); ++lit)
|
|
|
|
{
|
|
|
|
for (std::vector<std::string>::const_iterator it = lit->second.begin();
|
|
|
|
it != lit->second.end(); ++it)
|
|
|
|
{
|
|
|
|
if (!context->Makefile->HaveFeatureAvailable(target,
|
|
|
|
lit->first, *it))
|
|
|
|
{
|
|
|
|
if (evalLL)
|
|
|
|
{
|
|
|
|
const char* l = target->GetProperty(lit->first + "_STANDARD");
|
|
|
|
if (!l)
|
|
|
|
{
|
|
|
|
l = context->Makefile
|
|
|
|
->GetDefinition("CMAKE_" + lit->first + "_STANDARD_DEFAULT");
|
|
|
|
}
|
|
|
|
assert(l);
|
|
|
|
context->MaxLanguageStandard[target][lit->first] = l;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return "0";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "1";
|
|
|
|
}
|
|
|
|
} compileFeaturesNode;
|
|
|
|
|
2013-01-16 19:42:39 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const char* targetPolicyWhitelist[] = {
|
2013-06-28 13:25:40 +04:00
|
|
|
0
|
|
|
|
#define TARGET_POLICY_STRING(POLICY) \
|
|
|
|
, #POLICY
|
|
|
|
|
|
|
|
CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_STRING)
|
|
|
|
|
|
|
|
#undef TARGET_POLICY_STRING
|
2013-01-16 19:42:39 +04:00
|
|
|
};
|
|
|
|
|
2013-10-30 01:21:20 +04:00
|
|
|
cmPolicies::PolicyStatus statusForTarget(cmTarget const* tgt,
|
|
|
|
const char *policy)
|
2013-01-16 19:42:39 +04:00
|
|
|
{
|
|
|
|
#define RETURN_POLICY(POLICY) \
|
|
|
|
if (strcmp(policy, #POLICY) == 0) \
|
|
|
|
{ \
|
|
|
|
return tgt->GetPolicyStatus ## POLICY (); \
|
|
|
|
} \
|
|
|
|
|
2013-06-28 13:25:40 +04:00
|
|
|
CM_FOR_EACH_TARGET_POLICY(RETURN_POLICY)
|
2013-01-16 19:42:39 +04:00
|
|
|
|
|
|
|
#undef RETURN_POLICY
|
|
|
|
|
|
|
|
assert("!Unreachable code. Not a valid policy");
|
|
|
|
return cmPolicies::WARN;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmPolicies::PolicyID policyForString(const char *policy_id)
|
|
|
|
{
|
|
|
|
#define RETURN_POLICY_ID(POLICY_ID) \
|
|
|
|
if (strcmp(policy_id, #POLICY_ID) == 0) \
|
|
|
|
{ \
|
|
|
|
return cmPolicies:: POLICY_ID; \
|
|
|
|
} \
|
|
|
|
|
2013-06-28 13:25:40 +04:00
|
|
|
CM_FOR_EACH_TARGET_POLICY(RETURN_POLICY_ID)
|
2013-01-16 19:42:39 +04:00
|
|
|
|
|
|
|
#undef RETURN_POLICY_ID
|
|
|
|
|
|
|
|
assert("!Unreachable code. Not a valid policy");
|
|
|
|
return cmPolicies::CMP0002;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct TargetPolicyNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
TargetPolicyNode() {}
|
|
|
|
|
|
|
|
virtual int NumExpectedParameters() const { return 1; }
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *context ,
|
|
|
|
const GeneratorExpressionContent *content,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
|
|
|
{
|
|
|
|
if (!context->HeadTarget)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
2014-05-29 00:02:57 +04:00
|
|
|
"$<TARGET_POLICY:prop> may only be used with binary targets. It "
|
|
|
|
"may not be used with add_custom_command or add_custom_target.");
|
2013-01-16 19:42:39 +04:00
|
|
|
return std::string();
|
|
|
|
}
|
2013-02-03 10:33:15 +04:00
|
|
|
|
|
|
|
context->HadContextSensitiveCondition = true;
|
2014-07-21 21:02:22 +04:00
|
|
|
context->HadHeadSensitiveCondition = true;
|
2013-02-03 10:33:15 +04:00
|
|
|
|
2013-10-22 03:14:03 +04:00
|
|
|
for (size_t i = 1; i < cmArraySize(targetPolicyWhitelist); ++i)
|
2013-01-16 19:42:39 +04:00
|
|
|
{
|
|
|
|
const char *policy = targetPolicyWhitelist[i];
|
|
|
|
if (parameters.front() == policy)
|
|
|
|
{
|
|
|
|
cmMakefile *mf = context->HeadTarget->GetMakefile();
|
|
|
|
switch(statusForTarget(context->HeadTarget, policy))
|
|
|
|
{
|
|
|
|
case cmPolicies::WARN:
|
|
|
|
mf->IssueMessage(cmake::AUTHOR_WARNING,
|
|
|
|
mf->GetPolicies()->
|
|
|
|
GetPolicyWarning(policyForString(policy)));
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
case cmPolicies::OLD:
|
|
|
|
return "0";
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
return "1";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<TARGET_POLICY:prop> may only be used with a limited number of "
|
2013-06-28 13:25:40 +04:00
|
|
|
"policies. Currently it may be used with the following policies:\n"
|
|
|
|
|
|
|
|
#define STRINGIFY_HELPER(X) #X
|
|
|
|
#define STRINGIFY(X) STRINGIFY_HELPER(X)
|
|
|
|
|
|
|
|
#define TARGET_POLICY_LIST_ITEM(POLICY) \
|
|
|
|
" * " STRINGIFY(POLICY) "\n"
|
|
|
|
|
|
|
|
CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_LIST_ITEM)
|
|
|
|
|
|
|
|
#undef TARGET_POLICY_LIST_ITEM
|
2013-01-16 19:42:39 +04:00
|
|
|
);
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
|
|
|
} targetPolicyNode;
|
|
|
|
|
2013-01-27 12:43:44 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct InstallPrefixNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
InstallPrefixNode() {}
|
|
|
|
|
2013-01-30 20:49:47 +04:00
|
|
|
virtual bool GeneratesContent() const { return true; }
|
2013-01-27 12:43:44 +04:00
|
|
|
virtual int NumExpectedParameters() const { return 0; }
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> &,
|
2013-01-30 20:49:47 +04:00
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *content,
|
2013-01-27 12:43:44 +04:00
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
|
|
|
{
|
2013-01-30 20:49:47 +04:00
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"INSTALL_PREFIX is a marker for install(EXPORT) only. It "
|
|
|
|
"should never be evaluated.");
|
2013-01-27 12:43:44 +04:00
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
|
|
|
} installPrefixNode;
|
|
|
|
|
2012-09-11 21:53:38 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2014-07-24 23:36:21 +04:00
|
|
|
class ArtifactNameTag;
|
|
|
|
class ArtifactLinkerTag;
|
|
|
|
class ArtifactSonameTag;
|
2014-07-25 00:18:21 +04:00
|
|
|
class ArtifactPdbTag;
|
2014-07-24 23:36:21 +04:00
|
|
|
|
|
|
|
class ArtifactPathTag;
|
|
|
|
class ArtifactDirTag;
|
|
|
|
class ArtifactNameTag;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
template<typename ArtifactT>
|
2012-09-11 21:53:38 +04:00
|
|
|
struct TargetFilesystemArtifactResultCreator
|
|
|
|
{
|
|
|
|
static std::string Create(cmTarget* target,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *content);
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
template<>
|
2014-07-24 23:36:21 +04:00
|
|
|
struct TargetFilesystemArtifactResultCreator<ArtifactSonameTag>
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
|
|
|
static std::string Create(cmTarget* target,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *content)
|
|
|
|
{
|
|
|
|
// The target soname file (.so.1).
|
|
|
|
if(target->IsDLLPlatform())
|
|
|
|
{
|
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"TARGET_SONAME_FILE is not allowed "
|
|
|
|
"for DLL target platforms.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
if(target->GetType() != cmTarget::SHARED_LIBRARY)
|
|
|
|
{
|
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"TARGET_SONAME_FILE is allowed only for "
|
|
|
|
"SHARED libraries.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
std::string result = target->GetDirectory(context->Config);
|
|
|
|
result += "/";
|
|
|
|
result += target->GetSOName(context->Config);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
template<>
|
2014-07-25 00:18:21 +04:00
|
|
|
struct TargetFilesystemArtifactResultCreator<ArtifactPdbTag>
|
|
|
|
{
|
|
|
|
static std::string Create(cmTarget* target,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *content)
|
|
|
|
{
|
|
|
|
std::string language = target->GetLinkerLanguage(context->Config);
|
|
|
|
|
|
|
|
std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB";
|
|
|
|
|
|
|
|
if(!context->Makefile->IsOn(pdbSupportVar))
|
|
|
|
{
|
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"TARGET_PDB_FILE is not supported by the target linker.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
|
|
|
cmTarget::TargetType targetType = target->GetType();
|
|
|
|
|
|
|
|
if(targetType != cmTarget::SHARED_LIBRARY &&
|
|
|
|
targetType != cmTarget::MODULE_LIBRARY &&
|
|
|
|
targetType != cmTarget::EXECUTABLE)
|
|
|
|
{
|
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"TARGET_PDB_FILE is allowed only for "
|
|
|
|
"targets with linker created artifacts.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string result = target->GetPDBDirectory(context->Config);
|
|
|
|
result += "/";
|
|
|
|
result += target->GetPDBName(context->Config);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-09-11 21:53:38 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
template<>
|
2014-07-24 23:36:21 +04:00
|
|
|
struct TargetFilesystemArtifactResultCreator<ArtifactLinkerTag>
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
|
|
|
static std::string Create(cmTarget* target,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *content)
|
|
|
|
{
|
|
|
|
// The file used to link to the target (.so, .lib, .a).
|
|
|
|
if(!target->IsLinkable())
|
|
|
|
{
|
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"TARGET_LINKER_FILE is allowed only for libraries and "
|
|
|
|
"executables with ENABLE_EXPORTS.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
return target->GetFullPath(context->Config,
|
|
|
|
target->HasImportLibrary());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
template<>
|
2014-07-24 23:36:21 +04:00
|
|
|
struct TargetFilesystemArtifactResultCreator<ArtifactNameTag>
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
|
|
|
static std::string Create(cmTarget* target,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *)
|
|
|
|
{
|
|
|
|
return target->GetFullPath(context->Config, false, true);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2014-07-24 23:36:21 +04:00
|
|
|
template<typename ArtifactT>
|
2012-09-11 21:53:38 +04:00
|
|
|
struct TargetFilesystemArtifactResultGetter
|
|
|
|
{
|
|
|
|
static std::string Get(const std::string &result);
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
template<>
|
2014-07-24 23:36:21 +04:00
|
|
|
struct TargetFilesystemArtifactResultGetter<ArtifactNameTag>
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
|
|
|
static std::string Get(const std::string &result)
|
|
|
|
{ return cmSystemTools::GetFilenameName(result); }
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
template<>
|
2014-07-24 23:36:21 +04:00
|
|
|
struct TargetFilesystemArtifactResultGetter<ArtifactDirTag>
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
|
|
|
static std::string Get(const std::string &result)
|
|
|
|
{ return cmSystemTools::GetFilenamePath(result); }
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
template<>
|
2014-07-24 23:36:21 +04:00
|
|
|
struct TargetFilesystemArtifactResultGetter<ArtifactPathTag>
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
|
|
|
static std::string Get(const std::string &result)
|
|
|
|
{ return result; }
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
2014-07-24 23:36:21 +04:00
|
|
|
template<typename ArtifactT, typename ComponentT>
|
2012-09-11 21:53:38 +04:00
|
|
|
struct TargetFilesystemArtifact : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
TargetFilesystemArtifact() {}
|
|
|
|
|
|
|
|
virtual int NumExpectedParameters() const { return 1; }
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *context,
|
2012-09-18 15:42:23 +04:00
|
|
|
const GeneratorExpressionContent *content,
|
2013-06-14 18:25:29 +04:00
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker) const
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
|
|
|
// Lookup the referenced target.
|
|
|
|
std::string name = *parameters.begin();
|
|
|
|
|
2013-02-06 16:32:15 +04:00
|
|
|
if (!cmGeneratorExpression::IsValidTargetName(name))
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Expression syntax not recognized.");
|
|
|
|
return std::string();
|
|
|
|
}
|
2014-01-16 02:56:38 +04:00
|
|
|
cmTarget* target = context->Makefile->FindTargetToUse(name);
|
2012-09-11 21:53:38 +04:00
|
|
|
if(!target)
|
|
|
|
{
|
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"No target \"" + name + "\"");
|
|
|
|
return std::string();
|
|
|
|
}
|
2013-11-01 18:14:47 +04:00
|
|
|
if(target->GetType() >= cmTarget::OBJECT_LIBRARY &&
|
2012-09-11 21:53:38 +04:00
|
|
|
target->GetType() != cmTarget::UNKNOWN_LIBRARY)
|
|
|
|
{
|
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Target \"" + name + "\" is not an executable or library.");
|
|
|
|
return std::string();
|
|
|
|
}
|
2014-02-13 23:52:21 +04:00
|
|
|
if (dagChecker && (dagChecker->EvaluatingLinkLibraries(name.c_str())
|
|
|
|
|| (dagChecker->EvaluatingSources()
|
|
|
|
&& name == dagChecker->TopTarget())))
|
2013-06-14 18:25:29 +04:00
|
|
|
{
|
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Expressions which require the linker language may not "
|
|
|
|
"be used while evaluating link libraries");
|
|
|
|
return std::string();
|
|
|
|
}
|
2013-02-09 14:12:20 +04:00
|
|
|
context->DependTargets.insert(target);
|
|
|
|
context->AllTargets.insert(target);
|
2012-09-11 21:53:38 +04:00
|
|
|
|
|
|
|
std::string result =
|
2014-07-24 23:36:21 +04:00
|
|
|
TargetFilesystemArtifactResultCreator<ArtifactT>::Create(
|
2012-09-11 21:53:38 +04:00
|
|
|
target,
|
|
|
|
context,
|
|
|
|
content);
|
|
|
|
if (context->HadError)
|
|
|
|
{
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
return
|
2014-07-24 23:36:21 +04:00
|
|
|
TargetFilesystemArtifactResultGetter<ComponentT>::Get(result);
|
2012-09-11 21:53:38 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-07-24 23:36:21 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
template<typename ArtifactT>
|
|
|
|
struct TargetFilesystemArtifactNodeGroup
|
|
|
|
{
|
|
|
|
TargetFilesystemArtifactNodeGroup()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TargetFilesystemArtifact<ArtifactT, ArtifactPathTag> File;
|
|
|
|
TargetFilesystemArtifact<ArtifactT, ArtifactNameTag> FileName;
|
|
|
|
TargetFilesystemArtifact<ArtifactT, ArtifactDirTag> FileDir;
|
|
|
|
};
|
|
|
|
|
2012-09-11 21:53:38 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const
|
2014-07-24 23:36:21 +04:00
|
|
|
TargetFilesystemArtifactNodeGroup<ArtifactNameTag> targetNodeGroup;
|
|
|
|
|
2012-09-11 21:53:38 +04:00
|
|
|
static const
|
2014-07-24 23:36:21 +04:00
|
|
|
TargetFilesystemArtifactNodeGroup<ArtifactLinkerTag> targetLinkerNodeGroup;
|
|
|
|
|
2012-09-11 21:53:38 +04:00
|
|
|
static const
|
2014-07-24 23:36:21 +04:00
|
|
|
TargetFilesystemArtifactNodeGroup<ArtifactSonameTag> targetSoNameNodeGroup;
|
2012-09-11 21:53:38 +04:00
|
|
|
|
|
|
|
static const
|
2014-07-25 00:18:21 +04:00
|
|
|
TargetFilesystemArtifactNodeGroup<ArtifactPdbTag> targetPdbNodeGroup;
|
2012-09-11 21:53:38 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const
|
|
|
|
cmGeneratorExpressionNode* GetNode(const std::string &identifier)
|
|
|
|
{
|
2014-02-06 22:59:50 +04:00
|
|
|
typedef std::map<std::string, const cmGeneratorExpressionNode*> NodeMap;
|
|
|
|
static NodeMap nodeMap;
|
|
|
|
if (nodeMap.empty())
|
|
|
|
{
|
|
|
|
nodeMap["0"] = &zeroNode;
|
|
|
|
nodeMap["1"] = &oneNode;
|
|
|
|
nodeMap["AND"] = &andNode;
|
|
|
|
nodeMap["OR"] = &orNode;
|
|
|
|
nodeMap["NOT"] = ¬Node;
|
|
|
|
nodeMap["C_COMPILER_ID"] = &cCompilerIdNode;
|
|
|
|
nodeMap["CXX_COMPILER_ID"] = &cxxCompilerIdNode;
|
|
|
|
nodeMap["VERSION_GREATER"] = &versionGreaterNode;
|
|
|
|
nodeMap["VERSION_LESS"] = &versionLessNode;
|
|
|
|
nodeMap["VERSION_EQUAL"] = &versionEqualNode;
|
|
|
|
nodeMap["C_COMPILER_VERSION"] = &cCompilerVersionNode;
|
|
|
|
nodeMap["CXX_COMPILER_VERSION"] = &cxxCompilerVersionNode;
|
|
|
|
nodeMap["PLATFORM_ID"] = &platformIdNode;
|
2014-05-15 13:32:30 +04:00
|
|
|
nodeMap["COMPILE_FEATURES"] = &compileFeaturesNode;
|
2014-02-06 22:59:50 +04:00
|
|
|
nodeMap["CONFIGURATION"] = &configurationNode;
|
|
|
|
nodeMap["CONFIG"] = &configurationTestNode;
|
2014-07-24 23:36:21 +04:00
|
|
|
nodeMap["TARGET_FILE"] = &targetNodeGroup.File;
|
|
|
|
nodeMap["TARGET_LINKER_FILE"] = &targetLinkerNodeGroup.File;
|
|
|
|
nodeMap["TARGET_SONAME_FILE"] = &targetSoNameNodeGroup.File;
|
2014-07-25 00:18:21 +04:00
|
|
|
nodeMap["TARGET_PDB_FILE"] = &targetPdbNodeGroup.File;
|
2014-07-24 23:36:21 +04:00
|
|
|
nodeMap["TARGET_FILE_NAME"] = &targetNodeGroup.FileName;
|
|
|
|
nodeMap["TARGET_LINKER_FILE_NAME"] = &targetLinkerNodeGroup.FileName;
|
|
|
|
nodeMap["TARGET_SONAME_FILE_NAME"] = &targetSoNameNodeGroup.FileName;
|
2014-07-25 00:18:21 +04:00
|
|
|
nodeMap["TARGET_PDB_FILE_NAME"] = &targetPdbNodeGroup.FileName;
|
2014-07-24 23:36:21 +04:00
|
|
|
nodeMap["TARGET_FILE_DIR"] = &targetNodeGroup.FileDir;
|
|
|
|
nodeMap["TARGET_LINKER_FILE_DIR"] = &targetLinkerNodeGroup.FileDir;
|
|
|
|
nodeMap["TARGET_SONAME_FILE_DIR"] = &targetSoNameNodeGroup.FileDir;
|
2014-07-25 00:18:21 +04:00
|
|
|
nodeMap["TARGET_PDB_FILE_DIR"] = &targetPdbNodeGroup.FileDir;
|
2014-02-06 22:59:50 +04:00
|
|
|
nodeMap["STREQUAL"] = &strEqualNode;
|
|
|
|
nodeMap["EQUAL"] = &equalNode;
|
|
|
|
nodeMap["LOWER_CASE"] = &lowerCaseNode;
|
|
|
|
nodeMap["UPPER_CASE"] = &upperCaseNode;
|
|
|
|
nodeMap["MAKE_C_IDENTIFIER"] = &makeCIdentifierNode;
|
|
|
|
nodeMap["BOOL"] = &boolNode;
|
|
|
|
nodeMap["ANGLE-R"] = &angle_rNode;
|
|
|
|
nodeMap["COMMA"] = &commaNode;
|
|
|
|
nodeMap["SEMICOLON"] = &semicolonNode;
|
|
|
|
nodeMap["TARGET_PROPERTY"] = &targetPropertyNode;
|
|
|
|
nodeMap["TARGET_NAME"] = &targetNameNode;
|
2014-02-26 18:59:18 +04:00
|
|
|
nodeMap["TARGET_OBJECTS"] = &targetObjectsNode;
|
2014-02-06 22:59:50 +04:00
|
|
|
nodeMap["TARGET_POLICY"] = &targetPolicyNode;
|
|
|
|
nodeMap["BUILD_INTERFACE"] = &buildInterfaceNode;
|
|
|
|
nodeMap["INSTALL_INTERFACE"] = &installInterfaceNode;
|
|
|
|
nodeMap["INSTALL_PREFIX"] = &installPrefixNode;
|
|
|
|
nodeMap["JOIN"] = &joinNode;
|
|
|
|
nodeMap["LINK_ONLY"] = &linkOnlyNode;
|
|
|
|
}
|
|
|
|
NodeMap::const_iterator i = nodeMap.find(identifier);
|
|
|
|
if (i == nodeMap.end())
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return i->second;
|
2012-09-12 06:23:31 +04:00
|
|
|
|
2012-09-11 21:53:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
GeneratorExpressionContent::GeneratorExpressionContent(
|
|
|
|
const char *startContent,
|
2013-10-21 21:18:16 +04:00
|
|
|
size_t length)
|
2012-09-11 21:53:38 +04:00
|
|
|
: StartContent(startContent), ContentLength(length)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string GeneratorExpressionContent::GetOriginalExpression() const
|
|
|
|
{
|
|
|
|
return std::string(this->StartContent, this->ContentLength);
|
|
|
|
}
|
|
|
|
|
2013-04-25 15:54:18 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string GeneratorExpressionContent::ProcessArbitraryContent(
|
|
|
|
const cmGeneratorExpressionNode *node,
|
|
|
|
const std::string &identifier,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker,
|
|
|
|
std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
|
|
|
|
pit) const
|
|
|
|
{
|
|
|
|
std::string result;
|
|
|
|
|
|
|
|
const
|
|
|
|
std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
|
|
|
|
pend = this->ParamChildren.end();
|
|
|
|
for ( ; pit != pend; ++pit)
|
|
|
|
{
|
|
|
|
std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it
|
|
|
|
= pit->begin();
|
|
|
|
const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
|
|
|
|
= pit->end();
|
|
|
|
for ( ; it != end; ++it)
|
|
|
|
{
|
|
|
|
if (node->RequiresLiteralInput())
|
|
|
|
{
|
|
|
|
if ((*it)->GetType() != cmGeneratorExpressionEvaluator::Text)
|
|
|
|
{
|
|
|
|
reportError(context, this->GetOriginalExpression(),
|
|
|
|
"$<" + identifier + "> expression requires literal input.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
result += (*it)->Evaluate(context, dagChecker);
|
|
|
|
if (context->HadError)
|
|
|
|
{
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((pit + 1) != pend)
|
|
|
|
{
|
|
|
|
result += ",";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (node->RequiresLiteralInput())
|
|
|
|
{
|
|
|
|
std::vector<std::string> parameters;
|
|
|
|
parameters.push_back(result);
|
|
|
|
return node->Evaluate(parameters, context, this, dagChecker);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-09-11 21:53:38 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string GeneratorExpressionContent::Evaluate(
|
2012-09-18 15:42:23 +04:00
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker) const
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
|
|
|
std::string identifier;
|
|
|
|
{
|
|
|
|
std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it
|
|
|
|
= this->IdentifierChildren.begin();
|
|
|
|
const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
|
|
|
|
= this->IdentifierChildren.end();
|
|
|
|
for ( ; it != end; ++it)
|
|
|
|
{
|
2012-09-18 15:42:23 +04:00
|
|
|
identifier += (*it)->Evaluate(context, dagChecker);
|
2012-09-11 21:53:38 +04:00
|
|
|
if (context->HadError)
|
|
|
|
{
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const cmGeneratorExpressionNode *node = GetNode(identifier);
|
|
|
|
|
|
|
|
if (!node)
|
|
|
|
{
|
|
|
|
reportError(context, this->GetOriginalExpression(),
|
|
|
|
"Expression did not evaluate to a known generator expression");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!node->GeneratesContent())
|
|
|
|
{
|
2013-04-25 15:28:57 +04:00
|
|
|
if (node->NumExpectedParameters() == 1
|
|
|
|
&& node->AcceptsArbitraryContentParameter())
|
2012-11-27 01:43:13 +04:00
|
|
|
{
|
|
|
|
if (this->ParamChildren.empty())
|
|
|
|
{
|
|
|
|
reportError(context, this->GetOriginalExpression(),
|
|
|
|
"$<" + identifier + "> expression requires a parameter.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::vector<std::string> parameters;
|
|
|
|
this->EvaluateParameters(node, identifier, context, dagChecker,
|
|
|
|
parameters);
|
|
|
|
}
|
2012-09-11 21:53:38 +04:00
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<std::string> parameters;
|
2012-11-27 01:42:00 +04:00
|
|
|
this->EvaluateParameters(node, identifier, context, dagChecker, parameters);
|
|
|
|
if (context->HadError)
|
|
|
|
{
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
|
|
|
return node->Evaluate(parameters, context, this, dagChecker);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
std::string GeneratorExpressionContent::EvaluateParameters(
|
|
|
|
const cmGeneratorExpressionNode *node,
|
|
|
|
const std::string &identifier,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker,
|
|
|
|
std::vector<std::string> ¶meters) const
|
|
|
|
{
|
2013-04-25 15:54:57 +04:00
|
|
|
const int numExpected = node->NumExpectedParameters();
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
|
|
|
std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
|
|
|
|
pit = this->ParamChildren.begin();
|
|
|
|
const
|
|
|
|
std::vector<std::vector<cmGeneratorExpressionEvaluator*> >::const_iterator
|
|
|
|
pend = this->ParamChildren.end();
|
2013-04-25 15:54:57 +04:00
|
|
|
const bool acceptsArbitraryContent
|
|
|
|
= node->AcceptsArbitraryContentParameter();
|
2013-12-18 03:32:35 +04:00
|
|
|
int counter = 1;
|
|
|
|
for ( ; pit != pend; ++pit, ++counter)
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
2013-12-18 03:32:35 +04:00
|
|
|
if (acceptsArbitraryContent && counter == numExpected)
|
2013-04-25 15:54:57 +04:00
|
|
|
{
|
|
|
|
std::string lastParam = this->ProcessArbitraryContent(node, identifier,
|
|
|
|
context,
|
|
|
|
dagChecker,
|
2013-12-18 03:32:35 +04:00
|
|
|
pit);
|
2013-04-25 15:54:57 +04:00
|
|
|
parameters.push_back(lastParam);
|
|
|
|
return std::string();
|
|
|
|
}
|
2013-12-18 03:32:35 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
std::string parameter;
|
|
|
|
std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
|
|
|
|
pit->begin();
|
|
|
|
const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
|
|
|
|
pit->end();
|
|
|
|
for ( ; it != end; ++it)
|
|
|
|
{
|
|
|
|
parameter += (*it)->Evaluate(context, dagChecker);
|
|
|
|
if (context->HadError)
|
|
|
|
{
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
parameters.push_back(parameter);
|
|
|
|
}
|
2012-09-11 21:53:38 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-16 17:52:25 +04:00
|
|
|
if ((numExpected > cmGeneratorExpressionNode::DynamicParameters
|
|
|
|
&& (unsigned int)numExpected != parameters.size()))
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
|
|
|
if (numExpected == 0)
|
|
|
|
{
|
|
|
|
reportError(context, this->GetOriginalExpression(),
|
|
|
|
"$<" + identifier + "> expression requires no parameters.");
|
|
|
|
}
|
|
|
|
else if (numExpected == 1)
|
|
|
|
{
|
|
|
|
reportError(context, this->GetOriginalExpression(),
|
|
|
|
"$<" + identifier + "> expression requires "
|
|
|
|
"exactly one parameter.");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cmOStringStream e;
|
|
|
|
e << "$<" + identifier + "> expression requires "
|
|
|
|
<< numExpected
|
|
|
|
<< " comma separated parameters, but got "
|
|
|
|
<< parameters.size() << " instead.";
|
|
|
|
reportError(context, this->GetOriginalExpression(), e.str());
|
|
|
|
}
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
2013-05-16 17:52:25 +04:00
|
|
|
if (numExpected == cmGeneratorExpressionNode::OneOrMoreParameters
|
|
|
|
&& parameters.empty())
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
|
|
|
reportError(context, this->GetOriginalExpression(), "$<" + identifier
|
|
|
|
+ "> expression requires at least one parameter.");
|
|
|
|
}
|
2013-12-31 17:28:52 +04:00
|
|
|
if (numExpected == cmGeneratorExpressionNode::OneOrZeroParameters
|
2013-12-31 18:57:25 +04:00
|
|
|
&& parameters.size() > 1)
|
2013-12-31 17:28:52 +04:00
|
|
|
{
|
|
|
|
reportError(context, this->GetOriginalExpression(), "$<" + identifier
|
|
|
|
+ "> expression requires one or zero parameters.");
|
|
|
|
}
|
2012-11-27 01:42:00 +04:00
|
|
|
return std::string();
|
2012-09-11 21:53:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static void deleteAll(const std::vector<cmGeneratorExpressionEvaluator*> &c)
|
|
|
|
{
|
|
|
|
std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it
|
|
|
|
= c.begin();
|
|
|
|
const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
|
|
|
|
= c.end();
|
|
|
|
for ( ; it != end; ++it)
|
|
|
|
{
|
|
|
|
delete *it;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
GeneratorExpressionContent::~GeneratorExpressionContent()
|
|
|
|
{
|
|
|
|
deleteAll(this->IdentifierChildren);
|
|
|
|
|
|
|
|
typedef std::vector<cmGeneratorExpressionEvaluator*> EvaluatorVector;
|
|
|
|
std::vector<EvaluatorVector>::const_iterator pit =
|
|
|
|
this->ParamChildren.begin();
|
|
|
|
const std::vector<EvaluatorVector>::const_iterator pend =
|
|
|
|
this->ParamChildren.end();
|
|
|
|
for ( ; pit != pend; ++pit)
|
|
|
|
{
|
|
|
|
deleteAll(*pit);
|
|
|
|
}
|
|
|
|
}
|