Skip to content

Commit

Permalink
qt6
Browse files Browse the repository at this point in the history
  • Loading branch information
benapetr committed Mar 29, 2024
1 parent 7561af8 commit 8de821c
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 65 deletions.
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,17 @@ endif()

option(LINUX_SNAP "Enable support for snap, use this option only if you are building snapshotable version" false)
option(QT5_BUILD "Build Huggle using the Qt5 framework" true)
option(QT6_BUILD "Build Huggle using the Qt6 framework" false)
option(HUGGLE_PROFILING "Enable profiler" false)
option(HUGGLE_EXT "Build Huggle extensions" false)
option(HUGGLE_TEST "Unit tests" false)
option(WEB_ENGINE "Use Qt WebEngine instead of WebKit library" false)
option(AUDIO "Enable audio backend" true)

if (QT6_BUILD)
set (QT5_BUILD true)
endif()

set(HUGGLE_CMAKE true)

if (NOT AUDIO)
Expand Down
34 changes: 26 additions & 8 deletions src/huggle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@ endif()
project(huggle)
include(GNUInstallDirs)

find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Widgets REQUIRED)
set(QT_INCLUDES ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
include_directories(${QT_INCLUDES})
if (QT6_BUILD)
find_package(Qt6Core REQUIRED)
find_package(Qt6Gui REQUIRED)
find_package(Qt6Widgets REQUIRED)
set(QT_INCLUDES ${Qt6Gui_INCLUDE_DIRS} ${Qt6Widgets_INCLUDE_DIRS})
include_directories(${QT_INCLUDES})
elseif (QT5_BUILD)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Widgets REQUIRED)
set(QT_INCLUDES ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
include_directories(${QT_INCLUDES})
endif()

file(GLOB srcx "*.cpp")
file(GLOB resx "*.qrc")
Expand All @@ -23,9 +31,15 @@ set(huggle_SOURCES ${srcx})
set(huggle_FORMS ${uixx})
set(huggle_RESOURCES ${resx})

QT5_WRAP_CPP(huggle_HEADERS_MOC ${huggle_HEADERS})
QT5_WRAP_UI(huggle_FORMS_HEADERS ${huggle_FORMS})
QT5_ADD_RESOURCES(huggle_RESOURCES_RCC ${huggle_RESOURCES})
if (QT6_BUILD)
QT6_WRAP_CPP(huggle_HEADERS_MOC ${huggle_HEADERS})
QT6_WRAP_UI(huggle_FORMS_HEADERS ${huggle_FORMS})
QT6_ADD_RESOURCES(huggle_RESOURCES_RCC ${huggle_RESOURCES})
elseif (QT5_BUILD)
QT5_WRAP_CPP(huggle_HEADERS_MOC ${huggle_HEADERS})
QT5_WRAP_UI(huggle_FORMS_HEADERS ${huggle_FORMS})
QT5_ADD_RESOURCES(huggle_RESOURCES_RCC ${huggle_RESOURCES})
endif()

add_definitions(${QT_DEFINITIONS})

Expand All @@ -38,7 +52,11 @@ endif()

target_link_libraries(huggle huggle_l10n huggle_res huggle_core huggle_ui)

if (QT6_BUILD)
target_link_libraries(huggle Qt6::Core Qt6::Gui Qt6::Widgets)
elseif (QT5_BUILD)
target_link_libraries(huggle Qt5::Core Qt5::Gui Qt5::Widgets)
endif()

include_directories(${CMAKE_CURRENT_BINARY_DIR})
install(FILES ${CMAKE_SOURCE_DIR}/huggle/man/huggle.1 DESTINATION share/man/man1)
Expand Down
22 changes: 11 additions & 11 deletions src/huggle_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ include(GNUInstallDirs)
set(CMAKE_include_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)

find_package(Qt5Core REQUIRED)
find_package(Qt5Xml REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5Qml REQUIRED)
set(QT_INCLUDES ${Qt5Network_INCLUDE_DIRS} ${Qt5Qml_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS})
find_package(Qt6Core REQUIRED)
find_package(Qt6Xml REQUIRED)
find_package(Qt6Network REQUIRED)
find_package(Qt6Qml REQUIRED)
set(QT_INCLUDES ${Qt6Network_INCLUDE_DIRS} ${Qt6Qml_INCLUDE_DIRS} ${Qt6Xml_INCLUDE_DIRS})
if (AUDIO)
find_package(Qt5Multimedia REQUIRED)
set(QT_INCLUDES ${QT_INCLUDES} ${Qt5Multimedia_INCLUDE_DIRS})
find_package(Qt6Multimedia REQUIRED)
set(QT_INCLUDES ${QT_INCLUDES} ${Qt6Multimedia_INCLUDE_DIRS})
endif()
include_directories(${QT_INCLUDES})

Expand All @@ -31,8 +31,8 @@ file(GLOB headers "*.hpp" "scripting/*.hpp")
set(huggle_core_SOURCES ${srcx})
set(huggle_core_RESOURCES ${resx})

QT5_WRAP_CPP(huggle_core_HEADERS_MOC ${huggle_core_HEADERS})
QT5_ADD_RESOURCES(huggle_core_RESOURCES_RCC ${huggle_core_RESOURCES})
QT6_WRAP_CPP(huggle_core_HEADERS_MOC ${huggle_core_HEADERS})
QT6_ADD_RESOURCES(huggle_core_RESOURCES_RCC ${huggle_core_RESOURCES})

add_definitions(${QT_DEFINITIONS})
add_definitions( -DQT_USE_QSTRINGBUILDER )
Expand All @@ -46,9 +46,9 @@ if (WIN32)
endif()

target_link_libraries(huggle_core huggle_l10n irc ircclient yaml-cpp)
target_link_libraries(huggle_core Qt5::Core Qt5::Network Qt5::Xml Qt5::Qml)
target_link_libraries(huggle_core Qt6::Core Qt6::Network Qt6::Xml Qt6::Qml)
if (AUDIO)
target_link_libraries(huggle_core Qt5::Multimedia)
target_link_libraries(huggle_core Qt6::Multimedia)
endif()

include_directories(${CMAKE_CURRENT_BINARY_DIR})
Expand Down
24 changes: 20 additions & 4 deletions src/huggle_l10n/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ include(GNUInstallDirs)
set(CMAKE_include_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)

find_package(Qt5Core REQUIRED)
find_package(Qt5Xml REQUIRED)
set(QT_INCLUDES ${Qt5Xml_INCLUDE_DIRS})
include_directories(${QT_INCLUDES})
if (QT6_BUILD)
find_package(Qt6Core REQUIRED)
find_package(Qt6Xml REQUIRED)
set(QT_INCLUDES ${Qt6Xml_INCLUDE_DIRS})
include_directories(${QT_INCLUDES})
elseif (QT5_BUILD)
find_package(Qt5Core REQUIRED)
find_package(Qt5Xml REQUIRED)
set(QT_INCLUDES ${Qt5Xml_INCLUDE_DIRS})
include_directories(${QT_INCLUDES})
endif()

file(GLOB srcx "*.cpp")
file(GLOB resx "*.qrc")
Expand All @@ -23,8 +30,13 @@ file(GLOB headers "*.hpp")
set(huggle_l10n_SOURCES ${srcx})
set(huggle_l10n_RESOURCES ${resx})

if(QT6_BUILD)
QT6_WRAP_CPP(huggle_l10n_HEADERS_MOC ${huggle_l10n_HEADERS})
QT6_ADD_RESOURCES(huggle_l10n_RESOURCES_RCC ${huggle_l10n_RESOURCES})
elseif(QT5_BUILD)
QT5_WRAP_CPP(huggle_l10n_HEADERS_MOC ${huggle_l10n_HEADERS})
QT5_ADD_RESOURCES(huggle_l10n_RESOURCES_RCC ${huggle_l10n_RESOURCES})
endif()

add_definitions(${QT_DEFINITIONS})
add_definitions( -DQT_USE_QSTRINGBUILDER )
Expand All @@ -37,7 +49,11 @@ if (WIN32)
target_link_libraries(huggle_l10n dbghelp)
endif()

if (QT6_BUILD)
target_link_libraries(huggle_l10n Qt6::Core Qt6::Xml)
elseif (QT5_BUILD)
target_link_libraries(huggle_l10n Qt5::Core Qt5::Xml)
endif()

include_directories(${CMAKE_CURRENT_BINARY_DIR})
IF (NOT WIN32)
Expand Down
26 changes: 21 additions & 5 deletions src/huggle_res/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ include(GNUInstallDirs)
set(CMAKE_include_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)

find_package(Qt5Core REQUIRED)
find_package(Qt5Xml REQUIRED)
set(QT_INCLUDES ${Qt5Gui_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5Svg_INCLUDE_DIRS})
include_directories(${QT_INCLUDES})
if (QT6_BUILD)
find_package(Qt6Core REQUIRED)
find_package(Qt6Xml REQUIRED)
set(QT_INCLUDES ${Qt6Gui_INCLUDE_DIRS} ${Qt6Xml_INCLUDE_DIRS})
include_directories(${QT_INCLUDES})
elseif (QT5_BUILD)
find_package(Qt5Core REQUIRED)
find_package(Qt5Xml REQUIRED)
set(QT_INCLUDES ${Qt5Gui_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS})
include_directories(${QT_INCLUDES})
endif()

file(GLOB srcx "*.cpp")
file(GLOB resx "*.qrc")
Expand All @@ -26,8 +33,13 @@ if (AUDIO)
set(huggle_res_RESOURCES ${huggle_res_RESOURCES} "sounds/resources.qrc")
endif()

if (QT6_BUILD)
QT6_WRAP_CPP(huggle_res_HEADERS_MOC ${huggle_res_HEADERS})
QT6_ADD_RESOURCES(huggle_res_RESOURCES_RCC ${huggle_res_RESOURCES})
elseif (QT5_BUILD)
QT5_WRAP_CPP(huggle_res_HEADERS_MOC ${huggle_res_HEADERS})
QT5_ADD_RESOURCES(huggle_res_RESOURCES_RCC ${huggle_res_RESOURCES})
endif()

add_definitions(${QT_DEFINITIONS})
add_definitions( -DQT_USE_QSTRINGBUILDER )
Expand All @@ -40,7 +52,11 @@ if (WIN32)
target_link_libraries(huggle_res dbghelp)
endif()

target_link_libraries(huggle_res Qt5::Core Qt5::Xml)
if (QT6_BUILD)
target_link_libraries(huggle_res Qt6::Core Qt6::Xml)
elseif (QT5_BUILD)
target_link_libraries(huggle_res Qt5::Core Qt5::Xml)
endif()

include_directories(${CMAKE_CURRENT_BINARY_DIR})
INSTALL(TARGETS huggle_res DESTINATION ${CMAKE_INSTALL_LIBDIR})
90 changes: 60 additions & 30 deletions src/huggle_ui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,43 @@ include(GNUInstallDirs)

set(CMAKE_include_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Xml REQUIRED)
find_package(Qt5Qml REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Network REQUIRED)
set(QT_INCLUDES ${Qt5Gui_INCLUDE_DIRS} ${Qt5Qml_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5Svg_INCLUDE_DIRS})
if (NOT WEB_ENGINE)
find_package(Qt5WebKit REQUIRED)
find_package(Qt5WebKitWidgets REQUIRED)
set(QT_INCLUDES ${QT_INCLUDES} ${Qt5WebKit_INCLUDE_DIRS} ${Qt5WebKitWidgets_INCLUDE_DIRS})
else()
find_package(Qt5WebEngine REQUIRED)
find_package(Qt5WebEngineWidgets REQUIRED)
set(QT_INCLUDES ${QT_INCLUDES} ${Qt5WebEngine_INCLUDE_DIRS})
endif()
if (AUDIO)
find_package(Qt5Multimedia REQUIRED)
set(QT_INCLUDES ${QT_INCLUDES} ${Qt5Multimedia_INCLUDE_DIRS})

if (QT6_BUILD)
find_package(Qt6Core REQUIRED)
find_package(Qt6Gui REQUIRED)
find_package(Qt6Xml REQUIRED)
find_package(Qt6Qml REQUIRED)
find_package(Qt6Widgets REQUIRED)
find_package(Qt6Network REQUIRED)
set(QT_INCLUDES ${Qt6Gui_INCLUDE_DIRS} ${Qt6Qml_INCLUDE_DIRS} ${Qt6Widgets_INCLUDE_DIRS} ${Qt6Network_INCLUDE_DIRS} ${Qt6Xml_INCLUDE_DIRS} ${Qt6Svg_INCLUDE_DIRS})
find_package(Qt6WebEngineCore REQUIRED)
find_package(Qt6WebEngineWidgets REQUIRED)
set(QT_INCLUDES ${QT_INCLUDES} ${Qt6WebEngineCore_INCLUDE_DIRS})
if (AUDIO)
find_package(Qt6Multimedia REQUIRED)
set(QT_INCLUDES ${QT_INCLUDES} ${Qt6Multimedia_INCLUDE_DIRS})
endif()
elseif()
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Xml REQUIRED)
find_package(Qt5Qml REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Network REQUIRED)
set(QT_INCLUDES ${Qt5Gui_INCLUDE_DIRS} ${Qt5Qml_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5Svg_INCLUDE_DIRS})
if (NOT WEB_ENGINE)
find_package(Qt5WebKit REQUIRED)
find_package(Qt5WebKitWidgets REQUIRED)
set(QT_INCLUDES ${QT_INCLUDES} ${Qt5WebKit_INCLUDE_DIRS} ${Qt5WebKitWidgets_INCLUDE_DIRS})
else()
find_package(Qt5WebEngine REQUIRED)
find_package(Qt5WebEngineWidgets REQUIRED)
set(QT_INCLUDES ${QT_INCLUDES} ${Qt5WebEngine_INCLUDE_DIRS})
endif()
if (AUDIO)
find_package(Qt5Multimedia REQUIRED)
set(QT_INCLUDES ${QT_INCLUDES} ${Qt5Multimedia_INCLUDE_DIRS})
endif()
endif()
include_directories(${QT_INCLUDES})

