Project

General

Profile

Feature #1218 ยป 0021-Drop-qt5-configure-options.patch

Marko Lindqvist, 01/18/2025 02:22 PM

View differences:

INSTALL
This file describes how to compile and install Freeciv. Last time we
made sure this file is up to date was 16-Jul-06.
Last minor update was 10-Jul-24.
Last minor update was 18-Jan-25.
There may be a localized version of this file in the ./doc directory,
named INSTALL.<locale> (e.g., INSTALL.de).
......
- C++ compiler.
Qt-client is written in C++, so you need appropriate compiler.
Compiler needs to support c++17 standard, or,
in case of --with-qtver=qt5 build, just c++11 standard
Compiler needs to support c++17 standard.
In Freeciv development, g++ has been the primary C++ compiler.
Also clang++ has been used.
......
- Qt Meta Object Compiler (moc)
Qt's Meta Object Compiler is a command usually called 'moc', or
'moc-qt6' or 'moc-qt5' depending on Qt version in some systems.
'moc-qt6'.
You may want install 'qtchooser' to find correct moc version for you
when you have multiple Qt versions installed in parallel.
......
- Qt6Core, Qt6Gui, and Qt6Widgets libraries and headers.
At least version 6.0 is required.
If one configures with Qt5 compatibility switch --with-qtver=qt5,
required libraries and headers are Qt5Core, Qt5Gui, and Qt5Widgets
and at least version 5.15 of Qt is required.
2. Generating Makefiles
Makefile.am
m4/postgres.m4 \
m4/progtest.m4 \
m4/qt.m4 \
m4/qt5.m4 \
m4/qt6.m4 \
m4/qt5-darwin.m4 \
m4/qt6-darwin.m4 \
m4/qt-client.m4 \
m4/readline.m4 \
configure.ac
UTILITY_CFLAGS="${UTILITY_CFLAGS} ${ICU_CFLAGS}"
UTILITY_LIBS="${UTILITY_LIBS} ${ICU_LIBS}"
dnl Should we build Qt5 versions of Qt programs?
dnl This needs to be before C++ compiler check FC_WORKING_CXX, and
dnl that in turn needs to be before FC_DEBUG that will depend on compiler
dnl when setting compiler flags.
AC_ARG_WITH([qtver],
AS_HELP_STRING([--with-qtver], [which Qt version to build against qt5/qt6/qt6x]),
AS_HELP_STRING([--with-qtver], [which Qt version to build against qt6/qt6x]),
[case "${withval}" in
qt5|Qt5) qt_ver="Qt5" ;;
qt6|Qt6) qt_ver="Qt6" ;;
qt6x|Qt6x) qt_ver="Qt6x" ;;
*) AC_MSG_ERROR([bad value ${enableval} for --with-qtver]) ;;
esac], [qt_ver="Qt6"])
if test "x$qt_ver" = "xQt5" ; then
AC_DEFINE([FC_QT5_MODE], [1], [this is Qt5 based build])
elif test "x$qt_ver" = "xQt6x" ; then
if test "x$qt_ver" = "xQt6x" ; then
AC_DEFINE([FC_QT6X_MODE], [1], [this is build based on current Qt6 version])
fi
doc/INSTALL.meson
gen-packets-args (array):
Additional packet generator arguments passed to common/generate_packets.py.
qtver ('qt5'/'qt6'/'qt6x'):
Whether to build Qt5, Qt6, or experimental Qt6 versions of the binaries.
qtver ('qt6'/'qt6x'):
Whether to build Qt6, or experimental Qt6 versions of the binaries.
project-definition (string):
Filename of the project definition to use. See below for contents of
doc/README.packaging
load options from old client files generated by former version of Freeciv
(e.g. ~/.freeciv/freeciv-client-rc-3.3 generated by Freeciv 3.3,
~/.freeciv-client-rc-3.2 generated by Freeciv 3.2).
* Qt5 support removed
----------------------------------------------------------------------
Compatibility of modified versions
gen_headers/meson_fc_config.h.in
/* Have Sqlite3 database backend */
#mesondefine HAVE_FCDB_SQLITE3
/* Build in Qt5 mode */
#mesondefine FC_QT5_MODE
/* Build in Qt6x mode */
#mesondefine FC_QT6X_MODE
m4/compiler.m4
# Sets variable cxx_works accordingly.
AC_DEFUN([FC_WORKING_CXX],
[
if test "x$qt_ver" = "xQt5" ; then
AX_CXX_COMPILE_STDCXX([11], [], [optional])
elif test "x$qt_ver" = "xQt6" || test "x$qt_ver" = "xQt6x" ; then
AX_CXX_COMPILE_STDCXX([17], [], [optional])
fi
AX_CXX_COMPILE_STDCXX([17], [], [optional])
AC_MSG_CHECKING([whether C++ compiler works])
......
AC_LANG_POP([C++])
if test "x$qt_ver" = "xQt5" && test "x$HAVE_CXX11" = "x" ; then
dnl Qt5 requires C++11.
AC_MSG_WARN([The C++ compiler doesn't support C++11])
cxx_works=no
elif test "x$qt_ver" = "xQt6" && test "x$HAVE_CXX17" = "x" ; then
if test "x$HAVE_CXX17" = "x" ; then
dnl Qt6 requires C++17.
AC_MSG_WARN([The C++ compiler doesn't support C++17])
cxx_works=no
m4/features.m4
FC_FEATURE([threads suitable for threaded ai], [$feature_thr_cond], [pthreads])
FC_FEATURE([lua linked from system], [$feature_syslua], [lua-5.4])
FC_FEATURE([tolua command from system], [$feature_systolua_cmd], [tolua])
FC_FEATURE([Ruleset Editor], [$feature_ruledit], [Qt6, or Qt5, development packages])
FC_FEATURE([Ruleset Editor], [$feature_ruledit], [Qt6 development packages])
if test "x$missing_list" = "x" ; then
AC_MSG_NOTICE([
m4/qt.m4
FC_QT_CXXFLAGS="$FC_QT6_CXXFLAGS"
FC_QT_LIBS="$FC_QT6_LIBS"
fc_qt_usable="$fc_qt6_usable" ;;
xqt5|xQt5) FC_QT5
FC_QT_CPPFLAGS="$FC_QT5_CPPFLAGS"
FC_QT_CXXFLAGS="$FC_QT5_CXXFLAGS"
FC_QT_LIBS="$FC_QT5_LIBS"
fc_qt_usable="$fc_qt5_usable" ;;
esac
])
m4/qt5-darwin.m4
# Detect Qt5 headers and libraries and set flag variables for Mac OS X 10.10+
AC_DEFUN([FC_QT5_DARWIN],
[
AC_ARG_WITH([qt5-framework],
AS_HELP_STRING([--with-qt5-framework], [path to root of Qt5 framework (MacOS, autodetected if wasn't specified)]),
[qt5_path="${withval}"])
AC_ARG_WITH([qt5-framework-bin],
AS_HELP_STRING([--with-qt5-framework-bin], [path to binares of Qt5 framework (MacOS X, autodetected if wasn't specified)]),
[qt5_framework_bin="${withval}"])
if test "x$qt5_framework_bin" = "x" ; then
AC_CHECK_PROG([QTPATHS], [qtpaths], [qtpaths], [no])
elif test -x "$qt5_framework_bin/qtpaths" ; then
QTPATHS="$qt5_framework_bin/qtpaths"
fi
if test "x$qt5_path" != "x" || test "x$QTPATHS" != "xno" ; then
AC_MSG_CHECKING([Qt5 framework])
if test "x$qt5_framework_bin" = "x" ; then
if test "x$QTPATHS" != "xno" ; then
qt5_framework_bin="$($QTPATHS --binaries-dir)"
fi
fi
if test "x$qt5_path" = "x" ; then
qt5_path="$($QTPATHS --install-prefix)"
fi
if test "x$qt5_path" != "x" ; then
AC_LANG_PUSH([C++])
FC_QT5_DARWIN_COMPILETEST([$qt5_path])
if test "x$qt5_headers" = "xyes" ; then
FC_QT5_DARWIN_LINKTEST([$qt5_path])
else
fc_qt5_usable=false
fi
AC_LANG_POP([C++])
if test "x$qt5_libs" = "xyes" ; then
if test "x$qt5_framework_bin" != "x" ; then
AS_IF([test "x$MOCCMD" = "x"], [MOCCMD="$qt5_framework_bin/moc"])
fi
AS_IF([test -x $MOCCMD], [fc_qt5_usable=true], [fc_qt5_usable=false])
else
fc_qt5_usable=false
fi
fi
if test "x$fc_qt5_usable" = "xtrue" ; then
AC_MSG_RESULT([found])
else
AC_MSG_RESULT([not found])
fi
fi
])
dnl Test if Qt5 headers are found from given path
AC_DEFUN([FC_QT5_DARWIN_COMPILETEST],
[
CPPFADD=" -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I$1/lib/QtWidgets.framework/Versions/5/Headers -I$1/lib/QtGui.framework/Versions/5/Headers -I$1/lib/QtCore.framework/Versions/5/Headers -I. -I$1/mkspecs/macx-clang -F$1/lib "
CPPFLAGS_SAVE="$CPPFLAGS"
CPPFLAGS="${CPPFLAGS}${CPPFADD}"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <QApplication>]],
[[int a; QApplication app(a, 0);]])],
[qt5_headers=yes
FC_QT5_CPPFLAGS="${FC_QT5_CPPFLAGS}${CPPFADD}"],
[CXXFLAGS_SAVE="${CXXFLAGS}"
CXXFLAGS="${CXXFLAGS} -fPIC"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <QApplication>]],
[[int a; QApplication app(a, 0);]])],
[qt5_headers=yes
FC_QT5_CPPFLAGS="${FC_QT5_CPPFLAGS}${CPPFADD}"
FC_QT5_CXXFLAGS="${FC_QT5_CXXFLAGS} -fPIC"])
CXXFLAGS="${CXXFLAGS_SAVE}"])
CPPFLAGS="$CPPFLAGS_SAVE"
])
dnl Test Qt application linking with current flags
AC_DEFUN([FC_QT5_DARWIN_LINKTEST],
[
LIBSADD=" -F$1/lib -framework QtWidgets -framework QtGui -framework QtCore -framework DiskArbitration -framework IOKit -framework OpenGL -framework AGL"
CPPFLAGS_SAVE="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $FC_QT5_CPPFLAGS"
CXXFLAGS_SAVE="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $FC_QT5_CXXFLAGS"
LIBS_SAVE="$LIBS"
LIBS="${LIBS}${LIBSADD}"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <QApplication>]],
[[int a; QApplication app(a, 0);]])],
[qt5_libs=yes
FC_QT5_LIBS="${FC_QT5_LIBS}${LIBSADD}"])
LIBS="$LIBS_SAVE"
CPPFLAGS="${CPPFLAGS_SAVE}"
CXXFLAGS="${CXXFLAGS_SAVE}"
])
m4/qt5.m4
# Detect Qt5 headers and libraries and set flag variables
AC_DEFUN([FC_QT5],
[
if test "x$fc_qt5_usable" = "x" ; then
FC_QT5_CPPFLAGS="-DQT_DISABLE_DEPRECATED_BEFORE=0x050f00"
case $host_os in
darwin*) FC_QT5_DARWIN;;
*) FC_QT5_GENERIC;;
esac
fi
])
AC_DEFUN([FC_QT5_GENERIC],
[
AC_LANG_PUSH([C++])
AC_MSG_CHECKING([Qt5 headers])
AC_ARG_WITH([qt5-includes],
AS_HELP_STRING([--with-qt5-includes], [path to Qt5 includes]),
[FC_QT5_COMPILETEST([$withval])],
[POTENTIAL_PATHS="/usr/include /usr/include/qt5 /usr/include/qt"
# search multiarch paths too (if the multiarch tuple can be found)
FC_MULTIARCH_TUPLE()
AS_IF(test "x$MULTIARCH_TUPLE" != "x",
POTENTIAL_PATHS="$POTENTIAL_PATHS /usr/include/$MULTIARCH_TUPLE/qt5")
dnl First test without any additional include paths to see if it works already
FC_QT5_COMPILETEST
for TEST_PATH in $POTENTIAL_PATHS
do
if test "x$qt5_headers" != "xyes" ; then
FC_QT5_COMPILETEST($TEST_PATH)
fi
done])
if test "x$qt5_headers" = "xyes" ; then
AC_MSG_RESULT([found])
AC_MSG_CHECKING([Qt5 libraries])
AC_ARG_WITH([qt5-libs],
AS_HELP_STRING([--with-qt5-libs], [path to Qt5 libraries]),
[FC_QT5_LINKTEST([$withval])],
[POTENTIAL_PATHS="/usr/lib/qt5 /usr/lib/qt"
# search multiarch paths too (if the multiarch tuple can be found)
FC_MULTIARCH_TUPLE()
AS_IF(test "x$MULTIARCH_TUPLE" != "x",
POTENTIAL_PATHS="$POTENTIAL_PATHS /usr/lib/$MULTIARCH_TUPLE/qt5")
dnl First test without any additional library paths to see if it works already
FC_QT5_LINKTEST
for TEST_PATH in $POTENTIAL_PATHS
do
if test "x$qt5_libs" != "xyes" ; then
FC_QT5_LINKTEST($TEST_PATH)
fi
done])
fi
if test "x$qt5_libs" = "xyes" ; then
AC_MSG_RESULT([found])
AC_MSG_CHECKING([for Qt5 >= 5.15])
FC_QT5_VERSION_CHECK
fi
AC_LANG_POP([C++])
if test "x$fc_qt5_min_ver" = "xyes" ; then
AC_MSG_RESULT([ok])
FC_QT5_VALIDATE_MOC([fc_qt5_usable=true], [fc_qt5_usable=false])
else
AC_MSG_RESULT([not found])
fc_qt5_usable=false
fi
])
dnl Test if Qt headers are found from given path
AC_DEFUN([FC_QT5_COMPILETEST],
[
if test "x$1" != "x" ; then
CPPFADD=" -I$1 -I$1/QtCore -I$1/QtGui -I$1/QtWidgets"
else
CPPFADD=""
fi
CPPFLAGS_SAVE="$CPPFLAGS"
CPPFLAGS="${CPPFLAGS}${CPPFADD}"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <QApplication>]],
[[int a; QApplication app(a, 0);]])],
[qt5_headers=yes
FC_QT5_CPPFLAGS="${FC_QT5_CPPFLAGS}${CPPFADD}"],
[CXXFLAGS_SAVE="${CXXFLAGS}"
CXXFLAGS="${CXXFLAGS} -fPIC"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <QApplication>]],
[[int a; QApplication app(a, 0);]])],
[qt5_headers=yes
FC_QT5_CPPFLAGS="${FC_QT5_CPPFLAGS}${CPPFADD}"
FC_QT5_CXXFLAGS="${FC_QT5_CXXFLAGS} -fPIC"
dnl So, Qt requires -fPIC. At the same time it might conflict with -fPIE
dnl Try to disable pie (but even if that fails, we have -fPIC)
dnl Only add -no-pie if it works also with -Werror
CXXFLAGS="${CXXFLAGS} -no-pie -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <QApplication>]],
[[int a; QApplication app(a, 0);]])],
[FC_QT5_CXXFLAGS="${FC_QT5_CXXFLAGS} -no-pie"])
])
CXXFLAGS="${CXXFLAGS_SAVE}"])
CPPFLAGS="$CPPFLAGS_SAVE"
])
dnl Check if the included version of Qt is at least Qt5.15
dnl Output: fc_qt5_min_ver=yes|no
AC_DEFUN([FC_QT5_VERSION_CHECK],
[
CPPFLAGS_SAVE="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $FC_QT5_CPPFLAGS"
CXXFLAGS_SAVE="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $FC_QT5_CXXFLAGS"
LIBS_SAVE="$LIBS"
LIBS="${LIBS}${LIBSADD}"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[#include <QtCore>]],[[
#if QT_VERSION < 0x050f00
fail
#endif
]])],
[fc_qt5_min_ver=yes],
[fc_qt5_min_ver=no])
LIBS="$LIBS_SAVE"
CPPFLAGS="${CPPFLAGS_SAVE}"
CXXFLAGS="${CXXFLAGS_SAVE}"
])
dnl Test Qt application linking with current flags
AC_DEFUN([FC_QT5_LINKTEST],
[
if test "x$1" != "x" ; then
LIBSADD=" -L$1 -lQt5Gui -lQt5Core -lQt5Widgets"
else
LIBSADD=" -lQt5Gui -lQt5Core -lQt5Widgets"
fi
CPPFLAGS_SAVE="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $FC_QT5_CPPFLAGS"
CXXFLAGS_SAVE="$CXXFLAGS"
CXXFLAGS="$CXXFLAGS $FC_QT5_CXXFLAGS"
LIBS_SAVE="$LIBS"
LIBS="${LIBS}${LIBSADD}"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <QApplication>]],
[[int a; QApplication app(a, 0);]])],
[qt5_libs=yes
FC_QT5_LIBS="${FC_QT5_LIBS}${LIBSADD}"])
LIBS="$LIBS_SAVE"
CPPFLAGS="${CPPFLAGS_SAVE}"
CXXFLAGS="${CXXFLAGS_SAVE}"
])
dnl If $1 is Qt 5's moc command then $2 else $3
AC_DEFUN([FC_QT5_IF_QT5_MOC],
AS_IF([$1 -v >/dev/null 2>/dev/null &&
(test "`$1 -v 2<&1 | grep -o 'Qt [[[0-9]]]\+'`" = "Qt 5" ||
test "`$1 -v 2<&1 | grep -o 'moc [[[0-9]]]\+'`" = "moc 5" ||
test "`$1 -v 2<&1 | grep -o 'moc-qt[[[0-9]]]\+'`" = "moc-qt5")],
[$2], [$3]))
dnl Set MOCCMD to $1 if it is the Qt 5 "moc". If not run $2 parameter.
AC_DEFUN([FC_QT5_TRY_MOC],
[FC_QT5_IF_QT5_MOC([$1], [MOCCMD="$1"], [$2])])
dnl If a usable moc command is found do $1 else do $2
AC_DEFUN([FC_QT5_VALIDATE_MOC], [
AC_MSG_CHECKING([the Qt 5 moc command])
dnl Try to find a Qt 5 'moc' if MOCCMD isn't set.
dnl Test that the supplied MOCCMD is a Qt 5 'moc' if it is set.
AS_IF([test "x$MOCCMD" = "x"],
[FC_QT5_TRY_MOC([moc],
[FC_QT5_TRY_MOC([qtchooser -run-tool=moc -qt=5],
[FC_QT5_TRY_MOC([moc-qt5],
[MOCCMD=""])])])],
[FC_QT5_TRY_MOC([$MOCCMD],
AC_MSG_ERROR(["MOCCMD set to a bad value ($MOCCMD)"]))])
dnl If no Qt 5 'moc' was found do $2, else do $1
AS_IF([test "x$MOCCMD" = "x"],
[AC_MSG_RESULT([not found]); $2],
[AC_MSG_RESULT([$MOCCMD]); $1])])
meson.build
endif
endif
if qtver == 'qt5'
qt_minver='0x050f00'
add_global_arguments('-DQT_DISABLE_DEPRECATED_BEFORE=' + qt_minver, language : 'cpp')
priv_conf_data.set('FC_QT5_MODE', 1)
qt_opts = []
qt_cppflags = '-fPIC'
elif qtver == 'qt6x'
if qtver == 'qt6x'
qt_minver='0x060700'
add_global_arguments('-DQT_DISABLE_DEPRECATED_BEFORE=' + qt_minver, language : 'cpp')
priv_conf_data.set('FC_QT6X_MODE', 1)
......
'freeciv/themes/gtk4/Freeciv/gtk-4.0'))
endif
if qtver == 'qt6' or qtver == 'qt6x'
qt_mod = import('qt6')
qt_dep = dependency('Qt6', modules: ['Core', 'Gui', 'Widgets'], required: false)
else
qt_mod = import('qt5')
qt_dep = dependency('Qt5', modules: ['Core', 'Gui', 'Widgets'], required: false)
endif
qt_mod = import('qt6')
qt_dep = dependency('Qt6', modules: ['Core', 'Gui', 'Widgets'], required: false)
if qt_dep.found() and cxx_build
if cxx_compiler.compiles(
......
if not qtfine
if qtver == 'qt6'
error('Qt6 >= 6.0 required for qt-client in Qt6 mode, but not found')
elif qtver == 'qt6x'
elser
error('Qt6 >= 6.7 required for qt-client in Qt6x mode, but not found')
else
error('Qt5 >= 5.15 required for qt-client in Qt5 mode, but not found')
endif
endif
......
if not qtfine
if qtver == 'qt6'
error('Qt6 >= 6.0 required for qt-modpack-installer in Qt6 mode, but not found')
elif qtver == 'qt6x'
error('Qt6 >= 6.7 required for qt-modpack-installer in Qt6x mode, but not found')
else
error('Qt5 >= 5.15 required for qt-modpack-installer in Qt5 mode, but not found')
error('Qt6 >= 6.7 required for qt-modpack-installer in Qt6x mode, but not found')
endif
endif
......
if not qtfine
if qtver == 'qt6'
error('Qt6 >= 6.0 required for ruledit in Qt6 mode, but not found')
elif qtver == 'qt6x'
error('Qt6 >= 6.7 required for ruledit in Qt6x mode, but not found')
else
error('Qt5 >= 5.15 required for ruledit in Qt5 mode, but not found')
error('Qt6 >= 6.7 required for ruledit in Qt6x mode, but not found')
endif
endif
meson_options.txt
option('qtver',
type: 'combo',
choices: ['qt5', 'qt6', 'qt6x'],
choices: ['qt6', 'qt6x'],
value: 'qt6',
description: 'Whether to build Qt5, Qt6, or experimental Qt6 versions of the binaries')
description: 'Whether to build Qt6, or experimental Qt6 versions of the binaries')
option('project-definition',
type: 'string',
    (1-1/1)