cmPlaceHolderExpander: Add recognition of genex

Add a mode to ensure genex at kept as is.
This commit is contained in:
Marc Chevrier
2026-09-14 18:24:48 +02:00
parent b53f05cd8c
commit a570ee4c8f
2 changed files with 17 additions and 2 deletions
+9 -1
View File
@@ -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) {
+8 -1
View File
@@ -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;