From 86f7fc5d55da5cf569c516f2d1fb8b69603c1be2 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 5 Oct 2015 18:55:09 +0200 Subject: [PATCH] QtAutogen: Move SetupAutoRccTarget method. --- Source/cmQtAutoGeneratorInitializer.cxx | 233 ++++++++++++------------ 1 file changed, 116 insertions(+), 117 deletions(-) diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 9bece40ef..a2a72d429 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -593,6 +593,122 @@ std::string cmQtAutoGeneratorInitializer::ListQt4RccInputs(cmSourceFile* sf, return entriesList; } +void cmQtAutoGeneratorInitializer::SetupAutoRccTarget(cmTarget const* target) +{ + std::string _rcc_files; + const char* sepRccFiles = ""; + cmMakefile *makefile = target->GetMakefile(); + + std::vector srcFiles; + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); + + std::string qrcInputs; + const char* qrcInputsSep = ""; + + std::string rccFileFiles; + std::string rccFileOptions; + const char *optionSep = ""; + + const char *qtVersion = makefile->GetDefinition("_target_qt_version"); + + std::vector rccOptions; + if (const char* opts = target->GetProperty("AUTORCC_OPTIONS")) + { + cmSystemTools::ExpandListArgument(opts, rccOptions); + } + std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); + if (qtMajorVersion == "") + { + qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR"); + } + + 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()); + bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")); + + if (!skip) + { + _rcc_files += sepRccFiles; + _rcc_files += absFile; + sepRccFiles = ";"; + + if (const char *prop = sf->GetProperty("AUTORCC_OPTIONS")) + { + std::vector optsVec; + cmSystemTools::ExpandListArgument(prop, optsVec); + cmQtAutoGeneratorInitializer::MergeRccOptions(rccOptions, optsVec, + strcmp(qtVersion, "5") == 0); + } + + if (!rccOptions.empty()) + { + rccFileFiles += optionSep; + rccFileFiles += absFile; + rccFileOptions += optionSep; + } + const char *listSep = ""; + for(std::vector::const_iterator it = rccOptions.begin(); + it != rccOptions.end(); + ++it) + { + rccFileOptions += listSep; + rccFileOptions += *it; + listSep = "@list_sep@"; + } + optionSep = ";"; + + std::vector depends; + + std::string entriesList; + if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) + { + if (qtMajorVersion == "5") + { + entriesList = cmQtAutoGeneratorInitializer::ListQt5RccInputs(sf, + target, + depends); + } + else + { + entriesList = + cmQtAutoGeneratorInitializer::ListQt4RccInputs(sf, depends); + } + if (entriesList.empty()) + { + return; + } + } + qrcInputs += qrcInputsSep; + qrcInputs += entriesList; + qrcInputsSep = ";"; + } + } + } + makefile->AddDefinition("_qt_rcc_inputs_" + target->GetName(), + cmOutputConverter::EscapeForCMake(qrcInputs).c_str()); + + makefile->AddDefinition("_rcc_files", + cmOutputConverter::EscapeForCMake(_rcc_files).c_str()); + + makefile->AddDefinition("_qt_rcc_options_files", + cmOutputConverter::EscapeForCMake(rccFileFiles).c_str()); + makefile->AddDefinition("_qt_rcc_options_options", + cmOutputConverter::EscapeForCMake(rccFileOptions).c_str()); + + makefile->AddDefinition("_qt_rcc_executable", + cmQtAutoGeneratorInitializer::GetRccExecutable(target).c_str()); +} void cmQtAutoGeneratorInitializer::InitializeAutogenSources(cmTarget* target) { @@ -955,120 +1071,3 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget( } } } - -void cmQtAutoGeneratorInitializer::SetupAutoRccTarget(cmTarget const* target) -{ - std::string _rcc_files; - const char* sepRccFiles = ""; - cmMakefile *makefile = target->GetMakefile(); - - std::vector srcFiles; - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); - gtgt->GetConfigCommonSourceFiles(srcFiles); - - std::string qrcInputs; - const char* qrcInputsSep = ""; - - std::string rccFileFiles; - std::string rccFileOptions; - const char *optionSep = ""; - - const char *qtVersion = makefile->GetDefinition("_target_qt_version"); - - std::vector rccOptions; - if (const char* opts = target->GetProperty("AUTORCC_OPTIONS")) - { - cmSystemTools::ExpandListArgument(opts, rccOptions); - } - std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR"); - if (qtMajorVersion == "") - { - qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR"); - } - - 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()); - bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")); - - if (!skip) - { - _rcc_files += sepRccFiles; - _rcc_files += absFile; - sepRccFiles = ";"; - - if (const char *prop = sf->GetProperty("AUTORCC_OPTIONS")) - { - std::vector optsVec; - cmSystemTools::ExpandListArgument(prop, optsVec); - cmQtAutoGeneratorInitializer::MergeRccOptions(rccOptions, optsVec, - strcmp(qtVersion, "5") == 0); - } - - if (!rccOptions.empty()) - { - rccFileFiles += optionSep; - rccFileFiles += absFile; - rccFileOptions += optionSep; - } - const char *listSep = ""; - for(std::vector::const_iterator it = rccOptions.begin(); - it != rccOptions.end(); - ++it) - { - rccFileOptions += listSep; - rccFileOptions += *it; - listSep = "@list_sep@"; - } - optionSep = ";"; - - std::vector depends; - - std::string entriesList; - if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"))) - { - if (qtMajorVersion == "5") - { - entriesList = cmQtAutoGeneratorInitializer::ListQt5RccInputs(sf, - target, - depends); - } - else - { - entriesList = - cmQtAutoGeneratorInitializer::ListQt4RccInputs(sf, depends); - } - if (entriesList.empty()) - { - return; - } - } - qrcInputs += qrcInputsSep; - qrcInputs += entriesList; - qrcInputsSep = ";"; - } - } - } - makefile->AddDefinition("_qt_rcc_inputs_" + target->GetName(), - cmOutputConverter::EscapeForCMake(qrcInputs).c_str()); - - makefile->AddDefinition("_rcc_files", - cmOutputConverter::EscapeForCMake(_rcc_files).c_str()); - - makefile->AddDefinition("_qt_rcc_options_files", - cmOutputConverter::EscapeForCMake(rccFileFiles).c_str()); - makefile->AddDefinition("_qt_rcc_options_options", - cmOutputConverter::EscapeForCMake(rccFileOptions).c_str()); - - makefile->AddDefinition("_qt_rcc_executable", - cmQtAutoGeneratorInitializer::GetRccExecutable(target).c_str()); -}