Expand All @@ -53,9 +71,15 @@ set(huggle_ui_SOURCES ${srcx} ${srcx_web})
set(huggle_ui_FORMS ${uixx} ${uixx_web})
set(huggle_ui_RESOURCES ${resx} ${resx_web})

QT5_WRAP_CPP(huggle_ui_HEADERS_MOC ${huggle_ui_HEADERS})
QT5_WRAP_UI(huggle_ui_FORMS_HEADERS ${huggle_ui_FORMS})
QT5_ADD_RESOURCES(huggle_ui_RESOURCES_RCC ${huggle_ui_RESOURCES})
if (QT6_BUILD)
QT6_WRAP_CPP(huggle_ui_HEADERS_MOC ${huggle_ui_HEADERS})
QT6_WRAP_UI(huggle_ui_FORMS_HEADERS ${huggle_ui_FORMS})
QT6_ADD_RESOURCES(huggle_ui_RESOURCES_RCC ${huggle_ui_RESOURCES})
elseif()
QT5_WRAP_CPP(huggle_ui_HEADERS_MOC ${huggle_ui_HEADERS})
QT5_WRAP_UI(huggle_ui_FORMS_HEADERS ${huggle_ui_FORMS})
QT5_ADD_RESOURCES(huggle_ui_RESOURCES_RCC ${huggle_ui_RESOURCES})
endif()

