Autogen: Defer setup until Generate step

It is better to set variables up once all target dependencies are known.
This commit is contained in:
Orkun Tokdemir
2023-04-03 16:52:13 +02:00
committed by Brad King
parent 7cecb6353e
commit 69cf9700e6
2 changed files with 20 additions and 8 deletions
+14 -8
View File
@@ -1544,8 +1544,9 @@ bool cmGlobalGenerator::Compute()
} }
#ifndef CMAKE_BOOTSTRAP #ifndef CMAKE_BOOTSTRAP
cmQtAutoGenGlobalInitializer qtAutoGen(this->LocalGenerators); this->QtAutoGen =
if (!qtAutoGen.InitializeCustomTargets()) { cm::make_unique<cmQtAutoGenGlobalInitializer>(this->LocalGenerators);
if (!this->QtAutoGen->InitializeCustomTargets()) {
return false; return false;
} }
#endif #endif
@@ -1565,12 +1566,6 @@ bool cmGlobalGenerator::Compute()
} }
} }
#ifndef CMAKE_BOOTSTRAP
if (!qtAutoGen.SetupCustomTargets()) {
return false;
}
#endif
for (const auto& localGen : this->LocalGenerators) { for (const auto& localGen : this->LocalGenerators) {
cmMakefile* mf = localGen->GetMakefile(); cmMakefile* mf = localGen->GetMakefile();
for (const auto& g : mf->GetInstallGenerators()) { for (const auto& g : mf->GetInstallGenerators()) {
@@ -1635,6 +1630,17 @@ void cmGlobalGenerator::Generate()
this->CMakeInstance->UpdateProgress("Generating", 0.1f); this->CMakeInstance->UpdateProgress("Generating", 0.1f);
#ifndef CMAKE_BOOTSTRAP
if (!this->QtAutoGen->SetupCustomTargets()) {
if (!cmSystemTools::GetErrorOccurredFlag()) {
this->GetCMakeInstance()->IssueMessage(
MessageType::FATAL_ERROR,
"Problem setting up custom targets for QtAutoGen");
}
return;
}
#endif
// Generate project files // Generate project files
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) {
this->SetCurrentMakefile(this->LocalGenerators[i]->GetMakefile()); this->SetCurrentMakefile(this->LocalGenerators[i]->GetMakefile());
+6
View File
@@ -50,6 +50,7 @@ class cmLinkLineComputer;
class cmLocalGenerator; class cmLocalGenerator;
class cmMakefile; class cmMakefile;
class cmOutputConverter; class cmOutputConverter;
class cmQtAutoGenGlobalInitializer;
class cmSourceFile; class cmSourceFile;
class cmState; class cmState;
class cmStateDirectory; class cmStateDirectory;
@@ -683,6 +684,11 @@ protected:
cmake* CMakeInstance; cmake* CMakeInstance;
std::vector<std::unique_ptr<cmMakefile>> Makefiles; std::vector<std::unique_ptr<cmMakefile>> Makefiles;
LocalGeneratorVector LocalGenerators; LocalGeneratorVector LocalGenerators;
#ifndef CMAKE_BOOTSTRAP
std::unique_ptr<cmQtAutoGenGlobalInitializer> QtAutoGen;
#endif
cmMakefile* CurrentConfigureMakefile; cmMakefile* CurrentConfigureMakefile;
// map from project name to vector of local generators in that project // map from project name to vector of local generators in that project
std::map<std::string, std::vector<cmLocalGenerator*>> ProjectMap; std::map<std::string, std::vector<cmLocalGenerator*>> ProjectMap;