Explorar el Código

AUTOUIC: Revert "Fix internal paths of generated ui_foo.h files"

Revert commit 10668f26c9 (AUTOUIC: Fix internal paths of generated
ui_foo.h files, 2022-05-21, v3.24.0-rc3~20^2).  It broke some existing
projects that use more than one `.ui` file of the same name.

Fixes: #23759
Issue: #23523
Brad King hace 3 años
padre
commit
778aaf6fdc
Se han modificado 1 ficheros con 12 adiciones y 16 borrados
  1. 12 16
      Source/cmQtAutoGenInitializer.cxx

+ 12 - 16
Source/cmQtAutoGenInitializer.cxx

@@ -909,7 +909,6 @@ bool cmQtAutoGenInitializer::InitScanFiles()
   // The reason is that their file names might be discovered from source files
   // at generation time.
   if (this->MocOrUicEnabled()) {
-    std::unordered_set<std::string> addedFiles;
     for (const auto& sf : this->Makefile->GetSourceFiles()) {
       // sf->GetExtension() is only valid after sf->ResolveFullPath() ...
       // Since we're iterating over source files that might be not in the
@@ -951,28 +950,25 @@ bool cmQtAutoGenInitializer::InitScanFiles()
                                                       cmExpandedList(uicOpts));
           }
 
-          auto uiHeaderFileName = cmStrCat(
-            "ui_"_s, cmSystemTools::GetFilenameWithoutLastExtension(fullPath),
-            ".h"_s);
+          auto uiHeaderRelativePath = cmSystemTools::RelativePath(
+            this->LocalGen->GetCurrentSourceDirectory(),
+            cmSystemTools::GetFilenamePath(fullPath));
 
-          // .ui files with the same base name will conflict. Yield an error.
-          {
-            auto insertResult = addedFiles.insert(uiHeaderFileName);
-            if (!insertResult.second) {
-              this->Makefile->IssueMessage(
-                MessageType::FATAL_ERROR,
-                cmStrCat("More than one .ui file with the name "_s,
-                         cmSystemTools::GetFilenameName(fullPath),
-                         " was found in the sources for target "_s,
-                         this->GenTarget->GetName(), "."));
-            }
+          // Avoid creating a path containing adjacent slashes
+          if (!uiHeaderRelativePath.empty() &&
+              uiHeaderRelativePath.back() != '/') {
+            uiHeaderRelativePath += '/';
           }
 
+          auto uiHeaderFilePath = cmStrCat(
+            '/', uiHeaderRelativePath, "ui_"_s,
+            cmSystemTools::GetFilenameWithoutLastExtension(fullPath), ".h"_s);
+
           ConfigString uiHeader;
           std::string uiHeaderGenex;
           this->ConfigFileNamesAndGenex(
             uiHeader, uiHeaderGenex, cmStrCat(this->Dir.Build, "/include"_s),
-            cmStrCat("/"_s, uiHeaderFileName));
+            uiHeaderFilePath);
 
           this->Uic.UiHeaders.emplace_back(
             std::make_pair(uiHeader, uiHeaderGenex));