From 493b17f8c7fb171fd7ca36cc0b29257939609298 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 5 Oct 2015 18:45:21 +0200 Subject: [PATCH] QtAutogen: Move SetupSourceFiles method. --- Source/cmQtAutoGeneratorInitializer.cxx | 166 ++++++++++++------------ 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/Source/cmQtAutoGeneratorInitializer.cxx b/Source/cmQtAutoGeneratorInitializer.cxx index 24e7ed8db..216c5b4bf 100644 --- a/Source/cmQtAutoGeneratorInitializer.cxx +++ b/Source/cmQtAutoGeneratorInitializer.cxx @@ -25,6 +25,89 @@ # include "cmGlobalVisualStudioGenerator.h" #endif +void cmQtAutoGeneratorInitializer::SetupSourceFiles(cmTarget const* target, + std::vector& skipMoc, + std::vector& mocSources, + std::vector& mocHeaders, + std::vector& skipUic) +{ + cmMakefile* makefile = target->GetMakefile(); + + std::vector srcFiles; + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + gtgt->GetConfigCommonSourceFiles(srcFiles); + + std::vector newRccFiles; + + for(std::vector::const_iterator fileIt = srcFiles.begin(); + fileIt != srcFiles.end(); + ++fileIt) + { + cmSourceFile* sf = *fileIt; + std::string absFile = cmsys::SystemTools::GetRealPath( + sf->GetFullPath()); + bool skipFileForMoc = + cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC")); + bool generated = cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")); + + if(cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC"))) + { + skipUic.push_back(absFile); + } + + std::string ext = sf->GetExtension(); + + if (target->GetPropertyAsBool("AUTORCC")) + { + if (ext == "qrc" + && !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"))) + { + std::string basename = cmsys::SystemTools:: + GetFilenameWithoutLastExtension(absFile); + + std::string rcc_output_dir = target->GetSupportDirectory(); + cmSystemTools::MakeDirectory(rcc_output_dir.c_str()); + std::string rcc_output_file = rcc_output_dir; + rcc_output_file += "/qrc_" + basename + ".cpp"; + makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", + rcc_output_file.c_str(), false); + makefile->GetOrCreateSource(rcc_output_file, true); + newRccFiles.push_back(rcc_output_file); + } + } + + if (!generated) + { + if (skipFileForMoc) + { + skipMoc.push_back(absFile); + } + else + { + cmSystemTools::FileFormat fileType = cmSystemTools::GetFileFormat( + ext.c_str()); + if (fileType == cmSystemTools::CXX_FILE_FORMAT) + { + mocSources.push_back(absFile); + } + else if (fileType == cmSystemTools::HEADER_FILE_FORMAT) + { + mocHeaders.push_back(absFile); + } + } + } + } + + for(std::vector::const_iterator fileIt = newRccFiles.begin(); + fileIt != newRccFiles.end(); + ++fileIt) + { + const_cast(target)->AddSource(*fileIt); + } +} + std::string cmQtAutoGeneratorInitializer::GetAutogenTargetName( cmTarget const* target) { @@ -568,89 +651,6 @@ void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget( } } -void cmQtAutoGeneratorInitializer::SetupSourceFiles(cmTarget const* target, - std::vector& skipMoc, - std::vector& mocSources, - std::vector& mocHeaders, - std::vector& skipUic) -{ - cmMakefile* makefile = target->GetMakefile(); - - std::vector srcFiles; - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); - gtgt->GetConfigCommonSourceFiles(srcFiles); - - std::vector newRccFiles; - - for(std::vector::const_iterator fileIt = srcFiles.begin(); - fileIt != srcFiles.end(); - ++fileIt) - { - cmSourceFile* sf = *fileIt; - std::string absFile = cmsys::SystemTools::GetRealPath( - sf->GetFullPath()); - bool skipFileForMoc = - cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC")); - bool generated = cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")); - - if(cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOUIC"))) - { - skipUic.push_back(absFile); - } - - std::string ext = sf->GetExtension(); - - if (target->GetPropertyAsBool("AUTORCC")) - { - if (ext == "qrc" - && !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"))) - { - std::string basename = cmsys::SystemTools:: - GetFilenameWithoutLastExtension(absFile); - - std::string rcc_output_dir = target->GetSupportDirectory(); - cmSystemTools::MakeDirectory(rcc_output_dir.c_str()); - std::string rcc_output_file = rcc_output_dir; - rcc_output_file += "/qrc_" + basename + ".cpp"; - makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", - rcc_output_file.c_str(), false); - makefile->GetOrCreateSource(rcc_output_file, true); - newRccFiles.push_back(rcc_output_file); - } - } - - if (!generated) - { - if (skipFileForMoc) - { - skipMoc.push_back(absFile); - } - else - { - cmSystemTools::FileFormat fileType = cmSystemTools::GetFileFormat( - ext.c_str()); - if (fileType == cmSystemTools::CXX_FILE_FORMAT) - { - mocSources.push_back(absFile); - } - else if (fileType == cmSystemTools::HEADER_FILE_FORMAT) - { - mocHeaders.push_back(absFile); - } - } - } - } - - for(std::vector::const_iterator fileIt = newRccFiles.begin(); - fileIt != newRccFiles.end(); - ++fileIt) - { - const_cast(target)->AddSource(*fileIt); - } -} - void cmQtAutoGeneratorInitializer::SetupAutoMocTarget(cmTarget const* target, const std::string &autogenTargetName, std::vector const& skipMoc,