summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx11
-rw-r--r--Source/cmNinjaTargetGenerator.cxx16
2 files changed, 24 insertions, 3 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index c3989c0..8014c41 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -701,13 +701,22 @@ void cmGlobalNinjaGenerator::AddCXXCompileCommand(
*this->CompileCommandsStream << "," << std::endl;
}
+ std::string sourceFileName = sourceFile;
+ if (!cmSystemTools::FileIsFullPath(sourceFileName.c_str()))
+ {
+ sourceFileName = cmSystemTools::CollapseFullPath(
+ sourceFileName.c_str(),
+ this->GetCMakeInstance()->GetHomeOutputDirectory());
+ }
+
+
*this->CompileCommandsStream << "\n{\n"
<< " \"directory\": \""
<< cmGlobalGenerator::EscapeJSON(buildFileDir) << "\",\n"
<< " \"command\": \""
<< cmGlobalGenerator::EscapeJSON(commandLine) << "\",\n"
<< " \"file\": \""
- << cmGlobalGenerator::EscapeJSON(sourceFile) << "\"\n"
+ << cmGlobalGenerator::EscapeJSON(sourceFileName) << "\"\n"
<< "}";
}
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 6157931..4758989 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -534,9 +534,21 @@ cmNinjaTargetGenerator
cmLocalGenerator::RuleVariables compileObjectVars;
std::string lang = language;
compileObjectVars.Language = lang.c_str();
- std::string escapedSourceFileName =
+
+ std::string escapedSourceFileName = sourceFileName;
+
+ if (!cmSystemTools::FileIsFullPath(sourceFileName.c_str()))
+ {
+ escapedSourceFileName = cmSystemTools::CollapseFullPath(
+ escapedSourceFileName.c_str(),
+ this->GetGlobalGenerator()->GetCMakeInstance()->
+ GetHomeOutputDirectory());
+ }
+
+ escapedSourceFileName =
this->LocalGenerator->ConvertToOutputFormat(
- sourceFileName.c_str(), cmLocalGenerator::SHELL);
+ escapedSourceFileName.c_str(), cmLocalGenerator::SHELL);
+
compileObjectVars.Source = escapedSourceFileName.c_str();
compileObjectVars.Object = objectFileName.c_str();
compileObjectVars.Flags = vars["FLAGS"].c_str();