diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a9f0a9a80..c32c94ac9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -133,6 +133,12 @@ if(QT) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) + + # if we want to use qt5-static to eliminate need for bundling qt dlls (windows) + #set(QT_STATIC ON) + # needed to build with qt5-static if both qt5 and qt5-static are installed + #set(CMAKE_PREFIX_PATH "path/to/qt5-static") + find_package(Qt5 COMPONENTS Core Widgets REQUIRED) endif() diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index 96d3ba6d4..65ae7c643 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -107,6 +107,13 @@ target_link_libraries( Threads::Threads ) +# needed for static builds +if (WIN32) + qt_import_plugins(plat INCLUDE Qt5::QWindowsIntegrationPlugin Qt5::QICOPlugin QWindowsVistaStylePlugin) +else() + qt_import_plugins(plat INCLUDE Qt5::QICOPlugin) +endif() + if (PkgConfig_FOUND) pkg_check_modules(RTMIDI rtmidi) if (RTMIDI_FOUND) diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index 8aa878e3e..48ca388ac 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -4,6 +4,16 @@ #include #include +#ifdef QT_STATIC +/* Static builds need plugin imports */ +#include +Q_IMPORT_PLUGIN(QICOPlugin) +#ifdef Q_OS_WINDOWS +Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin) +Q_IMPORT_PLUGIN(QWindowsVistaStylePlugin) +#endif +#endif + #include <86box/86box.h> #include <86box/plat.h> #include <86box/ui.h>