소스 검색

Autogen: Enable SKIP_UNITY_BUILD_INCLUSION on AUTORCC generated files

`rcc` generated files are not compatible with unity builds, because they
contain classes in anonymous namespaces and static data with identical names.

This patch sets the source file property `SKIP_UNITY_BUILD_INCLUSION` to `On`
on all `AUTORCC` generated files to exclude them from unity build files.

Fixes: #20191 "QT5: Exclude resource files from unity build"
Sebastian Holtermann 5 년 전
부모
커밋
086d9b2bab
2개의 변경된 파일19개의 추가작업 그리고 14개의 파일을 삭제
  1. 14 10
      Source/cmQtAutoGenInitializer.cxx
  2. 5 4
      Source/cmQtAutoGenInitializer.h

+ 14 - 10
Source/cmQtAutoGenInitializer.cxx

@@ -1166,7 +1166,10 @@ bool cmQtAutoGenInitializer::InitRccTargets()
     // Register info file as generated by CMake
     this->Makefile->AddCMakeOutputFile(qrc.InfoFile);
     // Register file at target
-    this->AddGeneratedSource(qrc.OutputFile, this->Rcc);
+    {
+      cmSourceFile* sf = this->AddGeneratedSource(qrc.OutputFile, this->Rcc);
+      sf->SetProperty("SKIP_UNITY_BUILD_INCLUSION", "On");
+    }
 
     std::vector<std::string> ccOutput;
     ccOutput.push_back(qrc.OutputFile);
@@ -1461,27 +1464,30 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo()
   return true;
 }
 
-void cmQtAutoGenInitializer::RegisterGeneratedSource(
+cmSourceFile* cmQtAutoGenInitializer::RegisterGeneratedSource(
   std::string const& filename)
 {
   cmSourceFile* gFile = this->Makefile->GetOrCreateSource(filename, true);
   gFile->SetProperty("GENERATED", "1");
   gFile->SetProperty("SKIP_AUTOGEN", "1");
+  return gFile;
 }
 
-bool cmQtAutoGenInitializer::AddGeneratedSource(std::string const& filename,
-                                                GenVarsT const& genVars,
-                                                bool prepend)
+cmSourceFile* cmQtAutoGenInitializer::AddGeneratedSource(
+  std::string const& filename, GenVarsT const& genVars, bool prepend)
 {
   // Register source at makefile
-  this->RegisterGeneratedSource(filename);
+  cmSourceFile* gFile = this->RegisterGeneratedSource(filename);
   // Add source file to target
   this->GenTarget->AddSource(filename, prepend);
+
   // Add source file to source group
-  return this->AddToSourceGroup(filename, genVars.GenNameUpper);
+  this->AddToSourceGroup(filename, genVars.GenNameUpper);
+
+  return gFile;
 }
 
-bool cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName,
+void cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName,
                                               cm::string_view genNameUpper)
 {
   cmSourceGroup* sourceGroup = nullptr;
@@ -1512,14 +1518,12 @@ bool cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName,
           cmStrCat(genNameUpper, " error in ", property,
                    ": Could not find or create the source group ",
                    cmQtAutoGen::Quoted(groupName)));
-        return false;
       }
     }
   }
   if (sourceGroup != nullptr) {
     sourceGroup->AddGroupFile(fileName);
   }
-  return true;
 }
 
 void cmQtAutoGenInitializer::AddCleanFile(std::string const& fileName)

+ 5 - 4
Source/cmQtAutoGenInitializer.h

@@ -129,10 +129,11 @@ private:
   bool SetupWriteAutogenInfo();
   bool SetupWriteRccInfo();
 
-  void RegisterGeneratedSource(std::string const& filename);
-  bool AddGeneratedSource(std::string const& filename, GenVarsT const& genVars,
-                          bool prepend = false);
-  bool AddToSourceGroup(std::string const& fileName,
+  cmSourceFile* RegisterGeneratedSource(std::string const& filename);
+  cmSourceFile* AddGeneratedSource(std::string const& filename,
+                                   GenVarsT const& genVars,
+                                   bool prepend = false);
+  void AddToSourceGroup(std::string const& fileName,
                         cm::string_view genNameUpper);
   void AddCleanFile(std::string const& fileName);