2016-09-27 19:01:08 +00:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2015-02-22 22:32:11 +00:00
|
|
|
#include "cmGeneratorExpressionNode.h"
|
2016-04-29 13:40:20 +00:00
|
|
|
|
2015-02-22 22:32:11 +00:00
|
|
|
#include "cmAlgorithms.h"
|
2016-09-01 18:59:28 +00:00
|
|
|
#include "cmGeneratorExpression.h"
|
|
|
|
#include "cmGeneratorExpressionContext.h"
|
|
|
|
#include "cmGeneratorExpressionDAGChecker.h"
|
|
|
|
#include "cmGeneratorExpressionEvaluator.h"
|
|
|
|
#include "cmGeneratorTarget.h"
|
2016-04-29 14:53:13 +00:00
|
|
|
#include "cmGlobalGenerator.h"
|
2016-09-01 18:59:28 +00:00
|
|
|
#include "cmLinkItem.h"
|
|
|
|
#include "cmLocalGenerator.h"
|
2015-10-10 16:27:44 +00:00
|
|
|
#include "cmMakefile.h"
|
2016-04-29 14:53:13 +00:00
|
|
|
#include "cmOutputConverter.h"
|
2016-09-01 18:59:28 +00:00
|
|
|
#include "cmPolicies.h"
|
2016-10-18 19:28:48 +00:00
|
|
|
#include "cmStateTypes.h"
|
2016-09-01 18:59:28 +00:00
|
|
|
#include "cmSystemTools.h"
|
|
|
|
#include "cmTarget.h"
|
|
|
|
#include "cm_auto_ptr.hxx"
|
|
|
|
#include "cmake.h"
|
|
|
|
|
2017-04-11 20:00:21 +00:00
|
|
|
#include "cmsys/RegularExpression.hxx"
|
|
|
|
#include "cmsys/String.h"
|
2016-09-01 18:59:28 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
#include <sstream>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <utility>
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string const& prop, cmLocalGenerator* lg,
|
|
|
|
cmGeneratorExpressionContext* context, cmGeneratorTarget const* headTarget,
|
|
|
|
cmGeneratorTarget const* currentTarget,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker)
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
2015-07-08 21:52:51 +00:00
|
|
|
cmGeneratorExpression ge(context->Backtrace);
|
2016-06-28 14:17:52 +00:00
|
|
|
CM_AUTO_PTR<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
|
2015-02-22 22:32:11 +00:00
|
|
|
cge->SetEvaluateForBuildsystem(context->EvaluateForBuildsystem);
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string result =
|
|
|
|
cge->Evaluate(lg, context->Config, context->Quiet, headTarget,
|
|
|
|
currentTarget, dagChecker, context->Language);
|
|
|
|
if (cge->GetHadContextSensitiveCondition()) {
|
2015-02-22 22:32:11 +00:00
|
|
|
context->HadContextSensitiveCondition = true;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (cge->GetHadHeadSensitiveCondition()) {
|
2015-02-22 22:32:11 +00:00
|
|
|
context->HadHeadSensitiveCondition = true;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ZeroNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
ZeroNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
bool GeneratesContent() const CM_OVERRIDE { return false; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
bool AcceptsArbitraryContentParameter() const CM_OVERRIDE { return true; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-08-16 23:49:57 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& /*parameters*/,
|
|
|
|
cmGeneratorExpressionContext* /*context*/,
|
|
|
|
const GeneratorExpressionContent* /*content*/,
|
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
} zeroNode;
|
|
|
|
|
|
|
|
static const struct OneNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
OneNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
bool AcceptsArbitraryContentParameter() const CM_OVERRIDE { return true; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionContext* /*context*/,
|
|
|
|
const GeneratorExpressionContent* /*content*/,
|
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
return parameters.front();
|
|
|
|
}
|
|
|
|
} oneNode;
|
|
|
|
|
|
|
|
static const struct OneNode buildInterfaceNode;
|
|
|
|
|
|
|
|
static const struct ZeroNode installInterfaceNode;
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
#define BOOLEAN_OP_NODE(OPNAME, OP, SUCCESS_VALUE, FAILURE_VALUE) \
|
|
|
|
static const struct OP##Node : public cmGeneratorExpressionNode \
|
|
|
|
{ \
|
|
|
|
OP##Node() {} \
|
|
|
|
virtual int NumExpectedParameters() const { return OneOrMoreParameters; } \
|
|
|
|
\
|
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters, \
|
|
|
|
cmGeneratorExpressionContext* context, \
|
|
|
|
const GeneratorExpressionContent* content, \
|
|
|
|
cmGeneratorExpressionDAGChecker*) const \
|
|
|
|
{ \
|
|
|
|
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; \
|
2016-08-18 18:36:29 +00:00
|
|
|
} \
|
|
|
|
if (*it != #SUCCESS_VALUE) { \
|
2016-05-16 14:34:04 +00:00
|
|
|
reportError(context, content->GetOriginalExpression(), \
|
|
|
|
"Parameters to $<" #OP \
|
|
|
|
"> must resolve to either '0' or '1'."); \
|
|
|
|
return std::string(); \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
return #SUCCESS_VALUE; \
|
|
|
|
} \
|
|
|
|
} OPNAME;
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
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() {}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (*parameters.begin() != "0" && *parameters.begin() != "1") {
|
|
|
|
reportError(
|
|
|
|
context, content->GetOriginalExpression(),
|
|
|
|
"$<NOT> parameter must resolve to exactly one '0' or '1' value.");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
return *parameters.begin() == "0" ? "1" : "0";
|
|
|
|
}
|
|
|
|
} notNode;
|
|
|
|
|
|
|
|
static const struct BoolNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
BoolNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return 1; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionContext* /*context*/,
|
|
|
|
const GeneratorExpressionContent* /*content*/,
|
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
return !cmSystemTools::IsOff(parameters.begin()->c_str()) ? "1" : "0";
|
|
|
|
}
|
|
|
|
} boolNode;
|
|
|
|
|
2017-01-24 03:14:03 +00:00
|
|
|
static const struct IfNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
IfNode() {}
|
|
|
|
|
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return 3; }
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content,
|
|
|
|
cmGeneratorExpressionDAGChecker*) const CM_OVERRIDE
|
|
|
|
{
|
|
|
|
if (parameters[0] != "1" && parameters[0] != "0") {
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"First parameter to $<IF> must resolve to exactly one '0' "
|
|
|
|
"or '1' value.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
return parameters[0] == "1" ? parameters[1] : parameters[2];
|
|
|
|
}
|
|
|
|
} ifNode;
|
|
|
|
|
2015-02-22 22:32:11 +00:00
|
|
|
static const struct StrEqualNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
StrEqualNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return 2; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionContext* /*context*/,
|
|
|
|
const GeneratorExpressionContent* /*content*/,
|
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
return *parameters.begin() == parameters[1] ? "1" : "0";
|
|
|
|
}
|
|
|
|
} strEqualNode;
|
|
|
|
|
|
|
|
static const struct EqualNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
EqualNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return 2; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
char* pEnd;
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
int base = 0;
|
|
|
|
bool flipSign = false;
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
const char* lhs = parameters[0].c_str();
|
|
|
|
if (cmHasLiteralPrefix(lhs, "0b") || cmHasLiteralPrefix(lhs, "0B")) {
|
2015-02-22 22:32:11 +00:00
|
|
|
base = 2;
|
|
|
|
lhs += 2;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (cmHasLiteralPrefix(lhs, "-0b") || cmHasLiteralPrefix(lhs, "-0B")) {
|
2015-02-22 22:32:11 +00:00
|
|
|
base = 2;
|
|
|
|
lhs += 3;
|
|
|
|
flipSign = true;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (cmHasLiteralPrefix(lhs, "+0b") || cmHasLiteralPrefix(lhs, "+0B")) {
|
2015-02-22 22:32:11 +00:00
|
|
|
base = 2;
|
|
|
|
lhs += 3;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
long lnum = strtol(lhs, &pEnd, base);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) {
|
2015-02-22 22:32:11 +00:00
|
|
|
reportError(context, content->GetOriginalExpression(),
|
2016-05-16 14:34:04 +00:00
|
|
|
"$<EQUAL> parameter " + parameters[0] +
|
|
|
|
" is not a valid integer.");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (flipSign) {
|
2015-02-22 22:32:11 +00:00
|
|
|
lnum = -lnum;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
base = 0;
|
|
|
|
flipSign = false;
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
const char* rhs = parameters[1].c_str();
|
|
|
|
if (cmHasLiteralPrefix(rhs, "0b") || cmHasLiteralPrefix(rhs, "0B")) {
|
2015-02-22 22:32:11 +00:00
|
|
|
base = 2;
|
|
|
|
rhs += 2;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (cmHasLiteralPrefix(rhs, "-0b") || cmHasLiteralPrefix(rhs, "-0B")) {
|
2015-02-22 22:32:11 +00:00
|
|
|
base = 2;
|
|
|
|
rhs += 3;
|
|
|
|
flipSign = true;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (cmHasLiteralPrefix(rhs, "+0b") || cmHasLiteralPrefix(rhs, "+0B")) {
|
2015-02-22 22:32:11 +00:00
|
|
|
base = 2;
|
|
|
|
rhs += 3;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
long rnum = strtol(rhs, &pEnd, base);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) {
|
2015-02-22 22:32:11 +00:00
|
|
|
reportError(context, content->GetOriginalExpression(),
|
2016-05-16 14:34:04 +00:00
|
|
|
"$<EQUAL> parameter " + parameters[1] +
|
|
|
|
" is not a valid integer.");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (flipSign) {
|
2015-02-22 22:32:11 +00:00
|
|
|
rnum = -rnum;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
return lnum == rnum ? "1" : "0";
|
|
|
|
}
|
|
|
|
} equalNode;
|
|
|
|
|
|
|
|
static const struct LowerCaseNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
LowerCaseNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
bool AcceptsArbitraryContentParameter() const CM_OVERRIDE { return true; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionContext* /*context*/,
|
|
|
|
const GeneratorExpressionContent* /*content*/,
|
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
return cmSystemTools::LowerCase(parameters.front());
|
|
|
|
}
|
|
|
|
} lowerCaseNode;
|
|
|
|
|
|
|
|
static const struct UpperCaseNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
UpperCaseNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
bool AcceptsArbitraryContentParameter() const CM_OVERRIDE { return true; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionContext* /*context*/,
|
|
|
|
const GeneratorExpressionContent* /*content*/,
|
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
return cmSystemTools::UpperCase(parameters.front());
|
|
|
|
}
|
|
|
|
} upperCaseNode;
|
|
|
|
|
|
|
|
static const struct MakeCIdentifierNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
MakeCIdentifierNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
bool AcceptsArbitraryContentParameter() const CM_OVERRIDE { return true; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionContext* /*context*/,
|
|
|
|
const GeneratorExpressionContent* /*content*/,
|
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
return cmSystemTools::MakeCidentifier(parameters.front());
|
|
|
|
}
|
|
|
|
} makeCIdentifierNode;
|
|
|
|
|
|
|
|
static const struct Angle_RNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
Angle_RNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return 0; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-08-16 23:49:57 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& /*parameters*/,
|
|
|
|
cmGeneratorExpressionContext* /*context*/,
|
|
|
|
const GeneratorExpressionContent* /*content*/,
|
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
return ">";
|
|
|
|
}
|
|
|
|
} angle_rNode;
|
|
|
|
|
|
|
|
static const struct CommaNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
CommaNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return 0; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-08-16 23:49:57 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& /*parameters*/,
|
|
|
|
cmGeneratorExpressionContext* /*context*/,
|
|
|
|
const GeneratorExpressionContent* /*content*/,
|
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
return ",";
|
|
|
|
}
|
|
|
|
} commaNode;
|
|
|
|
|
|
|
|
static const struct SemicolonNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
SemicolonNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return 0; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-08-16 23:49:57 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& /*parameters*/,
|
|
|
|
cmGeneratorExpressionContext* /*context*/,
|
|
|
|
const GeneratorExpressionContent* /*content*/,
|
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
return ";";
|
|
|
|
}
|
|
|
|
} semicolonNode;
|
|
|
|
|
|
|
|
struct CompilerIdNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
CompilerIdNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return OneOrZeroParameters; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string EvaluateWithLanguage(const std::vector<std::string>& parameters,
|
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionDAGChecker* /*unused*/,
|
2016-05-16 14:34:04 +00:00
|
|
|
const std::string& lang) const
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
const char* compilerId = context->LG->GetMakefile()->GetSafeDefinition(
|
|
|
|
"CMAKE_" + lang + "_COMPILER_ID");
|
|
|
|
if (parameters.empty()) {
|
2015-02-22 22:32:11 +00:00
|
|
|
return compilerId ? compilerId : "";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
static cmsys::RegularExpression compilerIdValidator("^[A-Za-z0-9_]*$");
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!compilerIdValidator.find(*parameters.begin())) {
|
2015-02-22 22:32:11 +00:00
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Expression syntax not recognized.");
|
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (!compilerId) {
|
2015-02-22 22:32:11 +00:00
|
|
|
return parameters.front().empty() ? "1" : "0";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (strcmp(parameters.begin()->c_str(), compilerId) == 0) {
|
2015-02-22 22:32:11 +00:00
|
|
|
return "1";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (cmsysString_strcasecmp(parameters.begin()->c_str(), compilerId) == 0) {
|
|
|
|
switch (context->LG->GetPolicyStatus(cmPolicies::CMP0044)) {
|
|
|
|
case cmPolicies::WARN: {
|
2015-02-22 22:32:11 +00:00
|
|
|
std::ostringstream e;
|
2015-05-03 08:12:10 +00:00
|
|
|
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0044);
|
2016-05-16 14:34:04 +00:00
|
|
|
context->LG->GetCMakeInstance()->IssueMessage(
|
|
|
|
cmake::AUTHOR_WARNING, e.str(), context->Backtrace);
|
2017-06-02 18:32:58 +00:00
|
|
|
CM_FALLTHROUGH;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
case cmPolicies::OLD:
|
|
|
|
return "1";
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
break;
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
return "0";
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct CCompilerIdNode : public CompilerIdNode
|
|
|
|
{
|
|
|
|
CCompilerIdNode() {}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker) const
|
2016-06-22 23:02:39 +00:00
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!context->HeadTarget) {
|
|
|
|
reportError(
|
|
|
|
context, content->GetOriginalExpression(),
|
|
|
|
"$<C_COMPILER_ID> may only be used with binary targets. It may "
|
|
|
|
"not be used with add_custom_command or add_custom_target.");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
return this->EvaluateWithLanguage(parameters, context, content, dagChecker,
|
|
|
|
"C");
|
2015-02-22 22:32:11 +00:00
|
|
|
}
|
|
|
|
} cCompilerIdNode;
|
|
|
|
|
|
|
|
static const struct CXXCompilerIdNode : public CompilerIdNode
|
|
|
|
{
|
|
|
|
CXXCompilerIdNode() {}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker) const
|
2016-06-22 23:02:39 +00:00
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!context->HeadTarget) {
|
|
|
|
reportError(
|
|
|
|
context, content->GetOriginalExpression(),
|
|
|
|
"$<CXX_COMPILER_ID> may only be used with binary targets. It may "
|
|
|
|
"not be used with add_custom_command or add_custom_target.");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
return this->EvaluateWithLanguage(parameters, context, content, dagChecker,
|
|
|
|
"CXX");
|
2015-02-22 22:32:11 +00:00
|
|
|
}
|
|
|
|
} cxxCompilerIdNode;
|
|
|
|
|
|
|
|
struct CompilerVersionNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
CompilerVersionNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return OneOrZeroParameters; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string EvaluateWithLanguage(const std::vector<std::string>& parameters,
|
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionDAGChecker* /*unused*/,
|
2016-05-16 14:34:04 +00:00
|
|
|
const std::string& lang) const
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
const char* compilerVersion =
|
|
|
|
context->LG->GetMakefile()->GetSafeDefinition("CMAKE_" + lang +
|
|
|
|
"_COMPILER_VERSION");
|
|
|
|
if (parameters.empty()) {
|
2015-02-22 22:32:11 +00:00
|
|
|
return compilerVersion ? compilerVersion : "";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
static cmsys::RegularExpression compilerIdValidator("^[0-9\\.]*$");
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!compilerIdValidator.find(*parameters.begin())) {
|
2015-02-22 22:32:11 +00:00
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Expression syntax not recognized.");
|
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (!compilerVersion) {
|
2015-02-22 22:32:11 +00:00
|
|
|
return parameters.front().empty() ? "1" : "0";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
|
2016-05-16 14:34:04 +00:00
|
|
|
parameters.begin()->c_str(),
|
|
|
|
compilerVersion)
|
|
|
|
? "1"
|
|
|
|
: "0";
|
2015-02-22 22:32:11 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct CCompilerVersionNode : public CompilerVersionNode
|
|
|
|
{
|
|
|
|
CCompilerVersionNode() {}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker) const
|
2016-06-22 23:02:39 +00:00
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!context->HeadTarget) {
|
|
|
|
reportError(
|
|
|
|
context, content->GetOriginalExpression(),
|
|
|
|
"$<C_COMPILER_VERSION> may only be used with binary targets. It "
|
|
|
|
"may not be used with add_custom_command or add_custom_target.");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
return this->EvaluateWithLanguage(parameters, context, content, dagChecker,
|
|
|
|
"C");
|
2015-02-22 22:32:11 +00:00
|
|
|
}
|
|
|
|
} cCompilerVersionNode;
|
|
|
|
|
|
|
|
static const struct CxxCompilerVersionNode : public CompilerVersionNode
|
|
|
|
{
|
|
|
|
CxxCompilerVersionNode() {}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker) const
|
2016-06-22 23:02:39 +00:00
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!context->HeadTarget) {
|
|
|
|
reportError(
|
|
|
|
context, content->GetOriginalExpression(),
|
|
|
|
"$<CXX_COMPILER_VERSION> may only be used with binary targets. It "
|
|
|
|
"may not be used with add_custom_command or add_custom_target.");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
return this->EvaluateWithLanguage(parameters, context, content, dagChecker,
|
|
|
|
"CXX");
|
2015-02-22 22:32:11 +00:00
|
|
|
}
|
|
|
|
} cxxCompilerVersionNode;
|
|
|
|
|
|
|
|
struct PlatformIdNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
PlatformIdNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return OneOrZeroParameters; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
|
|
|
cmGeneratorExpressionContext* context,
|
2016-08-16 23:49:57 +00:00
|
|
|
const GeneratorExpressionContent* /*content*/,
|
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
const char* platformId =
|
2015-07-25 14:56:52 +00:00
|
|
|
context->LG->GetMakefile()->GetSafeDefinition("CMAKE_SYSTEM_NAME");
|
2016-05-16 14:34:04 +00:00
|
|
|
if (parameters.empty()) {
|
2015-02-22 22:32:11 +00:00
|
|
|
return platformId ? platformId : "";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!platformId) {
|
2015-02-22 22:32:11 +00:00
|
|
|
return parameters.front().empty() ? "1" : "0";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (strcmp(parameters.begin()->c_str(), platformId) == 0) {
|
2015-02-22 22:32:11 +00:00
|
|
|
return "1";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
return "0";
|
|
|
|
}
|
|
|
|
} platformIdNode;
|
|
|
|
|
|
|
|
static const struct VersionGreaterNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
VersionGreaterNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return 2; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionContext* /*context*/,
|
|
|
|
const GeneratorExpressionContent* /*content*/,
|
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER,
|
|
|
|
parameters.front().c_str(),
|
2016-05-16 14:34:04 +00:00
|
|
|
parameters[1].c_str())
|
|
|
|
? "1"
|
|
|
|
: "0";
|
2015-02-22 22:32:11 +00:00
|
|
|
}
|
|
|
|
} versionGreaterNode;
|
|
|
|
|
2016-08-05 18:11:46 +00:00
|
|
|
static const struct VersionGreaterEqNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
VersionGreaterEqNode() {}
|
|
|
|
|
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return 2; }
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionContext* /*context*/,
|
|
|
|
const GeneratorExpressionContent* /*content*/,
|
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2016-08-05 18:11:46 +00:00
|
|
|
{
|
|
|
|
return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER_EQUAL,
|
|
|
|
parameters.front().c_str(),
|
|
|
|
parameters[1].c_str())
|
|
|
|
? "1"
|
|
|
|
: "0";
|
|
|
|
}
|
|
|
|
} versionGreaterEqNode;
|
|
|
|
|
2015-02-22 22:32:11 +00:00
|
|
|
static const struct VersionLessNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
VersionLessNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return 2; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionContext* /*context*/,
|
|
|
|
const GeneratorExpressionContent* /*content*/,
|
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
|
|
|
|
parameters.front().c_str(),
|
2016-05-16 14:34:04 +00:00
|
|
|
parameters[1].c_str())
|
|
|
|
? "1"
|
|
|
|
: "0";
|
2015-02-22 22:32:11 +00:00
|
|
|
}
|
|
|
|
} versionLessNode;
|
|
|
|
|
2016-08-05 18:11:46 +00:00
|
|
|
static const struct VersionLessEqNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
VersionLessEqNode() {}
|
|
|
|
|
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return 2; }
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionContext* /*context*/,
|
|
|
|
const GeneratorExpressionContent* /*content*/,
|
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2016-08-05 18:11:46 +00:00
|
|
|
{
|
|
|
|
return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS_EQUAL,
|
|
|
|
parameters.front().c_str(),
|
|
|
|
parameters[1].c_str())
|
|
|
|
? "1"
|
|
|
|
: "0";
|
|
|
|
}
|
|
|
|
} versionLessEqNode;
|
|
|
|
|
2015-02-22 22:32:11 +00:00
|
|
|
static const struct VersionEqualNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
VersionEqualNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return 2; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionContext* /*context*/,
|
|
|
|
const GeneratorExpressionContent* /*content*/,
|
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
|
|
|
|
parameters.front().c_str(),
|
2016-05-16 14:34:04 +00:00
|
|
|
parameters[1].c_str())
|
|
|
|
? "1"
|
|
|
|
: "0";
|
2015-02-22 22:32:11 +00:00
|
|
|
}
|
|
|
|
} versionEqualNode;
|
|
|
|
|
|
|
|
static const struct LinkOnlyNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
LinkOnlyNode() {}
|
|
|
|
|
2016-08-16 23:49:57 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
2016-09-05 13:04:30 +00:00
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
2016-09-05 13:04:30 +00:00
|
|
|
if (!dagChecker) {
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<LINK_ONLY:...> may only be used for linking");
|
|
|
|
return std::string();
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!dagChecker->GetTransitivePropertiesOnly()) {
|
2015-02-22 22:32:11 +00:00
|
|
|
return parameters.front();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2016-09-05 13:04:30 +00:00
|
|
|
return std::string();
|
2015-02-22 22:32:11 +00:00
|
|
|
}
|
|
|
|
} linkOnlyNode;
|
|
|
|
|
|
|
|
static const struct ConfigurationNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
ConfigurationNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return 0; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-08-16 23:49:57 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& /*parameters*/,
|
2016-05-16 14:34:04 +00:00
|
|
|
cmGeneratorExpressionContext* context,
|
2016-08-16 23:49:57 +00:00
|
|
|
const GeneratorExpressionContent* /*content*/,
|
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
context->HadContextSensitiveCondition = true;
|
|
|
|
return context->Config;
|
|
|
|
}
|
|
|
|
} configurationNode;
|
|
|
|
|
|
|
|
static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
ConfigurationTestNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return OneOrZeroParameters; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (parameters.empty()) {
|
2017-08-22 21:42:36 +00:00
|
|
|
return configurationNode.Evaluate(parameters, context, content, nullptr);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
static cmsys::RegularExpression configValidator("^[A-Za-z0-9_]*$");
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!configValidator.find(*parameters.begin())) {
|
2015-02-22 22:32:11 +00:00
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Expression syntax not recognized.");
|
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
context->HadContextSensitiveCondition = true;
|
2016-05-16 14:34:04 +00:00
|
|
|
if (context->Config.empty()) {
|
2015-02-22 22:32:11 +00:00
|
|
|
return parameters.front().empty() ? "1" : "0";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
if (cmsysString_strcasecmp(parameters.begin()->c_str(),
|
2016-05-16 14:34:04 +00:00
|
|
|
context->Config.c_str()) == 0) {
|
2015-02-22 22:32:11 +00:00
|
|
|
return "1";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (context->CurrentTarget && context->CurrentTarget->IsImported()) {
|
2017-08-22 21:42:36 +00:00
|
|
|
const char* loc = nullptr;
|
|
|
|
const char* imp = nullptr;
|
2015-02-22 22:32:11 +00:00
|
|
|
std::string suffix;
|
2016-05-16 14:34:04 +00:00
|
|
|
if (context->CurrentTarget->Target->GetMappedConfig(
|
|
|
|
context->Config, &loc, &imp, suffix)) {
|
2015-02-22 22:32:11 +00:00
|
|
|
// 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_";
|
|
|
|
mapProp += cmSystemTools::UpperCase(context->Config);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (const char* mapValue =
|
|
|
|
context->CurrentTarget->GetProperty(mapProp)) {
|
2015-02-22 22:32:11 +00:00
|
|
|
cmSystemTools::ExpandListArgument(cmSystemTools::UpperCase(mapValue),
|
|
|
|
mappedConfigs);
|
|
|
|
return std::find(mappedConfigs.begin(), mappedConfigs.end(),
|
2016-05-16 14:34:04 +00:00
|
|
|
cmSystemTools::UpperCase(parameters.front())) !=
|
|
|
|
mappedConfigs.end()
|
|
|
|
? "1"
|
|
|
|
: "0";
|
2015-02-22 22:32:11 +00:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
return "0";
|
|
|
|
}
|
|
|
|
} configurationTestNode;
|
|
|
|
|
|
|
|
static const struct JoinNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
JoinNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return 2; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
bool AcceptsArbitraryContentParameter() const CM_OVERRIDE { return true; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionContext* /*context*/,
|
|
|
|
const GeneratorExpressionContent* /*content*/,
|
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
std::vector<std::string> list;
|
|
|
|
cmSystemTools::ExpandListArgument(parameters.front(), list);
|
|
|
|
return cmJoin(list, parameters[1]);
|
|
|
|
}
|
|
|
|
} joinNode;
|
|
|
|
|
|
|
|
static const struct CompileLanguageNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
CompileLanguageNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return OneOrZeroParameters; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker) const
|
2016-06-22 23:02:39 +00:00
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (context->Language.empty()) {
|
|
|
|
reportError(
|
|
|
|
context, content->GetOriginalExpression(),
|
|
|
|
"$<COMPILE_LANGUAGE:...> may only be used to specify include "
|
2017-08-03 17:29:33 +00:00
|
|
|
"directories, compile definitions, compile options, and to evaluate "
|
2016-05-16 14:34:04 +00:00
|
|
|
"components of the file(GENERATE) command.");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
std::vector<std::string> enabledLanguages;
|
2015-07-25 14:56:52 +00:00
|
|
|
cmGlobalGenerator* gg = context->LG->GetGlobalGenerator();
|
2015-02-22 22:32:11 +00:00
|
|
|
gg->GetEnabledLanguages(enabledLanguages);
|
|
|
|
if (!parameters.empty() &&
|
2016-05-16 14:34:04 +00:00
|
|
|
std::find(enabledLanguages.begin(), enabledLanguages.end(),
|
|
|
|
parameters.front()) == enabledLanguages.end()) {
|
2015-02-22 22:32:11 +00:00
|
|
|
reportError(context, content->GetOriginalExpression(),
|
2016-05-16 14:34:04 +00:00
|
|
|
"$<COMPILE_LANGUAGE:...> Unknown language.");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
std::string genName = gg->GetName();
|
2016-05-16 14:34:04 +00:00
|
|
|
if (genName.find("Visual Studio") != std::string::npos) {
|
2015-02-22 22:32:11 +00:00
|
|
|
reportError(context, content->GetOriginalExpression(),
|
2016-05-16 14:34:04 +00:00
|
|
|
"$<COMPILE_LANGUAGE:...> may not be used with Visual Studio "
|
|
|
|
"generators.");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
2016-08-18 18:36:29 +00:00
|
|
|
}
|
|
|
|
if (genName.find("Xcode") != std::string::npos) {
|
2016-05-16 14:34:04 +00:00
|
|
|
if (dagChecker && (dagChecker->EvaluatingCompileDefinitions() ||
|
|
|
|
dagChecker->EvaluatingIncludeDirectories())) {
|
|
|
|
reportError(
|
|
|
|
context, content->GetOriginalExpression(),
|
|
|
|
"$<COMPILE_LANGUAGE:...> may only be used with COMPILE_OPTIONS "
|
|
|
|
"with the Xcode generator.");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
} else {
|
|
|
|
if (genName.find("Makefiles") == std::string::npos &&
|
|
|
|
genName.find("Ninja") == std::string::npos &&
|
|
|
|
genName.find("Watcom WMake") == std::string::npos) {
|
|
|
|
reportError(
|
|
|
|
context, content->GetOriginalExpression(),
|
|
|
|
"$<COMPILE_LANGUAGE:...> not supported for this generator.");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (parameters.empty()) {
|
2015-02-22 22:32:11 +00:00
|
|
|
return context->Language;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
return context->Language == parameters.front() ? "1" : "0";
|
|
|
|
}
|
|
|
|
} languageNode;
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
#define TRANSITIVE_PROPERTY_NAME(PROPERTY) , "INTERFACE_" #PROPERTY
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
static const char* targetPropertyTransitiveWhitelist[] = {
|
2017-08-22 21:42:36 +00:00
|
|
|
nullptr CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(TRANSITIVE_PROPERTY_NAME)
|
2015-02-22 22:32:11 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#undef TRANSITIVE_PROPERTY_NAME
|
|
|
|
|
|
|
|
template <typename T>
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string getLinkedTargetsContent(
|
|
|
|
std::vector<T> const& libraries, cmGeneratorTarget const* target,
|
|
|
|
cmGeneratorTarget const* headTarget, cmGeneratorExpressionContext* context,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker,
|
|
|
|
const std::string& interfacePropertyName)
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
std::string linkedTargetsContent;
|
|
|
|
std::string sep;
|
|
|
|
std::string depString;
|
|
|
|
for (typename std::vector<T>::const_iterator it = libraries.begin();
|
2016-05-16 14:34:04 +00:00
|
|
|
it != libraries.end(); ++it) {
|
2015-02-22 22:32:11 +00: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.
|
2016-05-16 14:34:04 +00:00
|
|
|
if (it->Target && it->Target != target) {
|
|
|
|
depString += sep + "$<TARGET_PROPERTY:" + it->Target->GetName() + "," +
|
|
|
|
interfacePropertyName + ">";
|
2015-02-22 22:32:11 +00:00
|
|
|
sep = ";";
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (!depString.empty()) {
|
2015-02-22 22:32:11 +00:00
|
|
|
linkedTargetsContent =
|
2016-05-16 14:34:04 +00:00
|
|
|
cmGeneratorExpressionNode::EvaluateDependentExpression(
|
|
|
|
depString, target->GetLocalGenerator(), context, headTarget, target,
|
|
|
|
dagChecker);
|
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
linkedTargetsContent =
|
|
|
|
cmGeneratorExpression::StripEmptyListElements(linkedTargetsContent);
|
|
|
|
return linkedTargetsContent;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct TargetPropertyNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
TargetPropertyNode() {}
|
|
|
|
|
|
|
|
// This node handles errors on parameter count itself.
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return OneOrMoreParameters; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagCheckerParent) const
|
2016-06-22 23:02:39 +00:00
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (parameters.size() != 1 && parameters.size() != 2) {
|
|
|
|
reportError(
|
|
|
|
context, content->GetOriginalExpression(),
|
|
|
|
"$<TARGET_PROPERTY:...> expression requires one or two parameters");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
static cmsys::RegularExpression propertyNameValidator("^[A-Za-z0-9_]+$");
|
|
|
|
|
2015-10-10 16:27:10 +00:00
|
|
|
cmGeneratorTarget const* target = context->HeadTarget;
|
2015-02-22 22:32:11 +00:00
|
|
|
std::string propertyName = *parameters.begin();
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (parameters.size() == 1) {
|
2015-02-22 22:32:11 +00:00
|
|
|
context->HadHeadSensitiveCondition = true;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (!target && parameters.size() == 1) {
|
|
|
|
reportError(
|
|
|
|
context, content->GetOriginalExpression(),
|
|
|
|
"$<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.");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (parameters.size() == 2) {
|
|
|
|
if (parameters.begin()->empty() && parameters[1].empty()) {
|
|
|
|
reportError(
|
|
|
|
context, content->GetOriginalExpression(),
|
|
|
|
"$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty "
|
|
|
|
"target name and property name.");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (parameters.begin()->empty()) {
|
|
|
|
reportError(
|
|
|
|
context, content->GetOriginalExpression(),
|
|
|
|
"$<TARGET_PROPERTY:tgt,prop> expression requires a non-empty "
|
|
|
|
"target name.");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
std::string targetName = parameters.front();
|
|
|
|
propertyName = parameters[1];
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!cmGeneratorExpression::IsValidTargetName(targetName)) {
|
|
|
|
if (!propertyNameValidator.find(propertyName.c_str())) {
|
2015-02-22 22:32:11 +00:00
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Target name and property name not supported.");
|
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Target name not supported.");
|
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (propertyName == "ALIASED_TARGET") {
|
|
|
|
if (context->LG->GetMakefile()->IsAlias(targetName)) {
|
|
|
|
if (cmGeneratorTarget* tgt =
|
|
|
|
context->LG->FindGeneratorTargetToUse(targetName)) {
|
2015-02-22 22:32:11 +00:00
|
|
|
return tgt->GetName();
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
return "";
|
|
|
|
}
|
2015-10-10 16:27:10 +00:00
|
|
|
target = context->LG->FindGeneratorTargetToUse(targetName);
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!target) {
|
2015-02-22 22:32:11 +00:00
|
|
|
std::ostringstream e;
|
2016-05-16 14:34:04 +00:00
|
|
|
e << "Target \"" << targetName << "\" not found.";
|
2015-02-22 22:32:11 +00:00
|
|
|
reportError(context, content->GetOriginalExpression(), e.str());
|
|
|
|
return std::string();
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
context->AllTargets.insert(target);
|
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (target == context->HeadTarget) {
|
2015-02-22 22:32:11 +00:00
|
|
|
// Keep track of the properties seen while processing.
|
|
|
|
// The evaluation of the LINK_LIBRARIES generator expressions
|
|
|
|
// will check this to ensure that properties have one consistent
|
|
|
|
// value for all evaluations.
|
|
|
|
context->SeenTargetProperties.insert(propertyName);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (propertyName == "SOURCES") {
|
2015-02-22 22:32:11 +00:00
|
|
|
context->SourceSensitiveTargets.insert(target);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (propertyName.empty()) {
|
|
|
|
reportError(
|
|
|
|
context, content->GetOriginalExpression(),
|
|
|
|
"$<TARGET_PROPERTY:...> expression requires a non-empty property "
|
|
|
|
"name.");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!propertyNameValidator.find(propertyName)) {
|
2015-02-22 22:32:11 +00:00
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Property name not supported.");
|
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
assert(target);
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (propertyName == "LINKER_LANGUAGE") {
|
|
|
|
if (target->LinkLanguagePropagatesToDependents() && dagCheckerParent &&
|
|
|
|
(dagCheckerParent->EvaluatingLinkLibraries() ||
|
|
|
|
dagCheckerParent->EvaluatingSources())) {
|
|
|
|
reportError(
|
|
|
|
context, content->GetOriginalExpression(),
|
|
|
|
"LINKER_LANGUAGE target property can not be used while evaluating "
|
|
|
|
"link libraries for a static library");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
return target->GetLinkerLanguage(context->Config);
|
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace,
|
2016-05-16 14:34:04 +00:00
|
|
|
target->GetName(), propertyName,
|
|
|
|
content, dagCheckerParent);
|
|
|
|
|
|
|
|
switch (dagChecker.Check()) {
|
|
|
|
case cmGeneratorExpressionDAGChecker::SELF_REFERENCE:
|
|
|
|
dagChecker.ReportError(context, content->GetOriginalExpression());
|
|
|
|
return std::string();
|
|
|
|
case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE:
|
|
|
|
// No error. We just skip cyclic references.
|
|
|
|
return std::string();
|
|
|
|
case cmGeneratorExpressionDAGChecker::ALREADY_SEEN:
|
|
|
|
for (size_t i = 1; i < cmArraySize(targetPropertyTransitiveWhitelist);
|
|
|
|
++i) {
|
|
|
|
if (targetPropertyTransitiveWhitelist[i] == propertyName) {
|
|
|
|
// No error. We're not going to find anything new here.
|
|
|
|
return std::string();
|
2015-02-22 22:32:11 +00:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
case cmGeneratorExpressionDAGChecker::DAG:
|
|
|
|
break;
|
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
const char* prop = target->GetProperty(propertyName);
|
|
|
|
|
|
|
|
if (dagCheckerParent) {
|
|
|
|
if (dagCheckerParent->EvaluatingLinkLibraries()) {
|
|
|
|
#define TRANSITIVE_PROPERTY_COMPARE(PROPERTY) \
|
|
|
|
(#PROPERTY == propertyName || "INTERFACE_" #PROPERTY == propertyName) ||
|
|
|
|
if (CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(
|
2016-10-18 20:56:47 +00:00
|
|
|
TRANSITIVE_PROPERTY_COMPARE) false) { // NOLINT(clang-tidy)
|
2016-05-16 14:34:04 +00:00
|
|
|
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.");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
#undef TRANSITIVE_PROPERTY_COMPARE
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!prop) {
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
} else {
|
|
|
|
#define ASSERT_TRANSITIVE_PROPERTY_METHOD(METHOD) dagCheckerParent->METHOD() ||
|
|
|
|
|
|
|
|
assert(CM_FOR_EACH_TRANSITIVE_PROPERTY_METHOD(
|
2016-10-18 20:56:47 +00:00
|
|
|
ASSERT_TRANSITIVE_PROPERTY_METHOD) false); // NOLINT(clang-tidy)
|
2015-02-22 22:32:11 +00:00
|
|
|
#undef ASSERT_TRANSITIVE_PROPERTY_METHOD
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
std::string linkedTargetsContent;
|
|
|
|
|
|
|
|
std::string interfacePropertyName;
|
|
|
|
bool isInterfaceProperty = false;
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
#define POPULATE_INTERFACE_PROPERTY_NAME(prop) \
|
|
|
|
if (propertyName == #prop) { \
|
|
|
|
interfacePropertyName = "INTERFACE_" #prop; \
|
|
|
|
} else if (propertyName == "INTERFACE_" #prop) { \
|
|
|
|
interfacePropertyName = "INTERFACE_" #prop; \
|
|
|
|
isInterfaceProperty = true; \
|
|
|
|
} else
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(POPULATE_INTERFACE_PROPERTY_NAME)
|
2016-05-16 14:34:04 +00:00
|
|
|
// Note that the above macro terminates with an else
|
2015-02-22 22:32:11 +00:00
|
|
|
/* else */ if (cmHasLiteralPrefix(propertyName.c_str(),
|
2016-05-16 14:34:04 +00:00
|
|
|
"COMPILE_DEFINITIONS_")) {
|
2015-02-22 22:32:11 +00:00
|
|
|
cmPolicies::PolicyStatus polSt =
|
2016-05-16 14:34:04 +00:00
|
|
|
context->LG->GetPolicyStatus(cmPolicies::CMP0043);
|
|
|
|
if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) {
|
2015-02-22 22:32:11 +00:00
|
|
|
interfacePropertyName = "INTERFACE_COMPILE_DEFINITIONS";
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
#undef POPULATE_INTERFACE_PROPERTY_NAME
|
2015-10-10 16:27:10 +00:00
|
|
|
cmGeneratorTarget const* headTarget =
|
2016-05-16 14:34:04 +00:00
|
|
|
context->HeadTarget && isInterfaceProperty ? context->HeadTarget
|
|
|
|
: target;
|
|
|
|
|
|
|
|
if (isInterfaceProperty) {
|
|
|
|
if (cmLinkInterfaceLibraries const* iface =
|
|
|
|
target->GetLinkInterfaceLibraries(context->Config, headTarget,
|
|
|
|
true)) {
|
2015-02-22 22:32:11 +00:00
|
|
|
linkedTargetsContent =
|
2016-05-16 14:34:04 +00:00
|
|
|
getLinkedTargetsContent(iface->Libraries, target, headTarget,
|
|
|
|
context, &dagChecker, interfacePropertyName);
|
2015-02-22 22:32:11 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
} else if (!interfacePropertyName.empty()) {
|
|
|
|
if (cmLinkImplementationLibraries const* impl =
|
|
|
|
target->GetLinkImplementationLibraries(context->Config)) {
|
2015-02-22 22:32:11 +00:00
|
|
|
linkedTargetsContent =
|
2016-05-16 14:34:04 +00:00
|
|
|
getLinkedTargetsContent(impl->Libraries, target, target, context,
|
|
|
|
&dagChecker, interfacePropertyName);
|
2015-02-22 22:32:11 +00:00
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!prop) {
|
|
|
|
if (target->IsImported() ||
|
2016-10-18 19:28:46 +00:00
|
|
|
target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
|
2015-02-22 22:32:11 +00:00
|
|
|
return linkedTargetsContent;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-10-10 16:27:10 +00:00
|
|
|
if (target->IsLinkInterfaceDependentBoolProperty(propertyName,
|
2016-05-16 14:34:04 +00:00
|
|
|
context->Config)) {
|
2015-02-22 22:32:11 +00:00
|
|
|
context->HadContextSensitiveCondition = true;
|
2016-05-16 14:34:04 +00:00
|
|
|
return target->GetLinkInterfaceDependentBoolProperty(propertyName,
|
|
|
|
context->Config)
|
|
|
|
? "1"
|
|
|
|
: "0";
|
|
|
|
}
|
2015-10-10 16:27:10 +00:00
|
|
|
if (target->IsLinkInterfaceDependentStringProperty(propertyName,
|
2016-05-16 14:34:04 +00:00
|
|
|
context->Config)) {
|
2015-02-22 22:32:11 +00:00
|
|
|
context->HadContextSensitiveCondition = true;
|
2016-05-16 14:34:04 +00:00
|
|
|
const char* propContent =
|
|
|
|
target->GetLinkInterfaceDependentStringProperty(propertyName,
|
|
|
|
context->Config);
|
2015-02-22 22:32:11 +00:00
|
|
|
return propContent ? propContent : "";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-10-10 16:27:10 +00:00
|
|
|
if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName,
|
2016-05-16 14:34:04 +00:00
|
|
|
context->Config)) {
|
2015-02-22 22:32:11 +00:00
|
|
|
context->HadContextSensitiveCondition = true;
|
2016-05-16 14:34:04 +00:00
|
|
|
const char* propContent =
|
|
|
|
target->GetLinkInterfaceDependentNumberMinProperty(propertyName,
|
|
|
|
context->Config);
|
2015-02-22 22:32:11 +00:00
|
|
|
return propContent ? propContent : "";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-10-10 16:27:10 +00:00
|
|
|
if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName,
|
2016-05-16 14:34:04 +00:00
|
|
|
context->Config)) {
|
2015-02-22 22:32:11 +00:00
|
|
|
context->HadContextSensitiveCondition = true;
|
2016-05-16 14:34:04 +00:00
|
|
|
const char* propContent =
|
|
|
|
target->GetLinkInterfaceDependentNumberMaxProperty(propertyName,
|
|
|
|
context->Config);
|
2015-02-22 22:32:11 +00:00
|
|
|
return propContent ? propContent : "";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
return linkedTargetsContent;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!target->IsImported() && dagCheckerParent &&
|
|
|
|
!dagCheckerParent->EvaluatingLinkLibraries()) {
|
2015-10-10 16:27:10 +00:00
|
|
|
if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName,
|
2016-05-16 14:34:04 +00:00
|
|
|
context->Config)) {
|
2015-02-22 22:32:11 +00:00
|
|
|
context->HadContextSensitiveCondition = true;
|
2016-05-16 14:34:04 +00:00
|
|
|
const char* propContent =
|
|
|
|
target->GetLinkInterfaceDependentNumberMinProperty(propertyName,
|
|
|
|
context->Config);
|
2015-02-22 22:32:11 +00:00
|
|
|
return propContent ? propContent : "";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-10-10 16:27:10 +00:00
|
|
|
if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName,
|
2016-05-16 14:34:04 +00:00
|
|
|
context->Config)) {
|
2015-02-22 22:32:11 +00:00
|
|
|
context->HadContextSensitiveCondition = true;
|
2016-05-16 14:34:04 +00:00
|
|
|
const char* propContent =
|
|
|
|
target->GetLinkInterfaceDependentNumberMaxProperty(propertyName,
|
|
|
|
context->Config);
|
2015-02-22 22:32:11 +00:00
|
|
|
return propContent ? propContent : "";
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (!interfacePropertyName.empty()) {
|
|
|
|
std::string result = this->EvaluateDependentExpression(
|
|
|
|
prop, context->LG, context, headTarget, target, &dagChecker);
|
|
|
|
if (!linkedTargetsContent.empty()) {
|
2015-02-22 22:32:11 +00:00
|
|
|
result += (result.empty() ? "" : ";") + linkedTargetsContent;
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
return result;
|
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
return prop;
|
|
|
|
}
|
|
|
|
} targetPropertyNode;
|
|
|
|
|
|
|
|
static const struct TargetNameNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
TargetNameNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
bool GeneratesContent() const CM_OVERRIDE { return true; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
bool AcceptsArbitraryContentParameter() const CM_OVERRIDE { return true; }
|
|
|
|
bool RequiresLiteralInput() const CM_OVERRIDE { return true; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionContext* /*context*/,
|
|
|
|
const GeneratorExpressionContent* /*content*/,
|
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
return parameters.front();
|
|
|
|
}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return 1; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
} targetNameNode;
|
|
|
|
|
|
|
|
static const struct TargetObjectsNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
TargetObjectsNode() {}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
std::string tgtName = parameters.front();
|
2016-05-16 14:34:04 +00:00
|
|
|
cmGeneratorTarget* gt = context->LG->FindGeneratorTargetToUse(tgtName);
|
|
|
|
if (!gt) {
|
2015-02-22 22:32:11 +00:00
|
|
|
std::ostringstream e;
|
|
|
|
e << "Objects of target \"" << tgtName
|
|
|
|
<< "\" referenced but no such target exists.";
|
|
|
|
reportError(context, content->GetOriginalExpression(), e.str());
|
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2016-10-18 19:28:46 +00:00
|
|
|
if (gt->GetType() != cmStateEnums::OBJECT_LIBRARY) {
|
2015-02-22 22:32:11 +00:00
|
|
|
std::ostringstream e;
|
|
|
|
e << "Objects of target \"" << tgtName
|
|
|
|
<< "\" referenced but is not an OBJECT library.";
|
|
|
|
reportError(context, content->GetOriginalExpression(), e.str());
|
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2017-04-18 14:05:04 +00:00
|
|
|
if (!context->EvaluateForBuildsystem) {
|
2017-01-23 19:13:49 +00:00
|
|
|
cmGlobalGenerator* gg = context->LG->GetGlobalGenerator();
|
|
|
|
std::string reason;
|
|
|
|
if (!gg->HasKnownObjectFileLocation(&reason)) {
|
|
|
|
std::ostringstream e;
|
|
|
|
e << "The evaluation of the TARGET_OBJECTS generator expression "
|
|
|
|
"is only suitable for consumption by CMake (limited"
|
|
|
|
<< reason << "). "
|
|
|
|
"It is not suitable for writing out elsewhere.";
|
|
|
|
reportError(context, content->GetOriginalExpression(), e.str());
|
|
|
|
return std::string();
|
|
|
|
}
|
2017-04-18 14:05:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2017-04-11 18:42:39 +00:00
|
|
|
std::vector<std::string> objects;
|
2017-03-23 13:32:08 +00:00
|
|
|
|
|
|
|
if (gt->IsImported()) {
|
2017-08-22 21:42:36 +00:00
|
|
|
const char* loc = nullptr;
|
|
|
|
const char* imp = nullptr;
|
2017-03-23 13:32:08 +00:00
|
|
|
std::string suffix;
|
|
|
|
if (gt->Target->GetMappedConfig(context->Config, &loc, &imp, suffix)) {
|
|
|
|
cmSystemTools::ExpandListArgument(loc, objects);
|
|
|
|
}
|
2017-01-23 19:13:49 +00:00
|
|
|
context->HadContextSensitiveCondition = true;
|
2017-03-23 13:32:08 +00:00
|
|
|
} else {
|
|
|
|
gt->GetTargetObjectNames(context->Config, objects);
|
|
|
|
|
|
|
|
std::string obj_dir;
|
|
|
|
if (context->EvaluateForBuildsystem) {
|
|
|
|
// Use object file directory with buildsystem placeholder.
|
|
|
|
obj_dir = gt->ObjectDirectory;
|
|
|
|
// Here we assume that the set of object files produced
|
|
|
|
// by an object library does not vary with configuration
|
|
|
|
// and do not set HadContextSensitiveCondition to true.
|
|
|
|
} else {
|
|
|
|
// Use object file directory with per-config location.
|
|
|
|
obj_dir = gt->GetObjectDirectory(context->Config);
|
|
|
|
context->HadContextSensitiveCondition = true;
|
|
|
|
}
|
2017-01-23 19:13:49 +00:00
|
|
|
|
2017-03-23 13:32:08 +00:00
|
|
|
for (std::vector<std::string>::iterator oi = objects.begin();
|
|
|
|
oi != objects.end(); ++oi) {
|
|
|
|
*oi = obj_dir + *oi;
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2017-04-11 18:42:39 +00:00
|
|
|
// Create the cmSourceFile instances in the referencing directory.
|
2017-04-10 18:48:57 +00:00
|
|
|
cmMakefile* mf = context->LG->GetMakefile();
|
2017-04-11 18:42:39 +00:00
|
|
|
for (std::vector<std::string>::iterator oi = objects.begin();
|
|
|
|
oi != objects.end(); ++oi) {
|
|
|
|
mf->AddTargetObject(tgtName, *oi);
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2017-04-11 18:42:39 +00:00
|
|
|
|
|
|
|
return cmJoin(objects, ";");
|
2015-02-22 22:32:11 +00:00
|
|
|
}
|
|
|
|
} targetObjectsNode;
|
|
|
|
|
|
|
|
static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
CompileFeaturesNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return OneOrMoreParameters; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker) const
|
2016-06-22 23:02:39 +00:00
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
2015-10-10 16:27:10 +00:00
|
|
|
cmGeneratorTarget const* target = context->HeadTarget;
|
2016-05-16 14:34:04 +00:00
|
|
|
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.");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
context->HadHeadSensitiveCondition = true;
|
|
|
|
|
2017-08-25 21:25:09 +00:00
|
|
|
typedef std::map<std::string, std::vector<std::string>> LangMap;
|
2015-02-22 22:32:11 +00:00
|
|
|
static LangMap availableFeatures;
|
|
|
|
|
|
|
|
LangMap testedFeatures;
|
|
|
|
|
|
|
|
for (std::vector<std::string>::const_iterator it = parameters.begin();
|
2016-05-16 14:34:04 +00:00
|
|
|
it != parameters.end(); ++it) {
|
2015-02-22 22:32:11 +00:00
|
|
|
std::string error;
|
|
|
|
std::string lang;
|
2015-10-10 16:27:10 +00:00
|
|
|
if (!context->LG->GetMakefile()->CompileFeatureKnown(
|
2016-05-16 14:34:04 +00:00
|
|
|
context->HeadTarget->Target, *it, lang, &error)) {
|
2015-02-22 22:32:11 +00:00
|
|
|
reportError(context, content->GetOriginalExpression(), error);
|
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
testedFeatures[lang].push_back(*it);
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (availableFeatures.find(lang) == availableFeatures.end()) {
|
|
|
|
const char* featuresKnown =
|
|
|
|
context->LG->GetMakefile()->CompileFeaturesAvailable(lang, &error);
|
|
|
|
if (!featuresKnown) {
|
2015-02-22 22:32:11 +00:00
|
|
|
reportError(context, content->GetOriginalExpression(), error);
|
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
cmSystemTools::ExpandListArgument(featuresKnown,
|
|
|
|
availableFeatures[lang]);
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
bool evalLL = dagChecker && dagChecker->EvaluatingLinkLibraries();
|
|
|
|
|
|
|
|
for (LangMap::const_iterator lit = testedFeatures.begin();
|
2016-05-16 14:34:04 +00:00
|
|
|
lit != testedFeatures.end(); ++lit) {
|
|
|
|
std::vector<std::string> const& langAvailable =
|
|
|
|
availableFeatures[lit->first];
|
|
|
|
const char* standardDefault = context->LG->GetMakefile()->GetDefinition(
|
|
|
|
"CMAKE_" + lit->first + "_STANDARD_DEFAULT");
|
2015-02-22 22:32:11 +00:00
|
|
|
for (std::vector<std::string>::const_iterator it = lit->second.begin();
|
2016-05-16 14:34:04 +00:00
|
|
|
it != lit->second.end(); ++it) {
|
|
|
|
if (std::find(langAvailable.begin(), langAvailable.end(), *it) ==
|
|
|
|
langAvailable.end()) {
|
2015-02-22 22:32:11 +00:00
|
|
|
return "0";
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (standardDefault && !*standardDefault) {
|
2015-02-22 22:32:11 +00:00
|
|
|
// This compiler has no notion of language standard levels.
|
|
|
|
// All features known for the language are always available.
|
|
|
|
continue;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (!context->LG->GetMakefile()->HaveStandardAvailable(
|
|
|
|
target->Target, lit->first, *it)) {
|
|
|
|
if (evalLL) {
|
2015-02-22 22:32:11 +00:00
|
|
|
const char* l = target->GetProperty(lit->first + "_STANDARD");
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!l) {
|
2015-02-22 22:32:11 +00:00
|
|
|
l = standardDefault;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
assert(l);
|
|
|
|
context->MaxLanguageStandard[target][lit->first] = l;
|
2016-05-16 14:34:04 +00:00
|
|
|
} else {
|
2015-02-22 22:32:11 +00:00
|
|
|
return "0";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
return "1";
|
|
|
|
}
|
|
|
|
} compileFeaturesNode;
|
|
|
|
|
|
|
|
static const char* targetPolicyWhitelist[] = {
|
2017-08-22 21:42:36 +00:00
|
|
|
nullptr
|
2016-05-16 14:34:04 +00:00
|
|
|
#define TARGET_POLICY_STRING(POLICY) , #POLICY
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2017-08-25 21:25:09 +00:00
|
|
|
CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_STRING)
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
#undef TARGET_POLICY_STRING
|
|
|
|
};
|
|
|
|
|
2015-10-10 16:27:10 +00:00
|
|
|
cmPolicies::PolicyStatus statusForTarget(cmGeneratorTarget const* tgt,
|
2016-05-16 14:34:04 +00:00
|
|
|
const char* policy)
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
#define RETURN_POLICY(POLICY) \
|
|
|
|
if (strcmp(policy, #POLICY) == 0) { \
|
|
|
|
return tgt->GetPolicyStatus##POLICY(); \
|
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
CM_FOR_EACH_TARGET_POLICY(RETURN_POLICY)
|
|
|
|
|
|
|
|
#undef RETURN_POLICY
|
|
|
|
|
2016-12-10 14:17:06 +00:00
|
|
|
assert(false && "Unreachable code. Not a valid policy");
|
2015-02-22 22:32:11 +00:00
|
|
|
return cmPolicies::WARN;
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
cmPolicies::PolicyID policyForString(const char* policy_id)
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
#define RETURN_POLICY_ID(POLICY_ID) \
|
|
|
|
if (strcmp(policy_id, #POLICY_ID) == 0) { \
|
|
|
|
return cmPolicies::POLICY_ID; \
|
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
CM_FOR_EACH_TARGET_POLICY(RETURN_POLICY_ID)
|
|
|
|
|
|
|
|
#undef RETURN_POLICY_ID
|
|
|
|
|
2016-12-10 14:17:06 +00:00
|
|
|
assert(false && "Unreachable code. Not a valid policy");
|
2015-02-22 22:32:11 +00:00
|
|
|
return cmPolicies::CMP0002;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct TargetPolicyNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
TargetPolicyNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return 1; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!context->HeadTarget) {
|
|
|
|
reportError(
|
|
|
|
context, content->GetOriginalExpression(),
|
|
|
|
"$<TARGET_POLICY:prop> may only be used with binary targets. It "
|
|
|
|
"may not be used with add_custom_command or add_custom_target.");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
context->HadContextSensitiveCondition = true;
|
|
|
|
context->HadHeadSensitiveCondition = true;
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
for (size_t i = 1; i < cmArraySize(targetPolicyWhitelist); ++i) {
|
|
|
|
const char* policy = targetPolicyWhitelist[i];
|
|
|
|
if (parameters.front() == policy) {
|
2015-10-16 17:19:49 +00:00
|
|
|
cmLocalGenerator* lg = context->HeadTarget->GetLocalGenerator();
|
2016-05-16 14:34:04 +00:00
|
|
|
switch (statusForTarget(context->HeadTarget, policy)) {
|
2015-02-22 22:32:11 +00:00
|
|
|
case cmPolicies::WARN:
|
2016-05-16 14:34:04 +00:00
|
|
|
lg->IssueMessage(
|
|
|
|
cmake::AUTHOR_WARNING,
|
|
|
|
cmPolicies::GetPolicyWarning(policyForString(policy)));
|
2017-06-02 18:32:58 +00:00
|
|
|
CM_FALLTHROUGH;
|
2015-02-22 22:32:11 +00:00
|
|
|
case cmPolicies::REQUIRED_IF_USED:
|
|
|
|
case cmPolicies::REQUIRED_ALWAYS:
|
|
|
|
case cmPolicies::OLD:
|
|
|
|
return "0";
|
|
|
|
case cmPolicies::NEW:
|
|
|
|
return "1";
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
reportError(
|
|
|
|
context, content->GetOriginalExpression(),
|
2015-02-22 22:32:11 +00:00
|
|
|
"$<TARGET_POLICY:prop> may only be used with a limited number of "
|
|
|
|
"policies. Currently it may be used with the following policies:\n"
|
|
|
|
|
|
|
|
#define STRINGIFY_HELPER(X) #X
|
|
|
|
#define STRINGIFY(X) STRINGIFY_HELPER(X)
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
#define TARGET_POLICY_LIST_ITEM(POLICY) " * " STRINGIFY(POLICY) "\n"
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
CM_FOR_EACH_TARGET_POLICY(TARGET_POLICY_LIST_ITEM)
|
|
|
|
|
|
|
|
#undef TARGET_POLICY_LIST_ITEM
|
2016-05-16 14:34:04 +00:00
|
|
|
);
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
|
|
|
} targetPolicyNode;
|
|
|
|
|
|
|
|
static const struct InstallPrefixNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
InstallPrefixNode() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
bool GeneratesContent() const CM_OVERRIDE { return true; }
|
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return 0; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-08-16 23:49:57 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& /*parameters*/,
|
2016-05-16 14:34:04 +00:00
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"INSTALL_PREFIX is a marker for install(EXPORT) only. It "
|
|
|
|
"should never be evaluated.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
|
|
|
} installPrefixNode;
|
|
|
|
|
2016-09-01 18:59:28 +00:00
|
|
|
class ArtifactDirTag;
|
2015-02-22 22:32:11 +00:00
|
|
|
class ArtifactLinkerTag;
|
2016-09-01 18:59:28 +00:00
|
|
|
class ArtifactNameTag;
|
2015-02-22 22:32:11 +00:00
|
|
|
class ArtifactPathTag;
|
2016-09-01 18:59:28 +00:00
|
|
|
class ArtifactPdbTag;
|
|
|
|
class ArtifactSonameTag;
|
2017-03-27 18:54:22 +00:00
|
|
|
class ArtifactBundleDirTag;
|
|
|
|
class ArtifactBundleContentDirTag;
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
template <typename ArtifactT>
|
2015-02-22 22:32:11 +00:00
|
|
|
struct TargetFilesystemArtifactResultCreator
|
|
|
|
{
|
2012-10-06 16:30:43 +00:00
|
|
|
static std::string Create(cmGeneratorTarget* target,
|
2016-05-16 14:34:04 +00:00
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content);
|
2015-02-22 22:32:11 +00:00
|
|
|
};
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
template <>
|
2015-02-22 22:32:11 +00:00
|
|
|
struct TargetFilesystemArtifactResultCreator<ArtifactSonameTag>
|
|
|
|
{
|
2012-10-06 16:30:43 +00:00
|
|
|
static std::string Create(cmGeneratorTarget* target,
|
2016-05-16 14:34:04 +00:00
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content)
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
// The target soname file (.so.1).
|
2016-05-16 14:34:04 +00:00
|
|
|
if (target->IsDLLPlatform()) {
|
2015-02-22 22:32:11 +00:00
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"TARGET_SONAME_FILE is not allowed "
|
|
|
|
"for DLL target platforms.");
|
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2016-10-18 19:28:46 +00:00
|
|
|
if (target->GetType() != cmStateEnums::SHARED_LIBRARY) {
|
2015-02-22 22:32:11 +00:00
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"TARGET_SONAME_FILE is allowed only for "
|
|
|
|
"SHARED libraries.");
|
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2014-10-20 18:31:47 +00:00
|
|
|
std::string result = target->GetDirectory(context->Config);
|
2015-02-22 22:32:11 +00:00
|
|
|
result += "/";
|
2015-08-04 17:19:41 +00:00
|
|
|
result += target->GetSOName(context->Config);
|
2015-02-22 22:32:11 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
template <>
|
2015-02-22 22:32:11 +00:00
|
|
|
struct TargetFilesystemArtifactResultCreator<ArtifactPdbTag>
|
|
|
|
{
|
2012-10-06 16:30:43 +00:00
|
|
|
static std::string Create(cmGeneratorTarget* target,
|
2016-05-16 14:34:04 +00:00
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content)
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (target->IsImported()) {
|
2015-08-03 19:28:41 +00:00
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"TARGET_PDB_FILE not allowed for IMPORTED targets.");
|
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-08-03 19:28:41 +00:00
|
|
|
|
2015-08-04 17:19:49 +00:00
|
|
|
std::string language = target->GetLinkerLanguage(context->Config);
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB";
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!context->LG->GetMakefile()->IsOn(pdbSupportVar)) {
|
2015-02-22 22:32:11 +00:00
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"TARGET_PDB_FILE is not supported by the target linker.");
|
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-10-18 19:28:46 +00:00
|
|
|
cmStateEnums::TargetType targetType = target->GetType();
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-10-18 19:28:46 +00:00
|
|
|
if (targetType != cmStateEnums::SHARED_LIBRARY &&
|
|
|
|
targetType != cmStateEnums::MODULE_LIBRARY &&
|
|
|
|
targetType != cmStateEnums::EXECUTABLE) {
|
2015-02-22 22:32:11 +00:00
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"TARGET_PDB_FILE is allowed only for "
|
|
|
|
"targets with linker created artifacts.");
|
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2015-08-05 16:39:17 +00:00
|
|
|
std::string result = target->GetPDBDirectory(context->Config);
|
2015-02-22 22:32:11 +00:00
|
|
|
result += "/";
|
2015-08-04 17:19:46 +00:00
|
|
|
result += target->GetPDBName(context->Config);
|
2015-02-22 22:32:11 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
template <>
|
2015-02-22 22:32:11 +00:00
|
|
|
struct TargetFilesystemArtifactResultCreator<ArtifactLinkerTag>
|
|
|
|
{
|
2012-10-06 16:30:43 +00:00
|
|
|
static std::string Create(cmGeneratorTarget* target,
|
2016-05-16 14:34:04 +00:00
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content)
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
// The file used to link to the target (.so, .lib, .a).
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!target->IsLinkable()) {
|
2015-02-22 22:32:11 +00:00
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"TARGET_LINKER_FILE is allowed only for libraries and "
|
|
|
|
"executables with ENABLE_EXPORTS.");
|
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2017-04-19 17:10:09 +00:00
|
|
|
cmStateEnums::ArtifactType artifact = target->HasImportLibrary()
|
|
|
|
? cmStateEnums::ImportLibraryArtifact
|
|
|
|
: cmStateEnums::RuntimeBinaryArtifact;
|
|
|
|
return target->GetFullPath(context->Config, artifact);
|
2015-02-22 22:32:11 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-03-27 18:54:22 +00:00
|
|
|
template <>
|
|
|
|
struct TargetFilesystemArtifactResultCreator<ArtifactBundleDirTag>
|
|
|
|
{
|
|
|
|
static std::string Create(cmGeneratorTarget* target,
|
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content)
|
|
|
|
{
|
|
|
|
if (target->IsImported()) {
|
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"TARGET_BUNDLE_DIR not allowed for IMPORTED targets.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
if (!target->IsBundleOnApple()) {
|
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"TARGET_BUNDLE_DIR is allowed only for Bundle targets.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string outpath = target->GetDirectory(context->Config) + '/';
|
|
|
|
return target->BuildBundleDirectory(outpath, context->Config,
|
|
|
|
cmGeneratorTarget::BundleDirLevel);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
template <>
|
|
|
|
struct TargetFilesystemArtifactResultCreator<ArtifactBundleContentDirTag>
|
|
|
|
{
|
|
|
|
static std::string Create(cmGeneratorTarget* target,
|
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content)
|
|
|
|
{
|
|
|
|
if (target->IsImported()) {
|
|
|
|
::reportError(
|
|
|
|
context, content->GetOriginalExpression(),
|
|
|
|
"TARGET_BUNDLE_CONTENT_DIR not allowed for IMPORTED targets.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
if (!target->IsBundleOnApple()) {
|
|
|
|
::reportError(
|
|
|
|
context, content->GetOriginalExpression(),
|
|
|
|
"TARGET_BUNDLE_CONTENT_DIR is allowed only for Bundle targets.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string outpath = target->GetDirectory(context->Config) + '/';
|
|
|
|
return target->BuildBundleDirectory(outpath, context->Config,
|
|
|
|
cmGeneratorTarget::ContentLevel);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
template <>
|
2015-02-22 22:32:11 +00:00
|
|
|
struct TargetFilesystemArtifactResultCreator<ArtifactNameTag>
|
|
|
|
{
|
2012-10-06 16:30:43 +00:00
|
|
|
static std::string Create(cmGeneratorTarget* target,
|
2016-05-16 14:34:04 +00:00
|
|
|
cmGeneratorExpressionContext* context,
|
2016-08-16 23:49:57 +00:00
|
|
|
const GeneratorExpressionContent* /*unused*/)
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
2017-04-19 17:10:09 +00:00
|
|
|
return target->GetFullPath(context->Config,
|
|
|
|
cmStateEnums::RuntimeBinaryArtifact, true);
|
2015-02-22 22:32:11 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
template <typename ArtifactT>
|
2015-02-22 22:32:11 +00:00
|
|
|
struct TargetFilesystemArtifactResultGetter
|
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
static std::string Get(const std::string& result);
|
2015-02-22 22:32:11 +00:00
|
|
|
};
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
template <>
|
2015-02-22 22:32:11 +00:00
|
|
|
struct TargetFilesystemArtifactResultGetter<ArtifactNameTag>
|
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
static std::string Get(const std::string& result)
|
|
|
|
{
|
|
|
|
return cmSystemTools::GetFilenameName(result);
|
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
};
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
template <>
|
2015-02-22 22:32:11 +00:00
|
|
|
struct TargetFilesystemArtifactResultGetter<ArtifactDirTag>
|
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
static std::string Get(const std::string& result)
|
|
|
|
{
|
|
|
|
return cmSystemTools::GetFilenamePath(result);
|
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
};
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
template <>
|
2015-02-22 22:32:11 +00:00
|
|
|
struct TargetFilesystemArtifactResultGetter<ArtifactPathTag>
|
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
static std::string Get(const std::string& result) { return result; }
|
2015-02-22 22:32:11 +00:00
|
|
|
};
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
template <typename ArtifactT, typename ComponentT>
|
2015-02-22 22:32:11 +00:00
|
|
|
struct TargetFilesystemArtifact : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
TargetFilesystemArtifact() {}
|
|
|
|
|
2016-06-22 23:02:39 +00:00
|
|
|
int NumExpectedParameters() const CM_OVERRIDE { return 1; }
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content,
|
|
|
|
cmGeneratorExpressionDAGChecker* dagChecker) const
|
2016-06-22 23:02:39 +00:00
|
|
|
CM_OVERRIDE
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
// Lookup the referenced target.
|
|
|
|
std::string name = *parameters.begin();
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!cmGeneratorExpression::IsValidTargetName(name)) {
|
2015-02-22 22:32:11 +00:00
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Expression syntax not recognized.");
|
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
cmGeneratorTarget* target = context->LG->FindGeneratorTargetToUse(name);
|
|
|
|
if (!target) {
|
2015-02-22 22:32:11 +00:00
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"No target \"" + name + "\"");
|
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2016-10-18 19:28:46 +00:00
|
|
|
if (target->GetType() >= cmStateEnums::OBJECT_LIBRARY &&
|
|
|
|
target->GetType() != cmStateEnums::UNKNOWN_LIBRARY) {
|
2016-05-16 14:34:04 +00:00
|
|
|
::reportError(context, content->GetOriginalExpression(), "Target \"" +
|
|
|
|
name + "\" is not an executable or library.");
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
if (dagChecker && (dagChecker->EvaluatingLinkLibraries(name.c_str()) ||
|
|
|
|
(dagChecker->EvaluatingSources() &&
|
|
|
|
name == dagChecker->TopTarget()))) {
|
2015-02-22 22:32:11 +00:00
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Expressions which require the linker language may not "
|
|
|
|
"be used while evaluating link libraries");
|
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-10-10 16:41:51 +00:00
|
|
|
context->DependTargets.insert(target);
|
|
|
|
context->AllTargets.insert(target);
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
std::string result =
|
2016-05-16 14:34:04 +00:00
|
|
|
TargetFilesystemArtifactResultCreator<ArtifactT>::Create(target, context,
|
|
|
|
content);
|
|
|
|
if (context->HadError) {
|
2015-02-22 22:32:11 +00:00
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
|
|
|
return TargetFilesystemArtifactResultGetter<ComponentT>::Get(result);
|
2015-02-22 22:32:11 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
template <typename ArtifactT>
|
2015-02-22 22:32:11 +00:00
|
|
|
struct TargetFilesystemArtifactNodeGroup
|
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
TargetFilesystemArtifactNodeGroup() {}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
TargetFilesystemArtifact<ArtifactT, ArtifactPathTag> File;
|
|
|
|
TargetFilesystemArtifact<ArtifactT, ArtifactNameTag> FileName;
|
|
|
|
TargetFilesystemArtifact<ArtifactT, ArtifactDirTag> FileDir;
|
|
|
|
};
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
static const TargetFilesystemArtifactNodeGroup<ArtifactNameTag>
|
|
|
|
targetNodeGroup;
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
static const TargetFilesystemArtifactNodeGroup<ArtifactLinkerTag>
|
|
|
|
targetLinkerNodeGroup;
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
static const TargetFilesystemArtifactNodeGroup<ArtifactSonameTag>
|
|
|
|
targetSoNameNodeGroup;
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
static const TargetFilesystemArtifactNodeGroup<ArtifactPdbTag>
|
|
|
|
targetPdbNodeGroup;
|
2015-02-22 22:32:11 +00:00
|
|
|
|
2017-03-27 18:54:22 +00:00
|
|
|
static const TargetFilesystemArtifact<ArtifactBundleDirTag, ArtifactPathTag>
|
|
|
|
targetBundleDirNode;
|
|
|
|
|
|
|
|
static const TargetFilesystemArtifact<ArtifactBundleContentDirTag,
|
|
|
|
ArtifactPathTag>
|
|
|
|
targetBundleContentDirNode;
|
|
|
|
|
2015-09-24 10:33:01 +00:00
|
|
|
static const struct ShellPathNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
ShellPathNode() {}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
std::string Evaluate(const std::vector<std::string>& parameters,
|
|
|
|
cmGeneratorExpressionContext* context,
|
|
|
|
const GeneratorExpressionContent* content,
|
2016-08-16 23:49:57 +00:00
|
|
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const
|
|
|
|
CM_OVERRIDE
|
2015-09-24 10:33:01 +00:00
|
|
|
{
|
2016-05-16 14:34:04 +00:00
|
|
|
if (!cmSystemTools::FileIsFullPath(parameters.front())) {
|
2015-09-24 10:33:01 +00:00
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"\"" + parameters.front() + "\" is not an absolute path.");
|
|
|
|
return std::string();
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-07-25 14:56:52 +00:00
|
|
|
cmOutputConverter converter(context->LG->GetStateSnapshot());
|
2015-09-24 10:33:01 +00:00
|
|
|
return converter.ConvertDirectorySeparatorsForShell(parameters.front());
|
|
|
|
}
|
|
|
|
} shellPathNode;
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode(
|
|
|
|
const std::string& identifier)
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
typedef std::map<std::string, const cmGeneratorExpressionNode*> NodeMap;
|
|
|
|
static NodeMap nodeMap;
|
2016-05-16 14:34:04 +00:00
|
|
|
if (nodeMap.empty()) {
|
2015-02-22 22:32:11 +00:00
|
|
|
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;
|
2016-08-05 18:11:46 +00:00
|
|
|
nodeMap["VERSION_GREATER_EQUAL"] = &versionGreaterEqNode;
|
2015-02-22 22:32:11 +00:00
|
|
|
nodeMap["VERSION_LESS"] = &versionLessNode;
|
2016-08-05 18:11:46 +00:00
|
|
|
nodeMap["VERSION_LESS_EQUAL"] = &versionLessEqNode;
|
2015-02-22 22:32:11 +00:00
|
|
|
nodeMap["VERSION_EQUAL"] = &versionEqualNode;
|
|
|
|
nodeMap["C_COMPILER_VERSION"] = &cCompilerVersionNode;
|
|
|
|
nodeMap["CXX_COMPILER_VERSION"] = &cxxCompilerVersionNode;
|
|
|
|
nodeMap["PLATFORM_ID"] = &platformIdNode;
|
|
|
|
nodeMap["COMPILE_FEATURES"] = &compileFeaturesNode;
|
|
|
|
nodeMap["CONFIGURATION"] = &configurationNode;
|
|
|
|
nodeMap["CONFIG"] = &configurationTestNode;
|
|
|
|
nodeMap["TARGET_FILE"] = &targetNodeGroup.File;
|
|
|
|
nodeMap["TARGET_LINKER_FILE"] = &targetLinkerNodeGroup.File;
|
|
|
|
nodeMap["TARGET_SONAME_FILE"] = &targetSoNameNodeGroup.File;
|
|
|
|
nodeMap["TARGET_PDB_FILE"] = &targetPdbNodeGroup.File;
|
|
|
|
nodeMap["TARGET_FILE_NAME"] = &targetNodeGroup.FileName;
|
|
|
|
nodeMap["TARGET_LINKER_FILE_NAME"] = &targetLinkerNodeGroup.FileName;
|
|
|
|
nodeMap["TARGET_SONAME_FILE_NAME"] = &targetSoNameNodeGroup.FileName;
|
|
|
|
nodeMap["TARGET_PDB_FILE_NAME"] = &targetPdbNodeGroup.FileName;
|
|
|
|
nodeMap["TARGET_FILE_DIR"] = &targetNodeGroup.FileDir;
|
|
|
|
nodeMap["TARGET_LINKER_FILE_DIR"] = &targetLinkerNodeGroup.FileDir;
|
|
|
|
nodeMap["TARGET_SONAME_FILE_DIR"] = &targetSoNameNodeGroup.FileDir;
|
|
|
|
nodeMap["TARGET_PDB_FILE_DIR"] = &targetPdbNodeGroup.FileDir;
|
2017-03-27 18:54:22 +00:00
|
|
|
nodeMap["TARGET_BUNDLE_DIR"] = &targetBundleDirNode;
|
|
|
|
nodeMap["TARGET_BUNDLE_CONTENT_DIR"] = &targetBundleContentDirNode;
|
2015-02-22 22:32:11 +00:00
|
|
|
nodeMap["STREQUAL"] = &strEqualNode;
|
|
|
|
nodeMap["EQUAL"] = &equalNode;
|
|
|
|
nodeMap["LOWER_CASE"] = &lowerCaseNode;
|
|
|
|
nodeMap["UPPER_CASE"] = &upperCaseNode;
|
|
|
|
nodeMap["MAKE_C_IDENTIFIER"] = &makeCIdentifierNode;
|
|
|
|
nodeMap["BOOL"] = &boolNode;
|
2017-01-24 03:14:03 +00:00
|
|
|
nodeMap["IF"] = &ifNode;
|
2015-02-22 22:32:11 +00:00
|
|
|
nodeMap["ANGLE-R"] = &angle_rNode;
|
|
|
|
nodeMap["COMMA"] = &commaNode;
|
|
|
|
nodeMap["SEMICOLON"] = &semicolonNode;
|
|
|
|
nodeMap["TARGET_PROPERTY"] = &targetPropertyNode;
|
|
|
|
nodeMap["TARGET_NAME"] = &targetNameNode;
|
|
|
|
nodeMap["TARGET_OBJECTS"] = &targetObjectsNode;
|
|
|
|
nodeMap["TARGET_POLICY"] = &targetPolicyNode;
|
|
|
|
nodeMap["BUILD_INTERFACE"] = &buildInterfaceNode;
|
|
|
|
nodeMap["INSTALL_INTERFACE"] = &installInterfaceNode;
|
|
|
|
nodeMap["INSTALL_PREFIX"] = &installPrefixNode;
|
|
|
|
nodeMap["JOIN"] = &joinNode;
|
|
|
|
nodeMap["LINK_ONLY"] = &linkOnlyNode;
|
|
|
|
nodeMap["COMPILE_LANGUAGE"] = &languageNode;
|
2015-09-24 10:33:01 +00:00
|
|
|
nodeMap["SHELL_PATH"] = &shellPathNode;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
NodeMap::const_iterator i = nodeMap.find(identifier);
|
2016-05-16 14:34:04 +00:00
|
|
|
if (i == nodeMap.end()) {
|
2017-08-22 21:42:36 +00:00
|
|
|
return nullptr;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
return i->second;
|
|
|
|
}
|
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
void reportError(cmGeneratorExpressionContext* context,
|
|
|
|
const std::string& expr, const std::string& result)
|
2015-02-22 22:32:11 +00:00
|
|
|
{
|
|
|
|
context->HadError = true;
|
2016-05-16 14:34:04 +00:00
|
|
|
if (context->Quiet) {
|
2015-02-22 22:32:11 +00:00
|
|
|
return;
|
2016-05-16 14:34:04 +00:00
|
|
|
}
|
2015-02-22 22:32:11 +00:00
|
|
|
|
|
|
|
std::ostringstream e;
|
2016-05-06 18:19:04 +00:00
|
|
|
/* clang-format off */
|
2015-02-22 22:32:11 +00:00
|
|
|
e << "Error evaluating generator expression:\n"
|
|
|
|
<< " " << expr << "\n"
|
|
|
|
<< result;
|
2016-05-06 18:19:04 +00:00
|
|
|
/* clang-format on */
|
2016-05-16 14:34:04 +00:00
|
|
|
context->LG->GetCMakeInstance()->IssueMessage(cmake::FATAL_ERROR, e.str(),
|
|
|
|
context->Backtrace);
|
2015-02-22 22:32:11 +00:00
|
|
|
}
|