summaryrefslogtreecommitdiff
path: root/Source/cmExportFileGenerator.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-01-30 23:38:04 +0100
committerStephen Kelly <steveire@gmail.com>2013-01-31 17:34:20 +0100
commit0b92602b816e2584db3781b120a1e5200da72ada (patch)
treeccf0d78b89d14d2bc317725b81ff3281d8b83ed1 /Source/cmExportFileGenerator.cxx
parent0fa7f69c0e2cdcd8b7ece400651ee7821b2ede4b (diff)
downloadcmake-0b92602b816e2584db3781b120a1e5200da72ada.tar.gz
Add the $<LINKED:...> generator expression.
This is both a short form of using a TARGET_DEFINED expression together with a TARGET_PROPERTY definition, and a way to strip non-target content from interface properties when exporting.
Diffstat (limited to 'Source/cmExportFileGenerator.cxx')
-rw-r--r--Source/cmExportFileGenerator.cxx66
1 files changed, 60 insertions, 6 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 2ecac8477f..7e4c3dfe5a 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -25,6 +25,8 @@
#include <cmsys/auto_ptr.hxx>
+#include "assert.h"
+
//----------------------------------------------------------------------------
cmExportFileGenerator::cmExportFileGenerator()
{
@@ -160,7 +162,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
preprocessRule);
if (!prepro.empty())
{
- this->ResolveTargetsInGeneratorExpressions(prepro, target,
+ this->ResolveTargetsInGeneratorExpressions(prepro, target, propName,
missingTargets);
properties[outputName] = prepro;
}
@@ -324,13 +326,14 @@ static bool isGeneratorExpression(const std::string &lib)
void
cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
std::string &input,
- cmTarget* target,
+ cmTarget* target, const char *propName,
std::vector<std::string> &missingTargets,
FreeTargetsReplace replace)
{
if (replace == NoReplaceFreeTargets)
{
- this->ResolveTargetsInGeneratorExpression(input, target, missingTargets);
+ this->ResolveTargetsInGeneratorExpression(input, target, propName,
+ missingTargets);
return;
}
std::vector<std::string> parts;
@@ -349,7 +352,7 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
{
this->ResolveTargetsInGeneratorExpression(
*li,
- target,
+ target, propName,
missingTargets);
}
input += sep + *li;
@@ -361,7 +364,7 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpressions(
void
cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
std::string &input,
- cmTarget* target,
+ cmTarget* target, const char *propName,
std::vector<std::string> &missingTargets)
{
std::string::size_type pos = 0;
@@ -398,6 +401,57 @@ cmExportFileGenerator::ResolveTargetsInGeneratorExpression(
std::string errorString;
pos = 0;
lastPos = pos;
+ while((pos = input.find("$<LINKED:", lastPos)) != input.npos)
+ {
+ std::string::size_type nameStartPos = pos + sizeof("$<LINKED:") - 1;
+ std::string::size_type endPos = input.find(">", nameStartPos);
+ if (endPos == input.npos)
+ {
+ errorString = "$<LINKED:...> expression incomplete";
+ break;
+ }
+ std::string targetName = input.substr(nameStartPos,
+ endPos - nameStartPos);
+ if(targetName.find("$<") != input.npos)
+ {
+ errorString = "$<LINKED:...> requires its parameter to be a "
+ "literal.";
+ break;
+ }
+ if (this->AddTargetNamespace(targetName, target, missingTargets))
+ {
+ assert(propName); // The link libraries strings will
+ // never contain $<LINKED>
+ std::string replacement = "$<TARGET_PROPERTY:"
+ + targetName + "," + propName;
+ input.replace(pos, endPos - pos, replacement);
+ lastPos = pos + replacement.size() + 1;
+ }
+ else
+ {
+ if (pos != 0)
+ {
+ if (input[pos - 1] == ';')
+ {
+ --pos;
+ }
+ }
+ else if (input[endPos + 1] == ';')
+ {
+ ++endPos;
+ }
+ input.replace(pos, endPos - pos + 1, "");
+ lastPos = pos;
+ }
+ }
+ if (!errorString.empty())
+ {
+ mf->IssueMessage(cmake::FATAL_ERROR, errorString);
+ return;
+ }
+
+ pos = 0;
+ lastPos = pos;
while((pos = input.find("$<TARGET_NAME:", lastPos)) != input.npos)
{
std::string::size_type nameStartPos = pos + sizeof("$<TARGET_NAME:") - 1;
@@ -491,7 +545,7 @@ cmExportFileGenerator
preprocessRule);
if (!prepro.empty())
{
- this->ResolveTargetsInGeneratorExpressions(prepro, target,
+ this->ResolveTargetsInGeneratorExpressions(prepro, target, 0,
missingTargets,
ReplaceFreeTargets);
properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix] = prepro;