Ninja: add dependency tracking for msvc with cldeps
This commit is contained in:
parent
e3a1f727f7
commit
1d40729eaa
|
@ -330,12 +330,17 @@ cmNinjaTargetGenerator
|
||||||
vars.Defines = "$DEFINES";
|
vars.Defines = "$DEFINES";
|
||||||
vars.TargetPDB = "$TARGET_PDB";
|
vars.TargetPDB = "$TARGET_PDB";
|
||||||
|
|
||||||
|
bool cldeps = false;
|
||||||
|
const char* cc = this->GetMakefile()->GetDefinition("CMAKE_C_COMPILER");
|
||||||
|
if(cc && std::string(cc).find("cl.exe") != std::string::npos)
|
||||||
|
cldeps = true;
|
||||||
|
|
||||||
std::string depfile;
|
std::string depfile;
|
||||||
std::string depfileFlagsName = "CMAKE_DEPFILE_FLAGS_" + language;
|
std::string depfileFlagsName = "CMAKE_DEPFILE_FLAGS_" + language;
|
||||||
const char *depfileFlags =
|
const char *depfileFlags =
|
||||||
this->GetMakefile()->GetDefinition(depfileFlagsName.c_str());
|
this->GetMakefile()->GetDefinition(depfileFlagsName.c_str());
|
||||||
if (depfileFlags) {
|
if (depfileFlags || cldeps) {
|
||||||
std::string depfileFlagsStr = depfileFlags;
|
std::string depfileFlagsStr = depfileFlags ? depfileFlags : "";
|
||||||
depfile = "$out.d";
|
depfile = "$out.d";
|
||||||
cmSystemTools::ReplaceString(depfileFlagsStr, "<DEPFILE>",
|
cmSystemTools::ReplaceString(depfileFlagsStr, "<DEPFILE>",
|
||||||
depfile.c_str());
|
depfile.c_str());
|
||||||
|
@ -364,6 +369,9 @@ cmNinjaTargetGenerator
|
||||||
std::string cmdLine =
|
std::string cmdLine =
|
||||||
this->GetLocalGenerator()->BuildCommandLine(compileCmds);
|
this->GetLocalGenerator()->BuildCommandLine(compileCmds);
|
||||||
|
|
||||||
|
if(cldeps)
|
||||||
|
cmdLine = "cldeps.exe $out.d $out " + cmdLine;
|
||||||
|
|
||||||
// Write the rule for compiling file of the given language.
|
// Write the rule for compiling file of the given language.
|
||||||
std::ostringstream comment;
|
std::ostringstream comment;
|
||||||
comment << "Rule for compiling " << language << " files.";
|
comment << "Rule for compiling " << language << " files.";
|
||||||
|
|
Loading…
Reference in New Issue