summaryrefslogtreecommitdiffstats
path: root/Source/cmNinjaTargetGenerator.cxx
diff options
context:
space:
mode:
authorPeter Kuemmel <syntheticpp@gmx.net>2012-06-08 14:31:54 (GMT)
committerPeter Kuemmel <syntheticpp@gmx.net>2012-06-08 15:42:11 (GMT)
commit033a687acd828ad6667d154939ffdbc482ab047f (patch)
tree7e61efbc88da39b57810be42d502baaab0145136 /Source/cmNinjaTargetGenerator.cxx
parent1d40729eaa35dd643efdf5e793e6a541e890f33a (diff)
downloadCMake-033a687acd828ad6667d154939ffdbc482ab047f.zip
CMake-033a687acd828ad6667d154939ffdbc482ab047f.tar.gz
CMake-033a687acd828ad6667d154939ffdbc482ab047f.tar.bz2
Ninja: add wrapper for cl to extract dependencies
cmcldeps wraps cl and adds /showInclude before calling cl. It parses the output of cl for used headers, drops system headers and writes them to a GCC like dependency file. cmcldeps uses ATM ninja code for process handling, but could be ported later to SystemTools. TODO: Why needs ninja multiple calls in the BuildDepends test?
Diffstat (limited to 'Source/cmNinjaTargetGenerator.cxx')
-rw-r--r--Source/cmNinjaTargetGenerator.cxx17
1 files changed, 12 insertions, 5 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 74b5c92..6518727 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -330,16 +330,20 @@ cmNinjaTargetGenerator
vars.Defines = "$DEFINES";
vars.TargetPDB = "$TARGET_PDB";
- bool cldeps = false;
+ const char* cldeps = 0;
+ const char* showIncludePrefix = 0;
const char* cc = this->GetMakefile()->GetDefinition("CMAKE_C_COMPILER");
if(cc && std::string(cc).find("cl.exe") != std::string::npos)
- cldeps = true;
+ {
+ cldeps = this->GetMakefile()->GetDefinition("CMAKE_CMCLDEPS_EXECUTABLE");
+ showIncludePrefix = this->GetMakefile()->GetDefinition("CMAKE_CL_SHOWINCLUDE_PREFIX");
+ }
std::string depfile;
std::string depfileFlagsName = "CMAKE_DEPFILE_FLAGS_" + language;
const char *depfileFlags =
this->GetMakefile()->GetDefinition(depfileFlagsName.c_str());
- if (depfileFlags || cldeps) {
+ if (depfileFlags || (cldeps && showIncludePrefix)) {
std::string depfileFlagsStr = depfileFlags ? depfileFlags : "";
depfile = "$out.d";
cmSystemTools::ReplaceString(depfileFlagsStr, "<DEPFILE>",
@@ -369,8 +373,11 @@ cmNinjaTargetGenerator
std::string cmdLine =
this->GetLocalGenerator()->BuildCommandLine(compileCmds);
- if(cldeps)
- cmdLine = "cldeps.exe $out.d $out " + cmdLine;
+ if(cldeps && showIncludePrefix)
+ {
+ std::string prefix = showIncludePrefix;
+ cmdLine = std::string(cldeps) + " $in $out.d $out " + "\"" + prefix + "\" " + cmdLine;
+ }
// Write the rule for compiling file of the given language.
std::ostringstream comment;