summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalNinjaGenerator.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2012-06-18 17:59:33 (GMT)
committerStephen Kelly <steveire@gmail.com>2012-06-19 07:01:28 (GMT)
commite30d46e20ee71d57e09f83fafa39b7e464efe110 (patch)
treec2a4ed0ea02f844272200031ca19a19462205573 /Source/cmGlobalNinjaGenerator.cxx
parent1d8199ffecbd8881c38e0e63ee07844a50abac49 (diff)
downloadCMake-e30d46e20ee71d57e09f83fafa39b7e464efe110.zip
CMake-e30d46e20ee71d57e09f83fafa39b7e464efe110.tar.gz
CMake-e30d46e20ee71d57e09f83fafa39b7e464efe110.tar.bz2
Use full paths in compile_commands.json for out of source builds.
Clang tooling requires that paths in the directory and file JSON fields are relative to the directory field, but clang doesn't normalize the paths already. The result is that clang doesn't find the relevant entry for files which begin with ../.
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx11
1 files changed, 10 insertions, 1 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 40348e6..f21cddb 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -644,13 +644,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"
<< "}";
}