diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index a6f8159c8..26eadbe52 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -398,11 +398,14 @@ cmNinjaTargetGenerator depfile = "$DEP_FILE"; const std::string flagsName = "CMAKE_DEPFILE_FLAGS_" + lang; std::string depfileFlags = mf->GetSafeDefinition(flagsName.c_str()); - cmSystemTools::ReplaceString(depfileFlags, "", "$DEP_FILE"); - cmSystemTools::ReplaceString(depfileFlags, "", "$out"); - cmSystemTools::ReplaceString(depfileFlags, "", - mf->GetDefinition("CMAKE_C_COMPILER")); - flags += " " + depfileFlags; + if (!depfileFlags.empty()) + { + cmSystemTools::ReplaceString(depfileFlags, "", "$DEP_FILE"); + cmSystemTools::ReplaceString(depfileFlags, "", "$out"); + cmSystemTools::ReplaceString(depfileFlags, "", + mf->GetDefinition("CMAKE_C_COMPILER")); + flags += " " + depfileFlags; + } } vars.Flags = flags.c_str();