add_definitions(${QT_DEFINITIONS})
add_definitions( -DQT_USE_QSTRINGBUILDER )
Expand All @@ -70,14 +94,20 @@ endif()

target_link_libraries(huggle_ui huggle_core huggle_res irc ircclient yaml-cpp)

if (NOT WEB_ENGINE)
target_link_libraries(huggle_ui Qt5::Core Qt5::Gui Qt5::Qml Qt5::Widgets Qt5::WebKitWidgets Qt5::WebKit Qt5::Network Qt5::Xml)
else()
target_link_libraries(huggle_ui Qt5::Core Qt5::Gui Qt5::Widgets Qt5::WebEngineWidgets Qt5::WebEngine Qt5::Network Qt5::Xml)
endif()

if (AUDIO)
target_link_libraries(huggle_ui Qt5::Multimedia)
if (QT6_BUILD)
target_link_libraries(huggle_ui Qt6::Core Qt6::Gui Qt6::Widgets Qt6::WebEngineWidgets Qt6::WebEngineCore Qt6::Network Qt6::Xml)
if (AUDIO)
target_link_libraries(huggle_ui Qt6::Multimedia)
endif()
elseif()
if (NOT WEB_ENGINE)
target_link_libraries(huggle_ui Qt5::Core Qt5::Gui Qt5::Qml Qt5::Widgets Qt5::WebKitWidgets Qt5::WebKit Qt5::Network Qt5::Xml)
else()
target_link_libraries(huggle_ui Qt5::Core Qt5::Gui Qt5::Widgets Qt5::WebEngineWidgets Qt5::WebEngine Qt5::Network Qt5::Xml)
endif()
if (AUDIO)
target_link_libraries(huggle_ui Qt5::Multimedia)
endif()
endif()

