diff options
Diffstat (limited to 'Source/cmGeneratorExpression.cxx')
-rw-r--r-- | Source/cmGeneratorExpression.cxx | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index ab8bd137e..d73c72c10 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,16 +225,42 @@ 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); } //---------------------------------------------------------------------------- +static void prefixItems(const std::string &content, std::string &result, + const std::string &prefix) +{ + std::vector<std::string> entries; + cmGeneratorExpression::Split(content, entries); + const char *sep = ""; + for(std::vector<std::string>::const_iterator ei = entries.begin(); + ei != entries.end(); ++ei) + { + result += sep; + sep = ";"; + if (!cmSystemTools::FileIsFullPath(ei->c_str()) + && cmGeneratorExpression::Find(*ei) == std::string::npos) + { + result += prefix; + } + result += *ei; + } +} + +//---------------------------------------------------------------------------- static std::string stripExportInterface(const std::string &input, - cmGeneratorExpression::PreprocessContext context) + cmGeneratorExpression::PreprocessContext context, + bool resolveRelative) { std::string result; + int nestingLevel = 0; std::string::size_type pos = 0; std::string::size_type lastPos = pos; while (true) @@ -263,7 +290,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) @@ -289,7 +316,15 @@ static std::string stripExportInterface(const std::string &input, else if(context == cmGeneratorExpression::InstallInterface && gotInstallInterface) { - result += input.substr(pos, c - cStart); + const std::string content = input.substr(pos, c - cStart); + if (resolveRelative) + { + prefixItems(content, result, "${_IMPORT_PREFIX}/"); + } + else + { + result += content; + } } break; } @@ -304,7 +339,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); } @@ -380,7 +418,8 @@ void cmGeneratorExpression::Split(const std::string &input, //---------------------------------------------------------------------------- std::string cmGeneratorExpression::Preprocess(const std::string &input, - PreprocessContext context) + PreprocessContext context, + bool resolveRelative) { if (context == StripAllGeneratorExpressions) { @@ -388,7 +427,7 @@ std::string cmGeneratorExpression::Preprocess(const std::string &input, } else if (context == BuildInterface || context == InstallInterface) { - return stripExportInterface(input, context); + return stripExportInterface(input, context, resolveRelative); } assert(!"cmGeneratorExpression::Preprocess called with invalid args"); |