diff options
author | David Cole <david.cole@kitware.com> | 2012-07-09 18:21:22 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2012-07-09 18:21:22 (GMT) |
commit | 8947f11d078197e410ddf3235beeda5193fbb59e (patch) | |
tree | 1dd39bd8310ac85f6c3090034dc0308b51ff6c93 /Source/cmGlobalNinjaGenerator.cxx | |
parent | f70f55c064d2b3a761a32b84ca39ee25377300c5 (diff) | |
parent | ca403b8c436e25e2fe5de5144fecf7aef8b5de78 (diff) | |
download | CMake-8947f11d078197e410ddf3235beeda5193fbb59e.zip CMake-8947f11d078197e410ddf3235beeda5193fbb59e.tar.gz CMake-8947f11d078197e410ddf3235beeda5193fbb59e.tar.bz2 |
Merge topic 'Ninja-absolute-compile-commands'
ca403b8 Construct the full path before escaping it.
f9383a9 STYLE: Fix line length, remove extra blank line
e30d46e Use full paths in compile_commands.json for out of source builds.
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 11 |
1 files changed, 10 insertions, 1 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" << "}"; } |