include_directories(${CMAKE_CURRENT_BINARY_DIR})
Expand Down
20 changes: 13 additions & 7 deletions windows/release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ param
(
[string]$msbuild_path = "C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe",
[string]$root_path = $PWD,
[string]$qt5_path = "C:\Qt\5.7\msvc2013\",
[string]$qt_path = "C:\Qt\5.7\msvc2013\",
[string]$nsis_path = "C:\Program Files (x86)\NSIS\makensis.exe",
[string]$openssl_path = "C:\OpenSSL-Win32",
[string]$cmake_generator = "Visual Studio 12 2013",
Expand All @@ -42,7 +42,8 @@ param
[bool]$python = $true,
[string]$vcredist = "vcredist_x86.exe",
[string]$cmake_param = "",
[string]$vcinstall_path = "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\"
[string]$vcinstall_path = "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\",
[int]$qt_version = 5
)

$ErrorActionPreference = "Stop"
Expand Down Expand Up @@ -119,7 +120,7 @@ if ($mingw)
{
PackageTest "MSBuild" "$msbuild_path" "msbuild_path"
}
PackageTest "Qt5" "$qt5_path" "qt5_path"
PackageTest "Qt" "$qt_path" "qt_path"
PackageTest "OpenSSL" "$openssl_path" "openssl_path"
PackageTest "nsis" "$nsis_path" "nsis_path"
$git_enabled = $true
Expand Down Expand Up @@ -167,12 +168,17 @@ cd $root_path
echo "Running cmake"
mkdir build | Out-Null
cd build
$qt_params = "-DQT5BUILD=true"
if ($qt_version -eq 6)
{
$qt_params = "-DQT6BUILD=true -DQT5BUILD=false"
}
if ($python)
{
cmake ..\..\src\ -G "$cmake_generator" -DWEB_ENGINE=true -DPYTHON_BUILD=true -DCMAKE_PREFIX_PATH:STRING=$qt5_path -Wno-dev -DHUGGLE_EXT=true $cmake_param
cmake ..\..\src\ -G "$cmake_generator" -DWEB_ENGINE=true -DPYTHON_BUILD=true -DCMAKE_PREFIX_PATH:STRING=$qt_path -Wno-dev -DHUGGLE_EXT=true $qt_params $cmake_param
} else
{
cmake ..\..\src\ -G "$cmake_generator" -DWEB_ENGINE=true -DPYTHON_BUILD=false -DCMAKE_PREFIX_PATH:STRING=$qt5_path -Wno-dev -DHUGGLE_EXT=true $cmake_param
cmake ..\..\src\ -G "$cmake_generator" -DWEB_ENGINE=true -DPYTHON_BUILD=false -DCMAKE_PREFIX_PATH:STRING=$qt_path -Wno-dev -DHUGGLE_EXT=true $qt_params $cmake_param
}
if ($mingw)
{
Expand All @@ -198,15 +204,15 @@ cp ..\src\scripts\*.js release\extensions
cp ..\src\huggle_res\Resources\huggle.ico huggle.ico
cp ..\src\huggle_res\Resources\huggle.ico release
# missing Qt dll, bug in winqtdeploy :/
cp $qt5_path\bin\Qt5Multimedia.dll release
cp $qt_path\bin\Qt5Multimedia.dll release
cp $openssl_path\libssl32.dll release
cp $openssl_path\bin\ssleay32.dll release
cp $openssl_path\bin\libeay32.dll release

# Set the environment variable needed by windeployqt, todo: check if it's already set
$env:VCINSTALLDIR = $vcinstall_path

Invoke-Expression "$qt5_path\bin\windeployqt.exe release\huggle_ui.dll"
Invoke-Expression "$qt_path\bin\windeployqt.exe release\huggle_ui.dll"

echo "Making package out of this"

Expand Down

0 comments on commit 8de821c

Please sign in to comment.