mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-12 17:19:05 -05:00
Merge topic 'nmake-compile-commands'
37c6a02dc2CMake: fix nmake compile_commands generation7583f7490ecmGlobalGenerator: Teach EscapeJSON to escape newlines and tabs Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2648
This commit is contained in:
@@ -3023,11 +3023,23 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
|
||||
std::string cmGlobalGenerator::EscapeJSON(const std::string& s)
|
||||
{
|
||||
std::string result;
|
||||
result.reserve(s.size());
|
||||
for (char i : s) {
|
||||
if (i == '"' || i == '\\') {
|
||||
result += '\\';
|
||||
switch (i) {
|
||||
case '"':
|
||||
case '\\':
|
||||
result += '\\';
|
||||
result += i;
|
||||
break;
|
||||
case '\n':
|
||||
result += "\\n";
|
||||
break;
|
||||
case '\t':
|
||||
result += "\\t";
|
||||
break;
|
||||
default:
|
||||
result += i;
|
||||
}
|
||||
result += i;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -687,6 +687,17 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
|
||||
std::string langIncludes = std::string("$(") + lang + "_INCLUDES)";
|
||||
compileCommand.replace(compileCommand.find(langIncludes),
|
||||
langIncludes.size(), this->GetIncludes(lang));
|
||||
|
||||
const char* eliminate[] = {
|
||||
this->Makefile->GetDefinition("CMAKE_START_TEMP_FILE"),
|
||||
this->Makefile->GetDefinition("CMAKE_END_TEMP_FILE")
|
||||
};
|
||||
for (const char* el : eliminate) {
|
||||
if (el) {
|
||||
cmSystemTools::ReplaceString(compileCommand, el, "");
|
||||
}
|
||||
}
|
||||
|
||||
this->GlobalGenerator->AddCXXCompileCommand(
|
||||
source.GetFullPath(), workingDirectory, compileCommand);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user