diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2023-10-23 20:43:19 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2023-11-01 18:08:18 (GMT) |
commit | b0177003e12a422845f54865ea5f34e51d8cbf01 (patch) | |
tree | 650f69195560261b4d345b600c9b7d1f84668698 /Source/cmGlobalNinjaGenerator.cxx | |
parent | 45eff9145e82a4b1cd29396250b5235e10c4dd47 (diff) | |
download | CMake-b0177003e12a422845f54865ea5f34e51d8cbf01.zip CMake-b0177003e12a422845f54865ea5f34e51d8cbf01.tar.gz CMake-b0177003e12a422845f54865ea5f34e51d8cbf01.tar.bz2 |
cmGlobalNinjaGenerator: tell `ninja` to actually read the depfile
But only do so if the depfile is not specified as an output of the
command. Otherwise the command will out-of-date itself as `ninja`
deletes depfiles that it incorporates into the database and a missing
output will cause the command to run again.
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 4cf9dff..02f900c 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); |