Fix compiling against Qt6

This commit is contained in:
Phillip Stephens 2021-02-21 17:56:16 -08:00
parent e1515252f1
commit e0da690d7c
2 changed files with 12 additions and 6 deletions

View File

@ -15,9 +15,11 @@ endif()
find_package(Qt6Widgets QUIET PATHS ${QT_HOMEBREW_PATH}) find_package(Qt6Widgets QUIET PATHS ${QT_HOMEBREW_PATH})
if(Qt6Widgets_FOUND) if(Qt6Widgets_FOUND)
find_package(Qt6 COMPONENTS Core5Compat Network Widgets Xml Gui REQUIRED PATHS ${QT_HOMEBREW_PATH}) find_package(Qt6 COMPONENTS Core5Compat Network Widgets Xml Gui REQUIRED PATHS ${QT_HOMEBREW_PATH})
set(QUAZIP_QT_MAJOR_VERSION 6 CACHE STRING "")
else() else()
find_package(Qt5Widgets REQUIRED PATHS ${QT_HOMEBREW_PATH}) find_package(Qt5Widgets REQUIRED PATHS ${QT_HOMEBREW_PATH})
find_package(Qt5 COMPONENTS Network Widgets Xml Gui REQUIRED PATHS ${QT_HOMEBREW_PATH}) find_package(Qt5 COMPONENTS Network Widgets Xml Gui REQUIRED PATHS ${QT_HOMEBREW_PATH})
set(QUAZIP_QT_MAJOR_VERSION 5 CACHE STRING "")
endif() endif()
set(BUILD_SHARED_LIBS OFF CACHE BOOL "") set(BUILD_SHARED_LIBS OFF CACHE BOOL "")
@ -81,11 +83,11 @@ target_compile_definitions(hecl-gui PRIVATE
if(Qt6Widgets_FOUND) if(Qt6Widgets_FOUND)
set(Qt_LIBS set(Qt_LIBS
Qt6::Core Qt6::Core
Qt6::Core5Compat Qt6::Core5Compat
Qt6::Gui Qt6::Gui
Qt6::Network Qt6::Network
Qt6::Widgets Qt6::Widgets
Qt6::Xml) Qt6::Xml)
else() else()
set(Qt_LIBS set(Qt_LIBS
@ -93,7 +95,8 @@ else()
Qt5::Gui Qt5::Gui
Qt5::Network Qt5::Network
Qt5::Widgets Qt5::Widgets
Qt5::Xml) Qt5::Xml
Qt5::WindowsIntegrationPlugin)
endif() endif()
target_link_libraries(hecl-gui PRIVATE target_link_libraries(hecl-gui PRIVATE
${Qt_LIBS} ${Qt_LIBS}

View File

@ -1,8 +1,11 @@
#include <QtGlobal>
#if defined(_WIN32) && !defined(_DLL) #if defined(_WIN32) && !defined(_DLL)
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
// Static linking on Windows // Static linking on Windows
#include <QtPlugin> #include <QtPlugin>
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin); Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
#endif #endif
#endif
#include <QApplication> #include <QApplication>
#include <QStyleFactory> #include <QStyleFactory>