diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index d4d565c7b..cb070cc7a 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -392,7 +392,8 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) std::map configUicOptions; if (target->GetPropertyAsBool("AUTOMOC") - || target->GetPropertyAsBool("AUTOUIC")) + || target->GetPropertyAsBool("AUTOUIC") + || target->GetPropertyAsBool("AUTORCC")) { this->SetupSourceFiles(target); } @@ -1304,8 +1305,8 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) const std::vector& headerExtensions = makefile->GetHeaderExtensions(); - std::map includedUis; - std::map skippedUis; + std::map > includedUis; + std::map > skippedUis; std::vector uicSkipped; cmSystemTools::ExpandListArgument(this->SkipUic, uicSkipped); @@ -1315,7 +1316,7 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) { const bool skipUic = std::find(uicSkipped.begin(), uicSkipped.end(), *it) != uicSkipped.end(); - std::map& uiFiles + std::map >& uiFiles = skipUic ? skippedUis : includedUis; const std::string &absFilename = *it; if (this->Verbose) @@ -1376,12 +1377,17 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) { this->GenerateMoc(it->first, it->second); } - for(std::map::const_iterator + for(std::map >::const_iterator it = includedUis.begin(); it != includedUis.end(); ++it) { - this->GenerateUi(it->first, it->second); + for (std::vector::const_iterator nit = it->second.begin(); + nit != it->second.end(); + ++nit) + { + this->GenerateUi(it->first, *nit); + } } if(!this->RccExecutable.empty()) @@ -1456,9 +1462,9 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile) void cmQtAutoGenerators::ParseCppFile(const std::string& absFilename, - const std::vector& headerExtensions, - std::map& includedMocs, - std::map &includedUis) + const std::vector& headerExtensions, + std::map& includedMocs, + std::map > &includedUis) { cmsys::RegularExpression mocIncludeRegExp( "[\n][ \t]*#[ \t]*include[ \t]+" @@ -1644,9 +1650,9 @@ void cmQtAutoGenerators::ParseCppFile(const std::string& absFilename, void cmQtAutoGenerators::StrictParseCppFile(const std::string& absFilename, - const std::vector& headerExtensions, - std::map& includedMocs, - std::map& includedUis) + const std::vector& headerExtensions, + std::map& includedMocs, + std::map >& includedUis) { cmsys::RegularExpression mocIncludeRegExp( "[\n][ \t]*#[ \t]*include[ \t]+" @@ -1764,7 +1770,7 @@ void cmQtAutoGenerators::StrictParseCppFile(const std::string& absFilename, void cmQtAutoGenerators::ParseForUic(const std::string& absFilename, - std::map& includedUis) + std::map >& includedUis) { if (this->UicExecutable.empty()) { @@ -1782,8 +1788,8 @@ void cmQtAutoGenerators::ParseForUic(const std::string& absFilename, void cmQtAutoGenerators::ParseForUic(const std::string& absFilename, - const std::string& contentsString, - std::map& includedUis) + const std::string& contentsString, + std::map >& includedUis) { if (this->UicExecutable.empty()) { @@ -1813,7 +1819,7 @@ void cmQtAutoGenerators::ParseForUic(const std::string& absFilename, // finding the correct header, so we need to remove the ui_ part basename = basename.substr(3); - includedUis[realName] = basename; + includedUis[realName].push_back(basename); matchOffset += uiIncludeRegExp.end(); } while(uiIncludeRegExp.find(contentsString.c_str() + matchOffset)); @@ -1859,9 +1865,9 @@ cmQtAutoGenerators::SearchHeadersForCppFile(const std::string& absFilename, void cmQtAutoGenerators::ParseHeaders(const std::set& absHeaders, - const std::map& includedMocs, - std::map& notIncludedMocs, - std::map& includedUis) + const std::map& includedMocs, + std::map& notIncludedMocs, + std::map >& includedUis) { for(std::set::const_iterator hIt=absHeaders.begin(); hIt!=absHeaders.end(); diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h index 501e13ad5..c298f5d28 100644 --- a/Source/cmQtAutoGenerators.h +++ b/Source/cmQtAutoGenerators.h @@ -51,28 +51,28 @@ private: bool GenerateUi(const std::string& realName, const std::string& uiFileName); bool GenerateQrc(); void ParseCppFile(const std::string& absFilename, - const std::vector& headerExtensions, - std::map& includedMocs, - std::map& includedUis); + const std::vector& headerExtensions, + std::map& includedMocs, + std::map >& includedUis); void StrictParseCppFile(const std::string& absFilename, - const std::vector& headerExtensions, - std::map& includedMocs, - std::map& includedUis); + const std::vector& headerExtensions, + std::map& includedMocs, + std::map >& includedUis); void SearchHeadersForCppFile(const std::string& absFilename, const std::vector& headerExtensions, std::set& absHeaders); void ParseHeaders(const std::set& absHeaders, - const std::map& includedMocs, - std::map& notIncludedMocs, - std::map& includedUis); + const std::map& includedMocs, + std::map& notIncludedMocs, + std::map >& includedUis); void ParseForUic(const std::string& fileName, - const std::string& contentsString, - std::map& includedUis); + const std::string& contentsString, + std::map >& includedUis); void ParseForUic(const std::string& fileName, - std::map& includedUis); + std::map >& includedUis); void Init(); diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt index 39736539b..3fd00b8e0 100644 --- a/Tests/QtAutogen/CMakeLists.txt +++ b/Tests/QtAutogen/CMakeLists.txt @@ -37,6 +37,9 @@ else() endif() +add_executable(rcconly rcconly.cpp second_resource.qrc) +set_property(TARGET rcconly PROPERTY AUTORCC ON) +target_link_libraries(rcconly ${QT_QTCORE_TARGET}) include_directories(${CMAKE_CURRENT_BINARY_DIR}) @@ -71,6 +74,7 @@ if (CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]" AND NOT CMAKE_CONFIGURATION_ endif() add_executable(QtAutogen main.cpp calwidget.cpp second_widget.cpp foo.cpp blub.cpp bar.cpp abc.cpp + multiplewidgets.cpp xyz.cpp yaf.cpp gadget.cpp $ test.qrc second_resource.qrc resourcetester.cpp generated.cpp ${debug_srcs} ) diff --git a/Tests/QtAutogen/multiplewidgets.cpp b/Tests/QtAutogen/multiplewidgets.cpp new file mode 100644 index 000000000..f14387591 --- /dev/null +++ b/Tests/QtAutogen/multiplewidgets.cpp @@ -0,0 +1,19 @@ + +#include "multiplewidgets.h" + +#include "ui_widget1.h" +#include "ui_widget2.h" + +Widget1::Widget1(QWidget *parent) + : QWidget(parent), + ui(new Ui::Widget1) +{ + ui->setupUi(this); +} + +Widget2::Widget2(QWidget *parent) + : QWidget(parent), + ui(new Ui::Widget2) +{ + ui->setupUi(this); +} diff --git a/Tests/QtAutogen/multiplewidgets.h b/Tests/QtAutogen/multiplewidgets.h new file mode 100644 index 000000000..6ae6ad125 --- /dev/null +++ b/Tests/QtAutogen/multiplewidgets.h @@ -0,0 +1,33 @@ + +#ifndef MULTIPLEWIDGETS_H +#define MULTIPLEWIDGETS_H + +#include + +namespace Ui { +class Widget1; +} + +class Widget1 : public QWidget +{ + Q_OBJECT +public: + Widget1(QWidget *parent = 0); +private: + Ui::Widget1 *ui; +}; + +namespace Ui { +class Widget2; +} + +class Widget2 : public QWidget +{ + Q_OBJECT +public: + Widget2(QWidget *parent = 0); +private: + Ui::Widget2 *ui; +}; + +#endif diff --git a/Tests/QtAutogen/rcconly.cpp b/Tests/QtAutogen/rcconly.cpp new file mode 100644 index 000000000..854c4c1bc --- /dev/null +++ b/Tests/QtAutogen/rcconly.cpp @@ -0,0 +1,9 @@ + +extern int qInitResources_second_resource(); + +int main(int, char**) +{ + // Fails to link if the symbol is not present. + qInitResources_second_resource(); + return 0; +} diff --git a/Tests/QtAutogen/widget1.ui b/Tests/QtAutogen/widget1.ui new file mode 100644 index 000000000..8fce81a9a --- /dev/null +++ b/Tests/QtAutogen/widget1.ui @@ -0,0 +1,45 @@ + + + Widget1 + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + 140 + 80 + 80 + 23 + + + + PushButton + + + + + + 190 + 170 + 80 + 23 + + + + PushButton + + + + + + diff --git a/Tests/QtAutogen/widget2.ui b/Tests/QtAutogen/widget2.ui new file mode 100644 index 000000000..1f411b9fb --- /dev/null +++ b/Tests/QtAutogen/widget2.ui @@ -0,0 +1,29 @@ + + + Widget2 + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + 20 + 20 + 256 + 192 + + + + + + +