diff options
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 22fd90d..55eb9b5 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -378,6 +378,15 @@ void cmGlobalNinjaGenerator::WriteCustomCommandBuild( } { + std::string ninjaDepfilePath; + bool depfileIsOutput = false; + if (!depfile.empty()) { + ninjaDepfilePath = this->ConvertToNinjaPath(depfile); + depfileIsOutput = + std::find(outputs.ExplicitOuts.begin(), outputs.ExplicitOuts.end(), + ninjaDepfilePath) != outputs.ExplicitOuts.end(); + } + cmNinjaBuild build("CUSTOM_COMMAND"); build.Comment = comment; build.Outputs = std::move(outputs.ExplicitOuts); @@ -405,7 +414,13 @@ void cmGlobalNinjaGenerator::WriteCustomCommandBuild( vars["pool"] = job_pool; } if (!depfile.empty()) { - vars["depfile"] = depfile; + vars["depfile"] = ninjaDepfilePath; + // Add the depfile to the `.ninja_deps` database. Since this (generally) + // removes the file, it cannot be declared as an output or byproduct of + // the command. + if (!depfileIsOutput) { + vars["deps"] = "gcc"; + } } if (config.empty()) { this->WriteBuild(*this->GetCommonFileStream(), build); @@ -1359,10 +1374,10 @@ void cmGlobalNinjaGenerator::AppendTargetDepends( } else { cmNinjaDeps outs; - auto computeISPCOuputs = [](cmGlobalNinjaGenerator* gg, - cmGeneratorTarget const* depTarget, - cmNinjaDeps& outputDeps, - const std::string& targetConfig) { + auto computeISPCOutputs = [](cmGlobalNinjaGenerator* gg, + cmGeneratorTarget const* depTarget, + cmNinjaDeps& outputDeps, + const std::string& targetConfig) { if (depTarget->CanCompileSources()) { auto headers = depTarget->GetGeneratedISPCHeaders(targetConfig); if (!headers.empty()) { @@ -1386,10 +1401,10 @@ void cmGlobalNinjaGenerator::AppendTargetDepends( } if (targetDep.IsCross()) { this->AppendTargetOutputs(targetDep, outs, fileConfig, depends); - computeISPCOuputs(this, targetDep, outs, fileConfig); + computeISPCOutputs(this, targetDep, outs, fileConfig); } else { this->AppendTargetOutputs(targetDep, outs, config, depends); - computeISPCOuputs(this, targetDep, outs, config); + computeISPCOutputs(this, targetDep, outs, config); } } std::sort(outs.begin(), outs.end()); @@ -3242,10 +3257,3 @@ std::string cmGlobalNinjaMultiGenerator::OrderDependsTargetForTarget( return cmStrCat("cmake_object_order_depends_target_", target->GetName(), '_', cmSystemTools::UpperCase(config)); } - -std::string cmGlobalNinjaMultiGenerator::OrderDependsTargetForTargetPrivate( - cmGeneratorTarget const* target, const std::string& config) const -{ - return cmStrCat(this->OrderDependsTargetForTarget(target, config), - "_private"); -} |