From 554d6589d37773299e7868dcb177b0442241dbe7 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 8 May 2022 08:29:07 +0300 Subject: [PATCH 61/61] Meson: Add Qt6-mode support Default to it already. See osdn #43364 Signed-off-by: Marko Lindqvist --- doc/INSTALL.meson | 3 ++ gen_headers/meson_fc_config.h.in | 2 +- meson.build | 50 +++++++++++++++++++++++--------- meson_options.txt | 6 ++++ 4 files changed, 46 insertions(+), 15 deletions(-) diff --git a/doc/INSTALL.meson b/doc/INSTALL.meson index 94cf14e8ba..79eb71bc39 100644 --- a/doc/INSTALL.meson +++ b/doc/INSTALL.meson @@ -138,6 +138,9 @@ freeciv-web (boolean): gen-packets-args (array): Aditional packet generator arguments passed to common/generate_packets.py. +qtver ('qt5'/'qt6'): + Whether to build Qt5 or Qt6 versions of the binaries. + run.sh ------ diff --git a/gen_headers/meson_fc_config.h.in b/gen_headers/meson_fc_config.h.in index 2bea1938c9..ea46b3057f 100644 --- a/gen_headers/meson_fc_config.h.in +++ b/gen_headers/meson_fc_config.h.in @@ -49,7 +49,7 @@ #define HAVE_FCDB_SQLITE3 1 /* Build in Qt5 mode */ -#define FC_QT5_MODE +#mesondefine FC_QT5_MODE /* Release cycle information */ #mesondefine IS_DEVEL_VERSION diff --git a/meson.build b/meson.build index b6e2df7e78..2442c91bbb 100644 --- a/meson.build +++ b/meson.build @@ -398,6 +398,10 @@ if get_option('audio') or get_option('clients').contains('sdl2') endif endif +if get_option('qtver') == 'qt5' + priv_conf_data.set('FC_QT5_MODE', 1) +endif + if get_option('audio') priv_conf_data.set('AUDIO_SDL', 1) @@ -2506,17 +2510,27 @@ install_data('data/themes/gtk3.22/Freeciv/gtk-3.0/gtk.css', endif -qt5_mod = import('qt5') +if get_option('qtver') == 'qt6' + qt_mod = import('qt6') + + qt_dep = dependency('Qt6', modules: ['Core', 'Gui', 'Widgets'], required: false) +else + qt_mod = import('qt5') -qt5_dep = dependency('Qt5', modules: ['Core', 'Gui', 'Widgets'], required: false) + qt_dep = dependency('Qt5', modules: ['Core', 'Gui', 'Widgets'], required: false) +endif if get_option('clients').contains('qt') -if not qt5_dep.found() - error('Qt5 >= 5.11 required for qt-client, but not found') +if not qt_dep.found() + if get_option('qtver') == 'qt6' + error('Qt6 >= 6.0 required for qt-client in Qt6 mode, but not found') + else + error('Qt5 >= 5.11 required for qt-client in Qt5 mode, but not found') + endif endif -mocced_client = qt5_mod.preprocess( +mocced_client = qt_mod.preprocess( moc_headers: [ 'client/gui-qt/fc_client.h', 'client/gui-qt/ratesdlg.h', @@ -2582,7 +2596,7 @@ executable('freeciv-qt', 'client/gui_interface.c', mocced_client, clienticon, include_directories: [client_inc, include_directories('client/gui-qt')], - dependencies: [qt5_dep, net_dep, gettext_dep], + dependencies: [qt_dep, net_dep, gettext_dep], link_with: client_common, install: true) @@ -2904,11 +2918,15 @@ endif if get_option('fcmp').contains('qt') -if not qt5_dep.found() - error('Qt5 >= 5.11 required for qt-modpack-installer, but not found') +if not qt_dep.found() + if get_option('qtver') == 'qt6' + error('Qt6 >= 6.0 required for qt-modpack-installer in Qt6 mode, but not found') + else + error('Qt5 >= 5.11 required for qt-modpack-installer in Qt5 mode, but not found') + endif endif -mocced_fcmp = qt5_mod.preprocess( +mocced_fcmp = qt_mod.preprocess( moc_headers: [ 'tools/fcmp/mpgui_qt.h', 'tools/fcmp/mpgui_qt_worker.h'] @@ -2919,7 +2937,7 @@ executable('freeciv-mp-qt', 'tools/fcmp/mpgui_qt_worker.cpp', mocced_fcmp, mpicon, include_directories: tool_inc, - dependencies: [qt5_dep, sqlite3_dep, gettext_dep], + dependencies: [qt_dep, sqlite3_dep, gettext_dep], link_with: [common_lib, fcmp_common], install: true ) @@ -2957,11 +2975,15 @@ executable('freeciv-ruleup', if get_option('ruledit') -if not qt5_dep.found() - error('Qt5 >= 5.11 required for ruledit, but not found') +if not qt_dep.found() + if get_option('qtver') == 'qt6' + error('Qt6 >= 6.0 required for ruledit in Qt6 mode, but not found') + else + error('Qt5 >= 5.11 required for ruledit in Qt5 mode, but not found') + endif endif -mocced_ruledit = qt5_mod.preprocess( +mocced_ruledit = qt_mod.preprocess( moc_headers: [ 'tools/ruledit/conversion_log.h', 'tools/ruledit/edit_impr.h', @@ -3009,7 +3031,7 @@ executable('freeciv-ruledit', 'tools/ruledit/validity.c', mocced_ruledit, rulediticon, include_directories: tool_inc, - dependencies: [qt5_dep, m_dep, net_dep, readline_dep, gettext_dep], + dependencies: [qt_dep, m_dep, net_dep, readline_dep, gettext_dep], link_with: [common_lib, server_lib, ais, tool_lib], install: true ) diff --git a/meson_options.txt b/meson_options.txt index 91d2656cff..8d016e92f6 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -59,3 +59,9 @@ option('gen-packets-args', type: 'array', value: [], description: 'Additional arguments for the packet generator') + +option('qtver', + type: 'combo', + choices: ['qt5', 'qt6'], + value: 'qt6', + description: 'Whether to build Qt5 or Qt6 versions of the binaries') -- 2.35.1