From 035b6908829f524936a6819a342cdff145708529 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 10 Dec 2013 15:53:00 +0100 Subject: [PATCH] Autogen: Split AutoRcc handling into two methods The initialize method changes the target, whereas the setup method does not. --- Source/cmQtAutoGenerators.cxx | 56 ++++++++++++++++++++++------------- Source/cmQtAutoGenerators.h | 1 + 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 835e3b4f4..1988c5d95 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -221,6 +221,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target) if (target->GetPropertyAsBool("AUTORCC")) { toolNames.push_back("rcc"); + this->InitializeAutoRccTarget(target); } std::string tools = toolNames[0]; @@ -801,14 +802,47 @@ void cmQtAutoGenerators::MergeRccOptions(std::vector &opts, opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); } +void cmQtAutoGenerators::InitializeAutoRccTarget(cmTarget* target) +{ + cmMakefile *makefile = target->GetMakefile(); + + const std::vector& srcFiles = target->GetSourceFiles(); + + for(std::vector::const_iterator fileIt = srcFiles.begin(); + fileIt != srcFiles.end(); + ++fileIt) + { + cmSourceFile* sf = *fileIt; + std::string ext = sf->GetExtension(); + if (ext == "qrc") + { + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath().c_str()); + bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")); + + if (!skip) + { + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(absFile); + + std::string rcc_output_file = makefile->GetCurrentOutputDirectory(); + rcc_output_file += "/qrc_" + basename + ".cpp"; + makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", + rcc_output_file.c_str(), false); + cmSourceFile* rccCppSource + = makefile->GetOrCreateSource(rcc_output_file.c_str(), true); + target->AddSourceFile(rccCppSource); + } + } + } +} + void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target) { std::string _rcc_files; const char* sepRccFiles = ""; cmMakefile *makefile = target->GetMakefile(); - std::vector newFiles; - const std::vector& srcFiles = target->GetSourceFiles(); std::string rccFileFiles; @@ -841,17 +875,6 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target) _rcc_files += absFile; sepRccFiles = ";"; - std::string basename = cmsys::SystemTools:: - GetFilenameWithoutLastExtension(absFile); - - std::string rcc_output_file = makefile->GetCurrentOutputDirectory(); - rcc_output_file += "/qrc_" + basename + ".cpp"; - makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", - rcc_output_file.c_str(), false); - cmSourceFile* rccCppSource - = makefile->GetOrCreateSource(rcc_output_file.c_str(), true); - newFiles.push_back(rccCppSource); - if (const char *prop = sf->GetProperty("AUTORCC_OPTIONS")) { std::vector optsVec; @@ -880,13 +903,6 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target) } } - for(std::vector::const_iterator fileIt = newFiles.begin(); - fileIt != newFiles.end(); - ++fileIt) - { - target->AddSourceFile(*fileIt); - } - makefile->AddDefinition("_rcc_files", cmLocalGenerator::EscapeForCMake(_rcc_files.c_str()).c_str()); diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index e877f7d93..0888ea4ad 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -33,6 +33,7 @@ private: std::map &configDefines); void SetupAutoUicTarget(cmTarget* target, std::map &configUicOptions); + void InitializeAutoRccTarget(cmTarget* target); void SetupAutoRccTarget(cmTarget* target); cmGlobalGenerator* CreateGlobalGenerator(cmake* cm,