QtAutogen: Don't use members to initialize automoc targets.

This commit is contained in:
Stephen Kelly 2015-09-26 19:25:00 +02:00
parent dced2fe10f
commit a3ceb998d7
2 changed files with 22 additions and 19 deletions

View File

@ -562,6 +562,9 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
} }
std::vector<std::string> skipUic; std::vector<std::string> skipUic;
std::vector<std::string> skipMoc;
std::vector<std::string> mocSources;
std::vector<std::string> mocHeaders;
std::map<std::string, std::string> configIncludes; std::map<std::string, std::string> configIncludes;
std::map<std::string, std::string> configDefines; std::map<std::string, std::string> configDefines;
std::map<std::string, std::string> configUicOptions; std::map<std::string, std::string> configUicOptions;
@ -570,13 +573,14 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
|| target->GetPropertyAsBool("AUTOUIC") || target->GetPropertyAsBool("AUTOUIC")
|| target->GetPropertyAsBool("AUTORCC")) || target->GetPropertyAsBool("AUTORCC"))
{ {
this->SetupSourceFiles(target, skipUic); this->SetupSourceFiles(target, skipMoc, mocSources, mocHeaders, skipUic);
} }
makefile->AddDefinition("_cpp_files", makefile->AddDefinition("_cpp_files",
cmOutputConverter::EscapeForCMake(this->Sources).c_str()); cmOutputConverter::EscapeForCMake(cmJoin(mocSources, ";")).c_str());
if (target->GetPropertyAsBool("AUTOMOC")) if (target->GetPropertyAsBool("AUTOMOC"))
{ {
this->SetupAutoMocTarget(target, autogenTargetName, this->SetupAutoMocTarget(target, autogenTargetName,
skipMoc, mocHeaders,
configIncludes, configDefines); configIncludes, configDefines);
} }
if (target->GetPropertyAsBool("AUTOUIC")) if (target->GetPropertyAsBool("AUTOUIC"))
@ -657,21 +661,19 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
} }
void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target, void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target,
std::vector<std::string>& skipUic) std::vector<std::string>& skipMoc,
std::vector<std::string>& mocSources,
std::vector<std::string>& mocHeaders,
std::vector<std::string>& skipUic)
{ {
cmMakefile* makefile = target->GetMakefile(); cmMakefile* makefile = target->GetMakefile();
const char* sepFiles = "";
const char* sepHeaders = "";
std::vector<cmSourceFile*> srcFiles; std::vector<cmSourceFile*> srcFiles;
cmGeneratorTarget *gtgt = target->GetMakefile() cmGeneratorTarget *gtgt = target->GetMakefile()
->GetGlobalGenerator() ->GetGlobalGenerator()
->GetGeneratorTarget(target); ->GetGeneratorTarget(target);
gtgt->GetConfigCommonSourceFiles(srcFiles); gtgt->GetConfigCommonSourceFiles(srcFiles);
const char *skipMocSep = "";
std::vector<std::string> newRccFiles; std::vector<std::string> newRccFiles;
for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin(); for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
@ -715,9 +717,7 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target,
{ {
if (skipFileForMoc) if (skipFileForMoc)
{ {
this->SkipMoc += skipMocSep; skipMoc.push_back(absFile);
this->SkipMoc += absFile;
skipMocSep = ";";
} }
else else
{ {
@ -725,15 +725,11 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target,
ext.c_str()); ext.c_str());
if (fileType == cmSystemTools::CXX_FILE_FORMAT) if (fileType == cmSystemTools::CXX_FILE_FORMAT)
{ {
this->Sources += sepFiles; mocSources.push_back(absFile);
this->Sources += absFile;
sepFiles = ";";
} }
else if (fileType == cmSystemTools::HEADER_FILE_FORMAT) else if (fileType == cmSystemTools::HEADER_FILE_FORMAT)
{ {
this->Headers += sepHeaders; mocHeaders.push_back(absFile);
this->Headers += absFile;
sepHeaders = ";";
} }
} }
} }
@ -749,6 +745,8 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target,
void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target,
const std::string &autogenTargetName, const std::string &autogenTargetName,
std::vector<std::string> const& skipMoc,
std::vector<std::string> const& mocHeaders,
std::map<std::string, std::string> &configIncludes, std::map<std::string, std::string> &configIncludes,
std::map<std::string, std::string> &configDefines) std::map<std::string, std::string> &configDefines)
{ {
@ -759,9 +757,9 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target,
makefile->AddDefinition("_moc_options", makefile->AddDefinition("_moc_options",
cmOutputConverter::EscapeForCMake(_moc_options).c_str()); cmOutputConverter::EscapeForCMake(_moc_options).c_str());
makefile->AddDefinition("_skip_moc", makefile->AddDefinition("_skip_moc",
cmOutputConverter::EscapeForCMake(this->SkipMoc).c_str()); cmOutputConverter::EscapeForCMake(cmJoin(skipMoc, ";")).c_str());
makefile->AddDefinition("_moc_headers", makefile->AddDefinition("_moc_headers",
cmOutputConverter::EscapeForCMake(this->Headers).c_str()); cmOutputConverter::EscapeForCMake(cmJoin(mocHeaders, ";")).c_str());
bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE"); bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE");
makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE"); makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE");

View File

@ -34,11 +34,16 @@ public:
bool InitializeAutogenTarget(cmLocalGenerator* lg, 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,
std::vector<std::string>& skipMoc,
std::vector<std::string>& mocSources,
std::vector<std::string>& mocHeaders,
std::vector<std::string>& skipUic); std::vector<std::string>& skipUic);
private: private:
void SetupAutoMocTarget(cmTarget const* target, void SetupAutoMocTarget(cmTarget const* target,
const std::string &autogenTargetName, const std::string &autogenTargetName,
const std::vector<std::string>& skipMoc,
const std::vector<std::string>& mocHeaders,
std::map<std::string, std::string> &configIncludes, std::map<std::string, std::string> &configIncludes,
std::map<std::string, std::string> &configDefines); std::map<std::string, std::string> &configDefines);
void SetupAutoUicTarget(cmTarget const* target, void SetupAutoUicTarget(cmTarget const* target,