diff options
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 25be6cd..02ae60f 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -67,7 +67,8 @@ cmMakefile::cmMakefile() this->AddSourceGroup("Header Files", "\\.(h|h\\+\\+|hm|hpp|hxx|in|txx|inl)$"); this->AddSourceGroup("CMake Rules", "\\.rule$"); this->AddDefaultDefinitions(); -} + m_cmDefineRegex.compile("#cmakedefine[ \t]*([A-Za-z_0-9]*)"); + } const char* cmMakefile::GetReleaseVersion() { @@ -2207,3 +2208,64 @@ std::string cmMakefile::GetModulesFile(const char* filename) } return ""; } + +void cmMakefile::ConfigureString(const std::string& input, + std::string& output, bool atOnly, + bool escapeQuotes) +{ + // Split input to handle one line at a time. + std::string::const_iterator lineStart = input.begin(); + while(lineStart != input.end()) + { + // Find the end of this line. + std::string::const_iterator lineEnd = lineStart; + while(lineEnd != input.end() && *lineEnd != '\n') + { + ++lineEnd; + } + + // Copy the line. + std::string line(lineStart, lineEnd); + + // Skip the newline character. + bool haveNewline = (lineEnd != input.end()); + if(haveNewline) + { + ++lineEnd; + } + + // Replace #cmakedefine instances. + if(m_cmDefineRegex.find(line)) + { + const char* def = this->GetDefinition(m_cmDefineRegex.match(1).c_str()); + if(!cmSystemTools::IsOff(def)) + { + cmSystemTools::ReplaceString(line, "#cmakedefine", "#define"); + output += line; + } + else + { + cmSystemTools::ReplaceString(line, "#cmakedefine", "#undef"); + output += "/* "; + output += line; + output += " */"; + } + } + else + { + output += line; + } + + if(haveNewline) + { + output += "\n"; + } + + // Move to the next line. + lineStart = lineEnd; + } + + // Perform variable replacements. + this->ExpandVariablesInString(output, escapeQuotes, atOnly); + this->RemoveVariablesInString(output, atOnly); +} |