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

View File

@ -300,6 +300,11 @@ public:
/** Get per-target generator information. */
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 {return this->ProjectMap;}

View File

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

View File

@ -287,7 +287,8 @@ std::string cmQtAutoGenerators::ListQt4RccInputs(cmSourceFile* sf,
return entriesList;
}
bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg,
cmTarget* target)
{
cmMakefile* makefile = target->GetMakefile();
// 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,
commandLines, false, autogenComment.c_str());
cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg);
lg->GetGlobalGenerator()->AddGeneratorTarget(autogenTarget, gt);
makefile->AddGeneratorTarget(autogenTarget, gt);
// Set target folder
const char* autogenFolder = makefile->GetState()
->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER");

View File

@ -18,6 +18,7 @@
class cmGlobalGenerator;
class cmMakefile;
class cmLocalGenerator;
class cmQtAutoGenerators
{
@ -25,7 +26,7 @@ public:
cmQtAutoGenerators();
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 SetupSourceFiles(cmTarget const* target);