]> sigrok.org Git - pulseview.git/commitdiff
Build fixes for Qt5 Windows/mingw/MXE support.
authorUwe Hermann <redacted>
Sun, 29 Jan 2017 18:36:59 +0000 (19:36 +0100)
committerUwe Hermann <redacted>
Sun, 29 Jan 2017 18:48:42 +0000 (19:48 +0100)
We currently need to (ab)use pkg-config to get all the required
Qt5 static linking dependencies right, since this doesn't yet
work properly in MXE's cmake.

We use ${PKGDEPS_STATIC_LDFLAGS} instead of ${PKGDEPS_STATIC_LIBRARIES}
to avoid some linker issues related to libbz2.

We need to add Qt5::QSvgPlugin, Qt5::QWindowsIntegrationPlugin,
Qt5PlatformSupport and all the Qt5 libs and their dependencies to
the link libraries list (for both PulseView and the unit tests).

In one of the source code files we need to explicitly list all
static Qt plugins via Q_IMPORT_PLUGIN to make static builds work,
which is currently QWindowsIntegrationPlugin and QSvgPlugin.

We're only focusing on having a working Qt5 build for Windows,
as we no longer need to or want to support Qt4 there.

Details:
https://github.com/mxe/mxe/issues/1642

Thanks to Tony Theodore for the help!

This should also fix bug #871, since we're now building with Qt >= 5.6
which has high-DPI support in general.

Tested via manual specification (might need further changes, though):

  set QT_SCALE_FACTOR=2
  pulseview.exe

CMakeLists.txt
main.cpp

index ee58ce2cd6b335f00e272dc172ee79f50ab2b2d5..9d35376bbfcd2d9dff1773e306d51bfd0d105ce1 100644 (file)
@@ -81,6 +81,11 @@ if(FORCE_QT4)
        set(Qt5Core_FOUND FALSE)
 else()
        find_package(Qt5Core QUIET)
        set(Qt5Core_FOUND FALSE)
 else()
        find_package(Qt5Core QUIET)
+if(WIN32)
+       # MXE workaround: Use pkg-config to find Qt5 libs.
+       # https://github.com/mxe/mxe/issues/1642
+       pkg_check_modules(QT5ALL REQUIRED Qt5Widgets Qt5Gui Qt5Svg)
+endif()
 endif()
 
 if(Qt5Core_FOUND)
 endif()
 
 if(Qt5Core_FOUND)
@@ -446,11 +451,7 @@ set(PULSEVIEW_LINK_LIBS
 
 if(STATIC_PKGDEPS_LIBS)
        link_directories(${PKGDEPS_STATIC_LIBRARY_DIRS})
 
 if(STATIC_PKGDEPS_LIBS)
        link_directories(${PKGDEPS_STATIC_LIBRARY_DIRS})
-       list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_STATIC_LIBRARIES})
-if(WIN32)
-       # Workaround for a MinGW linking issue.
-       list(APPEND PULSEVIEW_LINK_LIBS "-llzma -llcms2")
-endif()
+       list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_STATIC_LDFLAGS})
 else()
        link_directories(${PKGDEPS_LIBRARY_DIRS})
        list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_LIBRARIES})
 else()
        link_directories(${PKGDEPS_LIBRARY_DIRS})
        list(APPEND PULSEVIEW_LINK_LIBS ${PKGDEPS_LIBRARIES})
@@ -459,10 +460,12 @@ endif()
 if(WIN32)
        # On Windows we need to statically link the libqsvg imageformat
        # plugin (and the QtSvg component) for SVG graphics/icons to work.
 if(WIN32)
        # On Windows we need to statically link the libqsvg imageformat
        # plugin (and the QtSvg component) for SVG graphics/icons to work.
+       # We also need QWindowsIntegrationPlugin, Qt5PlatformSupport, and all
+       # Qt libs and their dependencies.
        add_definitions(-DQT_STATICPLUGIN)
        add_definitions(-DQT_STATICPLUGIN)
-       link_directories("${QT_PLUGINS_DIR}/imageformats")
-       list(APPEND PULSEVIEW_LINK_LIBS "-lqsvg")
-       list(APPEND PULSEVIEW_LINK_LIBS ${QT_QTSVG_LIBRARY})
+       list(APPEND PULSEVIEW_LINK_LIBS Qt5::QSvgPlugin)
+       list(APPEND PULSEVIEW_LINK_LIBS Qt5::QWindowsIntegrationPlugin)
+       list(APPEND PULSEVIEW_LINK_LIBS -lQt5PlatformSupport ${QT5ALL_LDFLAGS})
 endif()
 
 if(ANDROID)
 endif()
 
 if(ANDROID)
index 039670649c61ba3e7197ad1b93a724ab3acd2e7f..0881c184a913d3c704abffca86e50485166e2da9 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -44,9 +44,9 @@
 #include "config.h"
 
 #ifdef _WIN32
 #include "config.h"
 
 #ifdef _WIN32
-// The static qsvg lib is required for SVG graphics/icons (on Windows).
 #include <QtPlugin>
 #include <QtPlugin>
-Q_IMPORT_PLUGIN(qsvg)
+Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
+Q_IMPORT_PLUGIN(QSvgPlugin)
 #endif
 
 void usage()
 #endif
 
 void usage()