cmGlobalGenerator: Create cmGeneratorTargets before QtAutomoc.

Add cmGeneratorTargets as needed in the QtAutomoc processing.
This commit is contained in:
Stephen Kelly 2015-07-25 23:19:36 +02:00
parent de80993a20
commit 496f4cd07d
5 changed files with 21 additions and 4 deletions

View File

@ -1234,13 +1234,14 @@ void cmGlobalGenerator::Generate()
this->FinalizeTargetCompileInfo(); this->FinalizeTargetCompileInfo();
this->CreateGenerationObjects();
#ifdef CMAKE_BUILD_WITH_CMAKE #ifdef CMAKE_BUILD_WITH_CMAKE
// Iterate through all targets and set up automoc for those which have // Iterate through all targets and set up automoc for those which have
// the AUTOMOC, AUTOUIC or AUTORCC property set // the AUTOMOC, AUTOUIC or AUTORCC property set
AutogensType autogens; AutogensType autogens;
this->CreateQtAutoGeneratorsTargets(autogens); this->CreateQtAutoGeneratorsTargets(autogens);
#endif #endif
this->CreateGenerationObjects();
unsigned int i; unsigned int i;
@ -1414,7 +1415,8 @@ void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
&& !target.IsImported()) && !target.IsImported())
{ {
cmQtAutoGenerators autogen; cmQtAutoGenerators autogen;
if(autogen.InitializeAutogenTarget(&target)) if(autogen.InitializeAutogenTarget(this->LocalGenerators[i],
&target))
{ {
autogens.push_back(std::make_pair(autogen, &target)); autogens.push_back(std::make_pair(autogen, &target));
} }

View File

@ -300,6 +300,11 @@ public:
/** Get per-target generator information. */ /** Get per-target generator information. */
cmGeneratorTarget* GetGeneratorTarget(cmTarget const*) const; cmGeneratorTarget* GetGeneratorTarget(cmTarget const*) const;
void AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt)
{
this->GeneratorTargets[t] = gt;
}
const std::map<std::string, std::vector<cmLocalGenerator*> >& GetProjectMap() const std::map<std::string, std::vector<cmLocalGenerator*> >& GetProjectMap()
const {return this->ProjectMap;} const {return this->ProjectMap;}

View File

@ -415,6 +415,10 @@ public:
{ {
this->GeneratorTargets = targets; this->GeneratorTargets = targets;
} }
void AddGeneratorTarget(cmTarget* t, cmGeneratorTarget* gt)
{
this->GeneratorTargets[t] = gt;
}
cmTarget* FindTarget(const std::string& name, cmTarget* FindTarget(const std::string& name,
bool excludeAliases = false) const; bool excludeAliases = false) const;

View File

@ -287,7 +287,8 @@ std::string cmQtAutoGenerators::ListQt4RccInputs(cmSourceFile* sf,
return entriesList; return entriesList;
} }
bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg,
cmTarget* target)
{ {
cmMakefile* makefile = target->GetMakefile(); cmMakefile* makefile = target->GetMakefile();
// don't do anything if there is no Qt4 or Qt5Core (which contains moc): // don't do anything if there is no Qt4 or Qt5Core (which contains moc):
@ -474,6 +475,10 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
/*byproducts=*/rcc_output, depends, /*byproducts=*/rcc_output, depends,
commandLines, false, autogenComment.c_str()); commandLines, false, autogenComment.c_str());
cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg);
lg->GetGlobalGenerator()->AddGeneratorTarget(autogenTarget, gt);
makefile->AddGeneratorTarget(autogenTarget, gt);
// Set target folder // Set target folder
const char* autogenFolder = makefile->GetState() const char* autogenFolder = makefile->GetState()
->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER"); ->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER");

View File

@ -18,6 +18,7 @@
class cmGlobalGenerator; class cmGlobalGenerator;
class cmMakefile; class cmMakefile;
class cmLocalGenerator;
class cmQtAutoGenerators class cmQtAutoGenerators
{ {
@ -25,7 +26,7 @@ public:
cmQtAutoGenerators(); cmQtAutoGenerators();
bool Run(const std::string& targetDirectory, const std::string& config); bool Run(const std::string& targetDirectory, const std::string& config);
bool InitializeAutogenTarget(cmTarget* target); bool InitializeAutogenTarget(cmLocalGenerator* lg, cmTarget* target);
void SetupAutoGenerateTarget(cmTarget const* target); void SetupAutoGenerateTarget(cmTarget const* target);
void SetupSourceFiles(cmTarget const* target); void SetupSourceFiles(cmTarget const* target);