summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorExpression.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-09-13 15:22:05 (GMT)
committerStephen Kelly <steveire@gmail.com>2013-09-13 16:21:37 (GMT)
commit70089d0769902c58da925eb571ad430bec40e9da (patch)
treee3c60a46e9606b02cda55f29a9148ce331ca22e4 /Source/cmGeneratorExpression.cxx
parent1fef29e4c63ca5331670257f67505e06725a8c82 (diff)
downloadCMake-70089d0769902c58da925eb571ad430bec40e9da.zip
CMake-70089d0769902c58da925eb571ad430bec40e9da.tar.gz
CMake-70089d0769902c58da925eb571ad430bec40e9da.tar.bz2
genex: Fix preprocessing with incomplete content (#14410).
Similar incomplete generator expressions are already tested in the GeneratorExpression unit test, but those are executed with add_custom_target. The generator expressions in the include directories are run through the preprocessor, whereas the ones run through add_custom_target are not.
Diffstat (limited to 'Source/cmGeneratorExpression.cxx')
-rw-r--r--Source/cmGeneratorExpression.cxx16
1 files changed, 12 insertions, 4 deletions
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index e962313..127cf6b 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -192,11 +192,12 @@ static std::string stripAllGeneratorExpressions(const std::string &input)
std::string result;
std::string::size_type pos = 0;
std::string::size_type lastPos = pos;
+ int nestingLevel = 0;
while((pos = input.find("$<", lastPos)) != input.npos)
{
result += input.substr(lastPos, pos - lastPos);
pos += 2;
- int nestingLevel = 1;
+ nestingLevel = 1;
const char *c = input.c_str() + pos;
const char * const cStart = c;
for ( ; *c; ++c)
@@ -224,7 +225,10 @@ static std::string stripAllGeneratorExpressions(const std::string &input)
pos += traversed;
lastPos = pos;
}
- result += input.substr(lastPos);
+ if (nestingLevel == 0)
+ {
+ result += input.substr(lastPos);
+ }
return cmGeneratorExpression::StripEmptyListElements(result);
}
@@ -253,6 +257,7 @@ static std::string stripExportInterface(const std::string &input,
{
std::string result;
+ int nestingLevel = 0;
std::string::size_type pos = 0;
std::string::size_type lastPos = pos;
while (true)
@@ -282,7 +287,7 @@ static std::string stripExportInterface(const std::string &input,
const bool gotInstallInterface = input[pos + 2] == 'I';
pos += gotInstallInterface ? sizeof("$<INSTALL_INTERFACE:") - 1
: sizeof("$<BUILD_INTERFACE:") - 1;
- int nestingLevel = 1;
+ nestingLevel = 1;
const char *c = input.c_str() + pos;
const char * const cStart = c;
for ( ; *c; ++c)
@@ -331,7 +336,10 @@ static std::string stripExportInterface(const std::string &input,
pos += traversed;
lastPos = pos;
}
- result += input.substr(lastPos);
+ if (nestingLevel == 0)
+ {
+ result += input.substr(lastPos);
+ }
return cmGeneratorExpression::StripEmptyListElements(result);
}