mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
cmPlaceHolderExpander: Add recognition of genex
Add a mode to ensure genex at kept as is.
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
|
||||
#include "cmsys/String.h"
|
||||
|
||||
std::string& cmPlaceholderExpander::ExpandVariables(std::string& s)
|
||||
std::string& cmPlaceholderExpander::ExpandVariables(std::string& s,
|
||||
HandleGenex handleGenex)
|
||||
{
|
||||
std::string::size_type start = s.find('<');
|
||||
// no variables to expand
|
||||
@@ -14,6 +15,13 @@ std::string& cmPlaceholderExpander::ExpandVariables(std::string& s)
|
||||
std::string::size_type pos = 0;
|
||||
std::string expandedInput;
|
||||
while (start != std::string::npos && start < s.size() - 2) {
|
||||
if (handleGenex == HandleGenex::Yes && start != 0 && s[start - 1] == '$') {
|
||||
// this is a generator expression
|
||||
// skip it and try to find the next < in the string
|
||||
start = s.find('<', start + 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string::size_type end = s.find('>', start);
|
||||
// if we find a < with no > we are done
|
||||
if (end == std::string::npos) {
|
||||
|
||||
@@ -10,9 +10,16 @@
|
||||
class cmPlaceholderExpander
|
||||
{
|
||||
public:
|
||||
enum class HandleGenex
|
||||
{
|
||||
No,
|
||||
Yes
|
||||
};
|
||||
|
||||
virtual ~cmPlaceholderExpander() = default;
|
||||
|
||||
std::string& ExpandVariables(std::string& string);
|
||||
std::string& ExpandVariables(std::string& string,
|
||||
HandleGenex handleGenex = HandleGenex::No);
|
||||
|
||||
protected:
|
||||
virtual std::string ExpandVariable(std::string const& variable) = 0;
|
||||
|
||||
Reference in New Issue
Block a user