Ninja: Substitute <OBJECT> and <CMAKE_C_COMPILER> in depfile flags
Patch by Amine Khaldi! Also, start using the -MT flag to set a target name for depfiles. This works around a bug observed in distcc, as explained in the comment. Based on a patch by Alexander Usov.
This commit is contained in:
parent
c337c7e205
commit
6b5614f164
|
@ -30,7 +30,10 @@ macro(__compiler_gnu lang)
|
||||||
# in try_compile mode.
|
# in try_compile mode.
|
||||||
GET_PROPERTY(_IN_TC GLOBAL PROPERTY IN_TRY_COMPILE)
|
GET_PROPERTY(_IN_TC GLOBAL PROPERTY IN_TRY_COMPILE)
|
||||||
if(NOT _IN_TC OR CMAKE_FORCE_DEPFILES)
|
if(NOT _IN_TC OR CMAKE_FORCE_DEPFILES)
|
||||||
set(CMAKE_DEPFILE_FLAGS_${lang} "-MMD -MF <DEPFILE>")
|
# distcc does not transform -o to -MT when invoking the preprocessor
|
||||||
|
# internally, as it ought to. Work around this bug by setting -MT here
|
||||||
|
# even though it isn't strictly necessary.
|
||||||
|
set(CMAKE_DEPFILE_FLAGS_${lang} "-MMD -MT <OBJECT> -MF <DEPFILE>")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Initial configuration flags.
|
# Initial configuration flags.
|
||||||
|
|
|
@ -331,6 +331,10 @@ cmNinjaTargetGenerator
|
||||||
depfile = "$out.d";
|
depfile = "$out.d";
|
||||||
cmSystemTools::ReplaceString(depfileFlagsStr, "<DEPFILE>",
|
cmSystemTools::ReplaceString(depfileFlagsStr, "<DEPFILE>",
|
||||||
depfile.c_str());
|
depfile.c_str());
|
||||||
|
cmSystemTools::ReplaceString(depfileFlagsStr, "<OBJECT>",
|
||||||
|
"$out");
|
||||||
|
cmSystemTools::ReplaceString(depfileFlagsStr, "<CMAKE_C_COMPILER>",
|
||||||
|
this->GetMakefile()->GetDefinition("CMAKE_C_COMPILER"));
|
||||||
flags += " " + depfileFlagsStr;
|
flags += " " + depfileFlagsStr;
|
||||||
}
|
}
|
||||||
vars.Flags = flags.c_str();
|
vars.Flags = flags.c_str();
|
||||||
|
|
Loading…
Reference in New Issue