Skip to content

Commit

Permalink
Meson: Add Qt6-mode support
Browse files Browse the repository at this point in the history
Default to it already.

See osdn #43364

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
  • Loading branch information
cazfi committed May 24, 2022
1 parent 5928f95 commit d94f915
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 17 deletions.
3 changes: 3 additions & 0 deletions doc/INSTALL.meson
Expand Up @@ -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
------
Expand Down
2 changes: 1 addition & 1 deletion gen_headers/meson_fc_config.h.in
Expand Up @@ -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
Expand Down
50 changes: 36 additions & 14 deletions meson.build
Expand Up @@ -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)

Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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']
Expand All @@ -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
)
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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
)
Expand Down
6 changes: 6 additions & 0 deletions meson_options.txt
Expand Up @@ -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')
7 changes: 5 additions & 2 deletions windows/installer_cross/meson-winbuild.sh
Expand Up @@ -63,6 +63,8 @@ fi

SETUP=$(grep "CrosserSetup=" $DLLSPATH/crosser.txt | sed -e 's/CrosserSetup="//' -e 's/"//')

QTPARAMS=""

case $GUI in
gtk3.22) FCMP="gtk3"
RULEDIT=false ;;
Expand All @@ -71,7 +73,8 @@ case $GUI in
qt5) CLIENT="qt"
FCMP="qt"
NLS="-Dnls=false"
RULEDIT=true ;;
RULEDIT=true
QTPARAMS="-Dqtver=qt5" ;;
esac

if test "x$CLIENT" = "x" ; then
Expand Down Expand Up @@ -113,7 +116,7 @@ cd meson-build-${SETUP}-${GUI}
export PKG_CONFIG_PATH=${DLLSPATH}/lib/pkgconfig

if ! meson --cross-file=cross.txt -Dprefix=$MESON_INSTALL_DIR -Dclients=$CLIENT -Dfcmp=$FCMP \
${NLS} -Dsyslua=false -Druledit=$RULEDIT \
${NLS} -Dsyslua=false -Druledit=$RULEDIT $QTPARAMS \
../../.. $EXTRA_CONFIG ; then
echo "Meson run failed!" >&2
exit 1
Expand Down

0 comments on commit d94f915

Please sign in to comment.