summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Cole <david.cole@kitware.com>2012-07-09 18:21:22 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2012-07-09 18:21:22 (GMT)
commit8947f11d078197e410ddf3235beeda5193fbb59e (patch)
tree1dd39bd8310ac85f6c3090034dc0308b51ff6c93
parentf70f55c064d2b3a761a32b84ca39ee25377300c5 (diff)
parentca403b8c436e25e2fe5de5144fecf7aef8b5de78 (diff)
downloadCMake-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.
-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();