AUTOUIC: Fix cyclic dependency between generated UI headers and timestamp

Once the generated UI headers are created by UIC they also are involved
into processing in next run on ninja.  Autogen adds `ui_*.h` files to
the deps file `ui_*.h` and this cause timestamp start depend on `ui_*.h`.
Meanwhile `ui_*.h` depend on timestamp because of the explicit rules
added by commit 1265c65b33 (AUTOUIC: Collect ui header files for Ninja
generator, 2021-02-18, v3.21.0-rc1~600^2).  Avoid adding `ui_*.h` to
deps file at second ninja run.

Fixes: #16776
This commit is contained in:
Alexey Edelev
2021-07-16 17:24:53 +02:00
committed by Brad King
parent 4ff651eb52
commit 9cebdbec77

View File

@@ -2248,12 +2248,20 @@ void cmQtAutoMocUicT::JobDepFilesMergeT::Process()
std::for_each(this->MocEval().SourceMappings.begin(),
this->MocEval().SourceMappings.end(), processMappingEntry);
// Remove SKIP_AUTOMOC files
dependencies.erase(std::remove_if(dependencies.begin(), dependencies.end(),
[this](const std::string& dep) {
return this->MocConst().skipped(dep);
}),
dependencies.end());
// Remove SKIP_AUTOMOC files.
// Also remove AUTOUIC header files to avoid cyclic dependency.
dependencies.erase(
std::remove_if(dependencies.begin(), dependencies.end(),
[this](const std::string& dep) {
return this->MocConst().skipped(dep) ||
std::any_of(
this->UicEval().Includes.begin(),
this->UicEval().Includes.end(),
[&dep](MappingMapT::value_type const& mapping) {
return dep == mapping.second->OutputFile;
});
}),
dependencies.end());
// Remove duplicates to make the depfile smaller
std::sort(dependencies.begin(), dependencies.end());