Browse Source

Merge topic 'autogen-ui-header-depends' into release-3.21

9cebdbec77 AUTOUIC: Fix cyclic dependency between generated UI headers and timestamp

Acked-by: Kitware Robot <[email protected]>
Merge-request: !6359
Brad King 4 years ago
parent
commit
9a2f3d4b68
1 changed files with 14 additions and 6 deletions
  1. 14 6
      Source/cmQtAutoMocUic.cxx

+ 14 - 6
Source/cmQtAutoMocUic.cxx

@@ -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());