Commit 1ed4d48d authored by Sebastian Holtermann's avatar Sebastian Holtermann
Browse files

Autogen: Prepend instead of append `mocs_compilation.cpp` to the sources list

`mocs_compilation.cpp` easily takes a long time to compile when it
contains multiple `moc` files.  When it was appended like before
we ran into the situation that all smaller sources were already compiled when
`mocs_compilation.cpp` got compiled at last.  In that case a single core was
busy but all remaining cores stayed idle.

To optimize CPU core utilization we now prepend `mocs_compilation.cpp`
to the sources list instead of appending it.  This allows smaller source files
to get compiled *while* the long lasting `mocs_compilation.cpp` gets compiled.

Closes #18793
parent a42b700c
......@@ -963,7 +963,7 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
// Files provided by the autogen target
std::vector<std::string> autogenProvides;
if (this->Moc.Enabled) {
this->AddGeneratedSource(this->Moc.MocsCompilation, GeneratorT::MOC);
this->AddGeneratedSource(this->Moc.MocsCompilation, GeneratorT::MOC, true);
......@@ -1356,7 +1356,8 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo()
void cmQtAutoGenInitializer::AddGeneratedSource(std::string const& filename,
GeneratorT genType)
GeneratorT genType,
bool prepend)
// Register source file in makefile
cmMakefile* makefile = this->Target->Target->GetMakefile();
......@@ -1370,7 +1371,7 @@ void cmQtAutoGenInitializer::AddGeneratedSource(std::string const& filename,
AddToSourceGroup(makefile, filename, genType);
// Add source file to target
this->Target->AddSource(filename, prepend);
static unsigned int CharPtrToInt(const char* const input)
......@@ -102,7 +102,8 @@ private:
bool SetupWriteAutogenInfo();
bool SetupWriteRccInfo();
void AddGeneratedSource(std::string const& filename, GeneratorT genType);
void AddGeneratedSource(std::string const& filename, GeneratorT genType,
bool prepend = false);
bool GetMocExecutable();
bool GetUicExecutable();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment