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"
|
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>
|
|
|
|
|
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()
|
|
|
|
->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(),
|
|
|
|
context->Backtrace);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
struct cmGeneratorExpressionNode
|
|
|
|
{
|
2013-05-16 17:52:25 +04:00
|
|
|
enum {
|
|
|
|
DynamicParameters = 0,
|
|
|
|
OneOrMoreParameters = -1,
|
|
|
|
ZeroOrMoreParameters = -2
|
|
|
|
};
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
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
|
|
|
{
|
|
|
|
// Unreachable
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
// Unreachable
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
} 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;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
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() {}
|
|
|
|
|
|
|
|
virtual int NumExpectedParameters() const { return ZeroOrMoreParameters; }
|
|
|
|
|
|
|
|
std::string EvaluateWithLanguage(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *content,
|
|
|
|
cmGeneratorExpressionDAGChecker *,
|
|
|
|
const std::string &lang) const
|
|
|
|
{
|
|
|
|
const char *compilerId = context->Makefile ?
|
|
|
|
context->Makefile->GetSafeDefinition((
|
|
|
|
"CMAKE_" + lang + "_COMPILER_ID").c_str()) : "";
|
|
|
|
if (parameters.size() == 0)
|
|
|
|
{
|
|
|
|
return compilerId ? compilerId : "";
|
|
|
|
}
|
|
|
|
cmsys::RegularExpression compilerIdValidator;
|
|
|
|
compilerIdValidator.compile("^[A-Za-z0-9_]*$");
|
|
|
|
if (!compilerIdValidator.find(parameters.begin()->c_str()))
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Expression syntax not recognized.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
if (!compilerId)
|
|
|
|
{
|
|
|
|
return parameters.front().empty() ? "1" : "0";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cmsysString_strcasecmp(parameters.begin()->c_str(), compilerId) == 0)
|
|
|
|
{
|
|
|
|
return "1";
|
|
|
|
}
|
|
|
|
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 (parameters.size() != 0 && parameters.size() != 1)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<C_COMPILER_ID> expression requires one or two parameters");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
if (!context->HeadTarget)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<C_COMPILER_ID> may only be used with targets. It may not "
|
|
|
|
"be used with add_custom_command.");
|
|
|
|
}
|
|
|
|
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 (parameters.size() != 0 && parameters.size() != 1)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<CXX_COMPILER_ID> expression requires one or two parameters");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
if (!context->HeadTarget)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<CXX_COMPILER_ID> may only be used with targets. It may not "
|
|
|
|
"be used with add_custom_command.");
|
|
|
|
}
|
|
|
|
return this->EvaluateWithLanguage(parameters, context, content,
|
|
|
|
dagChecker, "CXX");
|
|
|
|
}
|
|
|
|
} cxxCompilerIdNode;
|
|
|
|
|
2013-06-11 12:48:47 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
struct CompilerVersionNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
CompilerVersionNode() {}
|
|
|
|
|
|
|
|
virtual int NumExpectedParameters() const { return ZeroOrMoreParameters; }
|
|
|
|
|
|
|
|
std::string EvaluateWithLanguage(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *content,
|
|
|
|
cmGeneratorExpressionDAGChecker *,
|
|
|
|
const std::string &lang) const
|
|
|
|
{
|
|
|
|
const char *compilerVersion = context->Makefile ?
|
|
|
|
context->Makefile->GetSafeDefinition((
|
|
|
|
"CMAKE_" + lang + "_COMPILER_VERSION").c_str()) : "";
|
|
|
|
if (parameters.size() == 0)
|
|
|
|
{
|
|
|
|
return compilerVersion ? compilerVersion : "";
|
|
|
|
}
|
|
|
|
|
|
|
|
cmsys::RegularExpression compilerIdValidator;
|
|
|
|
compilerIdValidator.compile("^[0-9\\.]*$");
|
|
|
|
if (!compilerIdValidator.find(parameters.begin()->c_str()))
|
|
|
|
{
|
|
|
|
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 (parameters.size() != 0 && parameters.size() != 1)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<C_COMPILER_VERSION> expression requires one or two parameters");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
if (!context->HeadTarget)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<C_COMPILER_VERSION> may only be used with targets. It may not "
|
|
|
|
"be used with add_custom_command.");
|
|
|
|
}
|
|
|
|
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 (parameters.size() != 0 && parameters.size() != 1)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<CXX_COMPILER_VERSION> expression requires one or two "
|
|
|
|
"parameters");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
if (!context->HeadTarget)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<CXX_COMPILER_VERSION> may only be used with targets. It may "
|
|
|
|
"not be used with add_custom_command.");
|
|
|
|
}
|
|
|
|
return this->EvaluateWithLanguage(parameters, context, content,
|
|
|
|
dagChecker, "CXX");
|
|
|
|
}
|
|
|
|
} cxxCompilerVersionNode;
|
|
|
|
|
|
|
|
|
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;
|
2012-09-11 21:53:38 +04:00
|
|
|
return context->Config ? context->Config : "";
|
|
|
|
}
|
|
|
|
} configurationNode;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
ConfigurationTestNode() {}
|
|
|
|
|
|
|
|
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,
|
|
|
|
cmGeneratorExpressionDAGChecker *) const
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
|
|
|
cmsys::RegularExpression configValidator;
|
|
|
|
configValidator.compile("^[A-Za-z0-9_]*$");
|
|
|
|
if (!configValidator.find(parameters.begin()->c_str()))
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Expression syntax not recognized.");
|
|
|
|
return std::string();
|
|
|
|
}
|
2013-02-03 10:33:15 +04:00
|
|
|
context->HadContextSensitiveCondition = true;
|
2012-10-04 02:36:23 +04:00
|
|
|
if (!context->Config)
|
|
|
|
{
|
|
|
|
return parameters.front().empty() ? "1" : "0";
|
|
|
|
}
|
|
|
|
|
2012-12-23 14:20:37 +04:00
|
|
|
if (cmsysString_strcasecmp(parameters.begin()->c_str(),
|
|
|
|
context->Config) == 0)
|
|
|
|
{
|
|
|
|
return "1";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (context->CurrentTarget
|
|
|
|
&& context->CurrentTarget->IsImported())
|
|
|
|
{
|
|
|
|
const char* loc = 0;
|
|
|
|
const char* imp = 0;
|
|
|
|
std::string suffix;
|
|
|
|
return context->CurrentTarget->GetMappedConfig(context->Config,
|
|
|
|
&loc,
|
|
|
|
&imp,
|
|
|
|
suffix) ? "1" : "0";
|
|
|
|
}
|
|
|
|
return "0";
|
2012-09-11 21:53:38 +04:00
|
|
|
}
|
|
|
|
} configurationTestNode;
|
|
|
|
|
2013-05-16 17:52:25 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const struct LinkLanguageNode : public cmGeneratorExpressionNode
|
|
|
|
{
|
|
|
|
LinkLanguageNode() {}
|
|
|
|
|
|
|
|
virtual int NumExpectedParameters() const { return ZeroOrMoreParameters; }
|
|
|
|
|
|
|
|
std::string Evaluate(const std::vector<std::string> ¶meters,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *content,
|
2013-06-14 17:59:23 +04:00
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker) const
|
2013-05-16 17:52:25 +04:00
|
|
|
{
|
2013-06-14 17:59:23 +04:00
|
|
|
if (dagChecker && dagChecker->EvaluatingLinkLibraries())
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<LINK_LANGUAGE> expression can not be used while evaluating "
|
|
|
|
"link libraries");
|
|
|
|
return std::string();
|
|
|
|
}
|
2013-05-16 17:52:25 +04:00
|
|
|
if (parameters.size() != 0 && parameters.size() != 1)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<LINK_LANGUAGE> expression requires one or two parameters");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
cmTarget* target = context->HeadTarget;
|
|
|
|
if (!target)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<LINK_LANGUAGE> may only be used with targets. It may not "
|
|
|
|
"be used with add_custom_command.");
|
2013-06-14 17:45:12 +04:00
|
|
|
return std::string();
|
2013-05-16 17:52:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *lang = target->GetLinkerLanguage(context->Config);
|
|
|
|
if (parameters.size() == 0)
|
|
|
|
{
|
|
|
|
return lang ? lang : "";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cmsys::RegularExpression langValidator;
|
|
|
|
langValidator.compile("^[A-Za-z0-9_]*$");
|
|
|
|
if (!langValidator.find(parameters.begin()->c_str()))
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Expression syntax not recognized.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
if (!lang)
|
|
|
|
{
|
|
|
|
return parameters.front().empty() ? "1" : "0";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strcmp(parameters.begin()->c_str(), lang) == 0)
|
|
|
|
{
|
|
|
|
return "1";
|
|
|
|
}
|
|
|
|
return "0";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} linkLanguageNode;
|
2012-09-23 15:45:17 +04:00
|
|
|
|
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) \
|
|
|
|
, #PROPERTY
|
|
|
|
|
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-05-29 02:34:30 +04:00
|
|
|
std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
|
|
|
|
cmTarget *target,
|
2013-06-04 01:53:29 +04:00
|
|
|
cmTarget *headTarget,
|
2013-05-29 02:34:30 +04:00
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
cmGeneratorExpressionDAGChecker *dagChecker,
|
|
|
|
const std::string &interfacePropertyName)
|
|
|
|
{
|
|
|
|
cmGeneratorExpression ge(context->Backtrace);
|
|
|
|
|
|
|
|
std::string sep;
|
|
|
|
std::string depString;
|
|
|
|
for (std::vector<std::string>::const_iterator
|
|
|
|
it = libraries.begin();
|
|
|
|
it != libraries.end(); ++it)
|
|
|
|
{
|
|
|
|
if (*it == target->GetName())
|
|
|
|
{
|
|
|
|
// 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.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (context->Makefile->FindTargetToUse(it->c_str()))
|
|
|
|
{
|
|
|
|
depString +=
|
|
|
|
sep + "$<TARGET_PROPERTY:" + *it + "," + interfacePropertyName + ">";
|
|
|
|
sep = ";";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(depString);
|
|
|
|
std::string linkedTargetsContent = cge->Evaluate(context->Makefile,
|
|
|
|
context->Config,
|
|
|
|
context->Quiet,
|
2013-06-04 01:53:29 +04:00
|
|
|
headTarget,
|
2013-05-29 02:34:30 +04:00
|
|
|
target,
|
|
|
|
dagChecker);
|
|
|
|
if (cge->GetHadContextSensitiveCondition())
|
|
|
|
{
|
|
|
|
context->HadContextSensitiveCondition = true;
|
|
|
|
}
|
|
|
|
return linkedTargetsContent;
|
|
|
|
}
|
|
|
|
|
2013-05-16 17:52:14 +04:00
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
struct TransitiveWhitelistCompare
|
|
|
|
{
|
|
|
|
explicit TransitiveWhitelistCompare(const std::string &needle)
|
|
|
|
: Needle(needle) {}
|
|
|
|
bool operator() (const char *item)
|
|
|
|
{ return strcmp(item, this->Needle.c_str()) == 0; }
|
|
|
|
private:
|
|
|
|
std::string Needle;
|
|
|
|
};
|
|
|
|
|
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();
|
|
|
|
}
|
2012-10-19 15:11:59 +04:00
|
|
|
cmsys::RegularExpression propertyNameValidator;
|
|
|
|
propertyNameValidator.compile("^[A-Za-z0-9_]+$");
|
2012-10-04 02:31:24 +04:00
|
|
|
|
2012-11-06 19:06:31 +04:00
|
|
|
cmTarget* target = context->HeadTarget;
|
2012-09-12 06:23:31 +04:00
|
|
|
std::string propertyName = *parameters.begin();
|
2013-01-03 23:56:32 +04:00
|
|
|
|
|
|
|
if (!target && parameters.size() == 1)
|
|
|
|
{
|
|
|
|
reportError(context, content->GetOriginalExpression(),
|
|
|
|
"$<TARGET_PROPERTY:prop> may only be used with targets. It may not "
|
|
|
|
"be used with add_custom_command. Specify the target to read a "
|
|
|
|
"property from using the $<TARGET_PROPERTY:tgt,prop> signature "
|
|
|
|
"instead.");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
2012-10-27 18:16:17 +04:00
|
|
|
target = context->Makefile->FindTargetToUse(
|
2012-10-04 02:32:39 +04:00
|
|
|
targetName.c_str());
|
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();
|
|
|
|
}
|
|
|
|
|
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(),
|
|
|
|
"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);
|
|
|
|
|
2012-09-18 15:53:39 +04:00
|
|
|
cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace,
|
|
|
|
target->GetName(),
|
|
|
|
propertyName,
|
|
|
|
content,
|
|
|
|
dagCheckerParent);
|
|
|
|
|
2012-12-21 18:49:19 +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:
|
2012-09-18 15:53:39 +04:00
|
|
|
dagChecker.reportError(context, content->GetOriginalExpression());
|
|
|
|
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-02-07 15:33:20 +04:00
|
|
|
i < (sizeof(targetPropertyTransitiveWhitelist) /
|
|
|
|
sizeof(*targetPropertyTransitiveWhitelist));
|
|
|
|
++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
|
|
|
}
|
|
|
|
|
2012-09-12 06:23:31 +04:00
|
|
|
const char *prop = target->GetProperty(propertyName.c_str());
|
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
|
|
|
{
|
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-02-13 15:35:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string linkedTargetsContent;
|
|
|
|
|
|
|
|
std::string interfacePropertyName;
|
2013-02-12 14:29:09 +04:00
|
|
|
|
2013-02-13 15:35:31 +04:00
|
|
|
if (propertyName == "INTERFACE_INCLUDE_DIRECTORIES"
|
|
|
|
|| propertyName == "INCLUDE_DIRECTORIES")
|
|
|
|
{
|
|
|
|
interfacePropertyName = "INTERFACE_INCLUDE_DIRECTORIES";
|
|
|
|
}
|
|
|
|
else if (propertyName == "INTERFACE_COMPILE_DEFINITIONS"
|
|
|
|
|| propertyName == "COMPILE_DEFINITIONS"
|
|
|
|
|| strncmp(propertyName.c_str(), "COMPILE_DEFINITIONS_", 20) == 0)
|
|
|
|
{
|
|
|
|
interfacePropertyName = "INTERFACE_COMPILE_DEFINITIONS";
|
|
|
|
}
|
2013-05-16 17:15:28 +04:00
|
|
|
else if (propertyName == "INTERFACE_COMPILE_OPTIONS"
|
|
|
|
|| propertyName == "COMPILE_OPTIONS")
|
|
|
|
{
|
|
|
|
interfacePropertyName = "INTERFACE_COMPILE_OPTIONS";
|
|
|
|
}
|
2013-02-13 15:35:31 +04:00
|
|
|
|
2013-06-04 01:53:29 +04:00
|
|
|
cmTarget *headTarget = context->HeadTarget ? context->HeadTarget : target;
|
|
|
|
|
2013-06-10 18:01:59 +04:00
|
|
|
const char **transBegin = targetPropertyTransitiveWhitelist + 1;
|
2013-05-16 17:52:14 +04:00
|
|
|
const char **transEnd = targetPropertyTransitiveWhitelist
|
|
|
|
+ (sizeof(targetPropertyTransitiveWhitelist) /
|
|
|
|
sizeof(*targetPropertyTransitiveWhitelist));
|
|
|
|
if (std::find_if(transBegin, transEnd,
|
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
|
|
|
TransitiveWhitelistCompare(propertyName)) != transEnd)
|
2013-02-13 15:35:31 +04:00
|
|
|
{
|
2013-06-04 18:17:18 +04:00
|
|
|
|
|
|
|
std::vector<std::string> libs;
|
|
|
|
target->GetTransitivePropertyLinkLibraries(context->Config,
|
|
|
|
headTarget, libs);
|
|
|
|
if (!libs.empty())
|
2013-02-13 15:35:31 +04:00
|
|
|
{
|
2013-05-29 02:34:30 +04:00
|
|
|
linkedTargetsContent =
|
2013-06-04 18:17:18 +04:00
|
|
|
getLinkedTargetsContent(libs, target,
|
2013-06-04 01:53:29 +04:00
|
|
|
headTarget,
|
2013-05-29 02:34:30 +04:00
|
|
|
context, &dagChecker,
|
|
|
|
interfacePropertyName);
|
2013-02-12 14:29:09 +04:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
else if (std::find_if(transBegin, transEnd,
|
|
|
|
TransitiveWhitelistCompare(interfacePropertyName)) != transEnd)
|
|
|
|
{
|
|
|
|
const cmTarget::LinkImplementation *impl = target->GetLinkImplementation(
|
|
|
|
context->Config,
|
2013-06-04 01:53:29 +04:00
|
|
|
headTarget);
|
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
|
|
|
if(impl)
|
|
|
|
{
|
|
|
|
linkedTargetsContent =
|
|
|
|
getLinkedTargetsContent(impl->Libraries, target,
|
2013-06-04 01:53:29 +04:00
|
|
|
headTarget,
|
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
|
|
|
context, &dagChecker,
|
|
|
|
interfacePropertyName);
|
2013-02-12 14:29:09 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-18 14:24:41 +04:00
|
|
|
linkedTargetsContent =
|
|
|
|
cmGeneratorExpression::StripEmptyListElements(linkedTargetsContent);
|
|
|
|
|
2013-02-12 14:29:09 +04:00
|
|
|
if (!prop)
|
|
|
|
{
|
|
|
|
if (target->IsImported())
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2013-06-10 18:01:59 +04:00
|
|
|
for (size_t i = 1;
|
2012-09-23 15:45:17 +04:00
|
|
|
i < (sizeof(targetPropertyTransitiveWhitelist) /
|
|
|
|
sizeof(*targetPropertyTransitiveWhitelist));
|
|
|
|
++i)
|
|
|
|
{
|
2013-02-13 15:35:31 +04:00
|
|
|
if (targetPropertyTransitiveWhitelist[i] == interfacePropertyName)
|
2012-09-23 15:45:17 +04:00
|
|
|
{
|
|
|
|
cmGeneratorExpression ge(context->Backtrace);
|
2013-02-03 10:33:15 +04:00
|
|
|
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
|
|
|
|
std::string result = cge->Evaluate(context->Makefile,
|
2012-09-23 15:45:17 +04:00
|
|
|
context->Config,
|
|
|
|
context->Quiet,
|
2013-06-04 01:53:29 +04:00
|
|
|
headTarget,
|
2012-09-23 15:45:17 +04:00
|
|
|
target,
|
|
|
|
&dagChecker);
|
2013-02-03 10:33:15 +04:00
|
|
|
|
|
|
|
if (cge->GetHadContextSensitiveCondition())
|
|
|
|
{
|
|
|
|
context->HadContextSensitiveCondition = true;
|
|
|
|
}
|
2013-02-12 14:29:09 +04:00
|
|
|
if (!linkedTargetsContent.empty())
|
|
|
|
{
|
|
|
|
result += (result.empty() ? "" : ";") + linkedTargetsContent;
|
|
|
|
}
|
2013-02-03 10:33:15 +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;
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
cmPolicies::PolicyStatus statusForTarget(cmTarget *tgt, const char *policy)
|
|
|
|
{
|
|
|
|
#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(),
|
|
|
|
"$<TARGET_POLICY:prop> may only be used with targets. It may not "
|
|
|
|
"be used with add_custom_command.");
|
|
|
|
return std::string();
|
|
|
|
}
|
2013-02-03 10:33:15 +04:00
|
|
|
|
|
|
|
context->HadContextSensitiveCondition = true;
|
|
|
|
|
2013-06-28 13:25:40 +04:00
|
|
|
for (size_t i = 1;
|
2013-01-16 19:42:39 +04:00
|
|
|
i < (sizeof(targetPolicyWhitelist) /
|
|
|
|
sizeof(*targetPolicyWhitelist));
|
|
|
|
++i)
|
|
|
|
{
|
|
|
|
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
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
template<bool linker, bool soname>
|
|
|
|
struct TargetFilesystemArtifactResultCreator
|
|
|
|
{
|
|
|
|
static std::string Create(cmTarget* target,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *content);
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
template<>
|
|
|
|
struct TargetFilesystemArtifactResultCreator<false, true>
|
|
|
|
{
|
|
|
|
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<>
|
|
|
|
struct TargetFilesystemArtifactResultCreator<true, false>
|
|
|
|
{
|
|
|
|
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<>
|
|
|
|
struct TargetFilesystemArtifactResultCreator<false, false>
|
|
|
|
{
|
|
|
|
static std::string Create(cmTarget* target,
|
|
|
|
cmGeneratorExpressionContext *context,
|
|
|
|
const GeneratorExpressionContent *)
|
|
|
|
{
|
|
|
|
return target->GetFullPath(context->Config, false, true);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
template<bool dirQual, bool nameQual>
|
|
|
|
struct TargetFilesystemArtifactResultGetter
|
|
|
|
{
|
|
|
|
static std::string Get(const std::string &result);
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
template<>
|
|
|
|
struct TargetFilesystemArtifactResultGetter<false, true>
|
|
|
|
{
|
|
|
|
static std::string Get(const std::string &result)
|
|
|
|
{ return cmSystemTools::GetFilenameName(result); }
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
template<>
|
|
|
|
struct TargetFilesystemArtifactResultGetter<true, false>
|
|
|
|
{
|
|
|
|
static std::string Get(const std::string &result)
|
|
|
|
{ return cmSystemTools::GetFilenamePath(result); }
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
template<>
|
|
|
|
struct TargetFilesystemArtifactResultGetter<false, false>
|
|
|
|
{
|
|
|
|
static std::string Get(const std::string &result)
|
|
|
|
{ return result; }
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
template<bool linker, bool soname, bool dirQual, bool nameQual>
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
cmTarget* target = context->Makefile->FindTargetToUse(name.c_str());
|
|
|
|
if(!target)
|
|
|
|
{
|
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"No target \"" + name + "\"");
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
if(target->GetType() >= cmTarget::UTILITY &&
|
|
|
|
target->GetType() != cmTarget::UNKNOWN_LIBRARY)
|
|
|
|
{
|
|
|
|
::reportError(context, content->GetOriginalExpression(),
|
|
|
|
"Target \"" + name + "\" is not an executable or library.");
|
|
|
|
return std::string();
|
|
|
|
}
|
2013-06-14 18:25:29 +04:00
|
|
|
if (dagChecker && dagChecker->EvaluatingLinkLibraries(name.c_str()))
|
|
|
|
{
|
|
|
|
::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 =
|
|
|
|
TargetFilesystemArtifactResultCreator<linker, soname>::Create(
|
|
|
|
target,
|
|
|
|
context,
|
|
|
|
content);
|
|
|
|
if (context->HadError)
|
|
|
|
{
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
return
|
|
|
|
TargetFilesystemArtifactResultGetter<dirQual, nameQual>::Get(result);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const
|
|
|
|
TargetFilesystemArtifact<false, false, false, false> targetFileNode;
|
|
|
|
static const
|
|
|
|
TargetFilesystemArtifact<true, false, false, false> targetLinkerFileNode;
|
|
|
|
static const
|
|
|
|
TargetFilesystemArtifact<false, true, false, false> targetSoNameFileNode;
|
|
|
|
static const
|
|
|
|
TargetFilesystemArtifact<false, false, false, true> targetFileNameNode;
|
|
|
|
static const
|
|
|
|
TargetFilesystemArtifact<true, false, false, true> targetLinkerFileNameNode;
|
|
|
|
static const
|
|
|
|
TargetFilesystemArtifact<false, true, false, true> targetSoNameFileNameNode;
|
|
|
|
static const
|
|
|
|
TargetFilesystemArtifact<false, false, true, false> targetFileDirNode;
|
|
|
|
static const
|
|
|
|
TargetFilesystemArtifact<true, false, true, false> targetLinkerFileDirNode;
|
|
|
|
static const
|
|
|
|
TargetFilesystemArtifact<false, true, true, false> targetSoNameFileDirNode;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
static const
|
|
|
|
cmGeneratorExpressionNode* GetNode(const std::string &identifier)
|
|
|
|
{
|
|
|
|
if (identifier == "0")
|
|
|
|
return &zeroNode;
|
2012-12-10 14:32:42 +04:00
|
|
|
else if (identifier == "1")
|
2012-09-11 21:53:38 +04:00
|
|
|
return &oneNode;
|
2012-12-10 14:32:42 +04:00
|
|
|
else if (identifier == "AND")
|
2012-09-11 21:53:38 +04:00
|
|
|
return &andNode;
|
2012-12-10 14:32:42 +04:00
|
|
|
else if (identifier == "OR")
|
2012-09-11 21:53:38 +04:00
|
|
|
return &orNode;
|
2012-12-10 14:32:42 +04:00
|
|
|
else if (identifier == "NOT")
|
2012-09-11 21:53:38 +04:00
|
|
|
return ¬Node;
|
2013-05-28 14:17:25 +04:00
|
|
|
else if (identifier == "C_COMPILER_ID")
|
|
|
|
return &cCompilerIdNode;
|
|
|
|
else if (identifier == "CXX_COMPILER_ID")
|
|
|
|
return &cxxCompilerIdNode;
|
2013-06-11 11:53:10 +04:00
|
|
|
else if (identifier == "VERSION_GREATER")
|
|
|
|
return &versionGreaterNode;
|
|
|
|
else if (identifier == "VERSION_LESS")
|
|
|
|
return &versionLessNode;
|
|
|
|
else if (identifier == "VERSION_EQUAL")
|
|
|
|
return &versionEqualNode;
|
2013-06-11 12:48:47 +04:00
|
|
|
else if (identifier == "C_COMPILER_VERSION")
|
|
|
|
return &cCompilerVersionNode;
|
|
|
|
else if (identifier == "CXX_COMPILER_VERSION")
|
|
|
|
return &cxxCompilerVersionNode;
|
2012-09-11 21:53:38 +04:00
|
|
|
else if (identifier == "CONFIGURATION")
|
|
|
|
return &configurationNode;
|
|
|
|
else if (identifier == "CONFIG")
|
|
|
|
return &configurationTestNode;
|
2013-05-16 17:52:25 +04:00
|
|
|
else if (identifier == "LINK_LANGUAGE")
|
|
|
|
return &linkLanguageNode;
|
2012-09-11 21:53:38 +04:00
|
|
|
else if (identifier == "TARGET_FILE")
|
|
|
|
return &targetFileNode;
|
|
|
|
else if (identifier == "TARGET_LINKER_FILE")
|
|
|
|
return &targetLinkerFileNode;
|
|
|
|
else if (identifier == "TARGET_SONAME_FILE")
|
|
|
|
return &targetSoNameFileNode;
|
|
|
|
else if (identifier == "TARGET_FILE_NAME")
|
|
|
|
return &targetFileNameNode;
|
|
|
|
else if (identifier == "TARGET_LINKER_FILE_NAME")
|
|
|
|
return &targetLinkerFileNameNode;
|
|
|
|
else if (identifier == "TARGET_SONAME_FILE_NAME")
|
|
|
|
return &targetSoNameFileNameNode;
|
|
|
|
else if (identifier == "TARGET_FILE_DIR")
|
|
|
|
return &targetFileDirNode;
|
|
|
|
else if (identifier == "TARGET_LINKER_FILE_DIR")
|
|
|
|
return &targetLinkerFileDirNode;
|
|
|
|
else if (identifier == "TARGET_SONAME_FILE_DIR")
|
|
|
|
return &targetSoNameFileDirNode;
|
2012-09-12 06:20:42 +04:00
|
|
|
else if (identifier == "STREQUAL")
|
|
|
|
return &strEqualNode;
|
|
|
|
else if (identifier == "BOOL")
|
|
|
|
return &boolNode;
|
|
|
|
else if (identifier == "ANGLE-R")
|
|
|
|
return &angle_rNode;
|
|
|
|
else if (identifier == "COMMA")
|
|
|
|
return &commaNode;
|
2013-03-12 10:52:01 +04:00
|
|
|
else if (identifier == "SEMICOLON")
|
|
|
|
return &semicolonNode;
|
2012-09-12 06:23:31 +04:00
|
|
|
else if (identifier == "TARGET_PROPERTY")
|
|
|
|
return &targetPropertyNode;
|
2012-12-10 14:33:23 +04:00
|
|
|
else if (identifier == "TARGET_NAME")
|
|
|
|
return &targetNameNode;
|
2013-01-16 19:42:39 +04:00
|
|
|
else if (identifier == "TARGET_POLICY")
|
|
|
|
return &targetPolicyNode;
|
2012-09-23 15:16:44 +04:00
|
|
|
else if (identifier == "BUILD_INTERFACE")
|
|
|
|
return &buildInterfaceNode;
|
|
|
|
else if (identifier == "INSTALL_INTERFACE")
|
|
|
|
return &installInterfaceNode;
|
2013-01-27 12:43:44 +04:00
|
|
|
else if (identifier == "INSTALL_PREFIX")
|
|
|
|
return &installPrefixNode;
|
2013-02-26 03:50:49 +04:00
|
|
|
else if (identifier == "JOIN")
|
|
|
|
return &joinNode;
|
2013-06-05 15:43:54 +04:00
|
|
|
else if (identifier == "LINK_ONLY")
|
|
|
|
return &linkOnlyNode;
|
2012-09-11 21:53:38 +04:00
|
|
|
return 0;
|
2012-09-12 06:23:31 +04:00
|
|
|
|
2012-09-11 21:53:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
GeneratorExpressionContent::GeneratorExpressionContent(
|
|
|
|
const char *startContent,
|
|
|
|
unsigned int length)
|
|
|
|
: 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();
|
|
|
|
}
|
|
|
|
|
2013-04-25 15:28:57 +04:00
|
|
|
if (node->NumExpectedParameters() == 1
|
|
|
|
&& node->AcceptsArbitraryContentParameter())
|
2012-09-11 21:53:38 +04:00
|
|
|
{
|
2013-04-25 15:54:18 +04:00
|
|
|
return this->ProcessArbitraryContent(node, identifier, context,
|
|
|
|
dagChecker,
|
|
|
|
this->ParamChildren.begin());
|
2012-09-11 21:53:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
2012-09-11 21:53:38 +04:00
|
|
|
for ( ; pit != pend; ++pit)
|
|
|
|
{
|
|
|
|
std::string parameter;
|
|
|
|
std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it =
|
|
|
|
pit->begin();
|
|
|
|
const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end =
|
|
|
|
pit->end();
|
|
|
|
for ( ; it != end; ++it)
|
|
|
|
{
|
2012-09-18 15:42:23 +04:00
|
|
|
parameter += (*it)->Evaluate(context, dagChecker);
|
2012-09-11 21:53:38 +04:00
|
|
|
if (context->HadError)
|
|
|
|
{
|
|
|
|
return std::string();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
parameters.push_back(parameter);
|
2013-04-25 15:54:57 +04:00
|
|
|
if (acceptsArbitraryContent
|
|
|
|
&& parameters.size() == (unsigned int)numExpected - 1)
|
|
|
|
{
|
|
|
|
assert(pit != pend);
|
|
|
|
std::string lastParam = this->ProcessArbitraryContent(node, identifier,
|
|
|
|
context,
|
|
|
|
dagChecker,
|
|
|
|
pit + 1);
|
|
|
|
parameters.push_back(lastParam);
|
|
|
|
return std::string();
|
|
|
|
}
|
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.");
|
|
|
|
}
|
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);
|
|
|
|
}
|
|
|
|
}
|