diff options
author | Stephen Kelly <steveire@gmail.com> | 2013-12-10 14:53:00 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2013-12-11 14:30:12 (GMT) |
commit | 035b6908829f524936a6819a342cdff145708529 (patch) | |
tree | d1f311fa94d716ca02f585c9296382d3efb18f4d /Source/cmQtAutoGenerators.cxx | |
parent | 2fcafbf613f07d6b2484a1dfdb6ba7cd2fc4a645 (diff) | |
download | CMake-035b6908829f524936a6819a342cdff145708529.zip CMake-035b6908829f524936a6819a342cdff145708529.tar.gz CMake-035b6908829f524936a6819a342cdff145708529.tar.bz2 |
Autogen: Split AutoRcc handling into two methods
The initialize method changes the target, whereas the setup method
does not.
Diffstat (limited to 'Source/cmQtAutoGenerators.cxx')
-rw-r--r-- | Source/cmQtAutoGenerators.cxx | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 835e3b4..1988c5d 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<std::string> &opts, opts.insert(opts.end(), extraOpts.begin(), extraOpts.end()); } +void cmQtAutoGenerators::InitializeAutoRccTarget(cmTarget* target) +{ + cmMakefile *makefile = target->GetMakefile(); + + const std::vector<cmSourceFile*>& srcFiles = target->GetSourceFiles(); + + for(std::vector<cmSourceFile*>::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<cmSourceFile*> newFiles; - const std::vector<cmSourceFile*>& 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<std::string> optsVec; @@ -880,13 +903,6 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget* target) } } - for(std::vector<cmSourceFile*>::const_iterator fileIt = newFiles.begin(); - fileIt != newFiles.end(); - ++fileIt) - { - target->AddSourceFile(*fileIt); - } - makefile->AddDefinition("_rcc_files", cmLocalGenerator::EscapeForCMake(_rcc_files.c_str()).c_str()); |