mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-16 05:26:58 +08:00
Ninja: Avoid cleandead with dyndep bindings for Fortran module dependencies
The Ninja `cleandead` tool does not account for implicit outputs discovered by `dyndep` bindings and can remove Fortran `.mod` files that are still needed. Disable the `cleandead` step when using `dyndep` bindings. Fixes: #21406
This commit is contained in:
@@ -240,6 +240,12 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
|
||||
}
|
||||
}
|
||||
|
||||
if (build.Variables.count("dyndep") > 0) {
|
||||
// The ninja 'cleandead' operation does not account for outputs
|
||||
// discovered by 'dyndep' bindings. Avoid removing them.
|
||||
this->DisableCleandead = true;
|
||||
}
|
||||
|
||||
os << buildStr << arguments << assignments << "\n";
|
||||
}
|
||||
|
||||
@@ -501,6 +507,7 @@ void cmGlobalNinjaGenerator::Generate()
|
||||
this->InitOutputPathPrefix();
|
||||
this->TargetAll = this->NinjaOutputPath("all");
|
||||
this->CMakeCacheFile = this->NinjaOutputPath("CMakeCache.txt");
|
||||
this->DisableCleandead = false;
|
||||
|
||||
this->PolicyCMP0058 =
|
||||
this->LocalGenerators[0]->GetMakefile()->GetPolicyStatus(
|
||||
@@ -581,8 +588,8 @@ void cmGlobalNinjaGenerator::CleanMetaData()
|
||||
// wrote out. Ninja-Multi doesn't have a single `build.ninja` we can use that
|
||||
// is the union of all generated configurations, so we can't run it reliably
|
||||
// in that case.
|
||||
if (this->NinjaSupportsCleanDeadTool && expectBuildManifest &&
|
||||
!missingBuildManifest) {
|
||||
if (this->NinjaSupportsCleanDeadTool && !this->DisableCleandead &&
|
||||
expectBuildManifest && !missingBuildManifest) {
|
||||
run_ninja_tool({ "cleandead" });
|
||||
}
|
||||
// The `recompact` tool loads the manifest. As above, we don't have a single
|
||||
|
@@ -545,6 +545,7 @@ private:
|
||||
std::string OutputPathPrefix;
|
||||
std::string TargetAll;
|
||||
std::string CMakeCacheFile;
|
||||
bool DisableCleandead = false;
|
||||
|
||||
struct ByConfig
|
||||
{
|
||||
|
Reference in New Issue
Block a user