From a3ceb998d7768592b670abd2a8d0dd2777c84789 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sat, 26 Sep 2015 19:25:00 +0200 Subject: [PATCH] QtAutogen: Don't use members to initialize automoc targets. --- Source/cmQtAutoGenerators.cxx | 36 +++++++++++++++++------------------ Source/cmQtAutoGenerators.h | 5 +++++ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index c069a49760..197f92a927 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -562,6 +562,9 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) } std::vector skipUic; + std::vector skipMoc; + std::vector mocSources; + std::vector mocHeaders; std::map configIncludes; std::map configDefines; std::map configUicOptions; @@ -570,13 +573,14 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) || target->GetPropertyAsBool("AUTOUIC") || target->GetPropertyAsBool("AUTORCC")) { - this->SetupSourceFiles(target, skipUic); + this->SetupSourceFiles(target, skipMoc, mocSources, mocHeaders, skipUic); } makefile->AddDefinition("_cpp_files", - cmOutputConverter::EscapeForCMake(this->Sources).c_str()); + cmOutputConverter::EscapeForCMake(cmJoin(mocSources, ";")).c_str()); if (target->GetPropertyAsBool("AUTOMOC")) { this->SetupAutoMocTarget(target, autogenTargetName, + skipMoc, mocHeaders, configIncludes, configDefines); } if (target->GetPropertyAsBool("AUTOUIC")) @@ -657,21 +661,19 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) } void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target, - std::vector& skipUic) + std::vector& skipMoc, + std::vector& mocSources, + std::vector& mocHeaders, + std::vector& skipUic) { cmMakefile* makefile = target->GetMakefile(); - const char* sepFiles = ""; - const char* sepHeaders = ""; - std::vector srcFiles; cmGeneratorTarget *gtgt = target->GetMakefile() ->GetGlobalGenerator() ->GetGeneratorTarget(target); gtgt->GetConfigCommonSourceFiles(srcFiles); - const char *skipMocSep = ""; - std::vector newRccFiles; for(std::vector::const_iterator fileIt = srcFiles.begin(); @@ -715,9 +717,7 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target, { if (skipFileForMoc) { - this->SkipMoc += skipMocSep; - this->SkipMoc += absFile; - skipMocSep = ";"; + skipMoc.push_back(absFile); } else { @@ -725,15 +725,11 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target, ext.c_str()); if (fileType == cmSystemTools::CXX_FILE_FORMAT) { - this->Sources += sepFiles; - this->Sources += absFile; - sepFiles = ";"; + mocSources.push_back(absFile); } else if (fileType == cmSystemTools::HEADER_FILE_FORMAT) { - this->Headers += sepHeaders; - this->Headers += absFile; - sepHeaders = ";"; + mocHeaders.push_back(absFile); } } } @@ -749,6 +745,8 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target, void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, const std::string &autogenTargetName, + std::vector const& skipMoc, + std::vector const& mocHeaders, std::map &configIncludes, std::map &configDefines) { @@ -759,9 +757,9 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target, makefile->AddDefinition("_moc_options", cmOutputConverter::EscapeForCMake(_moc_options).c_str()); makefile->AddDefinition("_skip_moc", - cmOutputConverter::EscapeForCMake(this->SkipMoc).c_str()); + cmOutputConverter::EscapeForCMake(cmJoin(skipMoc, ";")).c_str()); makefile->AddDefinition("_moc_headers", - cmOutputConverter::EscapeForCMake(this->Headers).c_str()); + cmOutputConverter::EscapeForCMake(cmJoin(mocHeaders, ";")).c_str()); bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE"); makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE"); diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index c1dac2bdbc..6741139b91 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -34,11 +34,16 @@ public: bool InitializeAutogenTarget(cmLocalGenerator* lg, cmTarget* target); void SetupAutoGenerateTarget(cmTarget const* target); void SetupSourceFiles(cmTarget const* target, + std::vector& skipMoc, + std::vector& mocSources, + std::vector& mocHeaders, std::vector& skipUic); private: void SetupAutoMocTarget(cmTarget const* target, const std::string &autogenTargetName, + const std::vector& skipMoc, + const std::vector& mocHeaders, std::map &configIncludes, std::map &configDefines); void SetupAutoUicTarget(cmTarget const* target,