diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5dd5331b..8bd121fa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,8 +96,8 @@ jobs: python -m pip install --upgrade aqtinstall # there is no win64_msvc2019_64 for Qt 5.12.12 aqt install-qt --outputdir C:\Qt windows desktop 5.15.2 win64_msvc2019_64 + aqt install-qt --outputdir C:\Qt windows desktop 5.15.2 win64_mingw81 # aqt install-qt --outputdir C:\Qt windows desktop 5.12.12 win64_msvc2017_64 - # aqt install-qt --outputdir C:\Qt windows desktop 5.15.2 win64_mingw81 fi shell: bash diff --git a/demos/README.rst b/demos/README.rst index 311b29e6..d3fa4ea2 100644 --- a/demos/README.rst +++ b/demos/README.rst @@ -48,4 +48,4 @@ MS Windows: - pyyaml (optional) - msvc (Microsoft Visual C++) - boost - - qt5 (in C:\Qt) + - qt5 (msvc and mingw versions in C:\Qt) diff --git a/demos/qt5/03-simple-nomsvc/appwindow.cpp b/demos/qt5/03-simple-nomsvc/appwindow.cpp new file mode 100644 index 00000000..aec4b41a --- /dev/null +++ b/demos/qt5/03-simple-nomsvc/appwindow.cpp @@ -0,0 +1,40 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "appwindow.h" + +AppWindow::AppWindow() +{ + auto* newAct = new QAction(tr("&New"), this); + auto* openAct = new QAction(tr("&Open"), this); + auto* quitAct = new QAction(tr("&Quit"), this); + quitAct->setShortcuts(QKeySequence::Quit); + quitAct->setStatusTip(tr("Exit the application")); + + connect(quitAct, &QAction::triggered, qApp, &QApplication::quit); + + auto* menu = menuBar()->addMenu(tr("&File")); + menu->addAction(newAct); + menu->addAction(openAct); + menu->addAction(quitAct); + + auto* toolbar = addToolBar(tr("Main toolbar")); + toolbar->addAction(newAct); + toolbar->addAction(openAct); + toolbar->addSeparator(); + toolbar->addAction(quitAct); + + auto* edit = new QTextEdit(this); + edit->setText("Hello, world!"); + edit->append(QString("Qt version: ") + qVersion()); + + setCentralWidget(edit); + + statusBar()->showMessage(tr("Ready")); +} diff --git a/demos/qt5/03-simple-nomsvc/appwindow.h b/demos/qt5/03-simple-nomsvc/appwindow.h new file mode 100644 index 00000000..5957fabc --- /dev/null +++ b/demos/qt5/03-simple-nomsvc/appwindow.h @@ -0,0 +1,9 @@ +#pragma once + +#include + +class AppWindow : public QMainWindow +{ +public: + AppWindow(); +}; diff --git a/demos/qt5/03-simple-nomsvc/buildconf.yml b/demos/qt5/03-simple-nomsvc/buildconf.yml new file mode 100644 index 00000000..7e30fc8e --- /dev/null +++ b/demos/qt5/03-simple-nomsvc/buildconf.yml @@ -0,0 +1,20 @@ + +tasks: + main: + features : cxxprogram qt5 + source : appwindow.cpp main.cpp + use : QtWidgets + +GCC_BASE_FLAGS: -std=c++11 -fPIC + +buildtypes: + debug: + cxxflags: $GCC_BASE_FLAGS -O0 -g + toolchain: g++ # force use of gcc + + release: + cxxflags: $GCC_BASE_FLAGS -O2 + toolchain: g++ # force use of gcc + + default: debug + diff --git a/demos/qt5/03-simple-nomsvc/main.cpp b/demos/qt5/03-simple-nomsvc/main.cpp new file mode 100644 index 00000000..d1e216e3 --- /dev/null +++ b/demos/qt5/03-simple-nomsvc/main.cpp @@ -0,0 +1,17 @@ + +#include + +#include "appwindow.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + AppWindow window; + + window.resize(500, 300); + window.setWindowTitle("Simple example"); + window.show(); + + return app.exec(); +} diff --git a/src/zenmake/zm/features/qt5.py b/src/zenmake/zm/features/qt5.py index 67871cc4..8e78e351 100644 --- a/src/zenmake/zm/features/qt5.py +++ b/src/zenmake/zm/features/qt5.py @@ -391,11 +391,20 @@ def _findSingleQt5LibAsIs(conf, qtlibname, qtlibDeps, forceStatic): qtLibDir = env.QTLIBS uselib = qtlibname.upper() + isMSVC = conf.env.CXX_NAME == 'msvc' + if forceStatic: exts = ('.a', '.lib') envPrefix = 'STLIB' else: - exts = ('.so', '.lib') + if isMSVC: + exts = ('.lib', ) + elif env.DEST_OS == 'win32': + # MinGW g++/clang++ + # .a files from mingw version of Qt5 are not static libs + exts = ('.a', ) + else: + exts = ('.so', '.lib') envPrefix = 'LIB' def libPrefixExt(): @@ -413,7 +422,8 @@ def setUpLib(prefix, module, ext): if not _pathexists(_joinpath(qtLibDir, libFileName)): return False - libval = prefix + basename if env.DEST_OS == 'win32' else basename + #libval = prefix + basename if env.DEST_OS == 'win32' else basename + libval = basename env.append_unique('%s_%s' % (envPrefix, uselib), libval) addModuleDefine(module) return True diff --git a/tests/func_base_test.py b/tests/func_base_test.py index e96a0ff6..2412cf96 100644 --- a/tests/func_base_test.py +++ b/tests/func_base_test.py @@ -32,6 +32,7 @@ RE_ALL_GTK3 = '^gtk3/' RE_ALL_SDL2 = '^sdl2/' RE_ALL_QT5 = '^qt5/' +RE_QT5_WINONLY = '^qt5/03-simple-nomsvc' RE_EXT_DEPS = '^external-deps/' TEST_CONDITIONS = { @@ -48,6 +49,7 @@ dict(regexp = RE_ALL_DBUS, condition = dict( os = ['linux'], )), dict(regexp = RE_ALL_GTK3, condition = dict( os = ['linux'], )), dict(regexp = RE_ALL_SDL2, condition = dict( os = ['linux'], )), + dict(regexp = RE_QT5_WINONLY, condition = dict( os = ['windows'], )), dict(regexp = RE_ALL_QT5, condition = dict( os = ['linux', 'windows'], )), dict(regexp = RE_EXT_DEPS + '1-makefile', condition = dict( os = ['linux', 'darwin'], )),