summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalNinjaGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-11-07 14:07:36 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-11-07 14:07:46 (GMT)
commit92cc1f3b62c149326cc535220f6233357ee5d749 (patch)
tree7edb4c4b54897b1f77ef91c81d4dec591acfb9fa /Source/cmGlobalNinjaGenerator.cxx
parent4b92515182ce642a6f8f587d5c35f11f9e6a291c (diff)
parentbb7a0497ef41540c75183acf4ee740656aa61dd9 (diff)
downloadCMake-92cc1f3b62c149326cc535220f6233357ee5d749.zip
CMake-92cc1f3b62c149326cc535220f6233357ee5d749.tar.gz
CMake-92cc1f3b62c149326cc535220f6233357ee5d749.tar.bz2
Merge topic 'Ninja-use-depslog'
bb7a0497ef cmTransformDepfile: warn when a depfile is not written to c22c473bde Tests/Ninja*/CustomCommandDepfile: check that deps are in the database b0177003e1 cmGlobalNinjaGenerator: tell `ninja` to actually read the depfile 45eff9145e cmAddCustomCommandCommand: use `cmStrCat` c6445c615b Tests/RunCMake/Ninja: fix subdir prefix check Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !8911
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx17
1 files changed, 16 insertions, 1 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index fb5c5c6..9fac513 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);