Skip to content

Commit 35c46bc

Browse files
committed
Check QT library version
Fixes issue #15688 Due to a bug, in systems using pkg-config, the version of the Qt library is not checked at configure time. Without any check, when Qt version is not supported, the build process stops with unexpleined errors. This PR introduces the control of the version of the QT library, returning a warning or an error at configure time, when the installed version is not supported.
1 parent 28fbe68 commit 35c46bc

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

build-aux/m4/bitcoin_qt.m4

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ AC_DEFUN([BITCOIN_QT_INIT],[
8181

8282
dnl Find the appropriate version of Qt libraries and includes.
8383
dnl Inputs: $1: Whether or not pkg-config should be used. yes|no. Default: yes.
84-
dnl Inputs: $2: If $1 is "yes" and --with-gui=auto, which qt version should be
85-
dnl tried first.
8684
dnl Outputs: See _BITCOIN_QT_FIND_LIBS_*
8785
dnl Outputs: Sets variables for all qt-related tools.
8886
dnl Outputs: bitcoin_enable_qt, bitcoin_enable_qt_dbus, bitcoin_enable_qt_test
@@ -99,6 +97,12 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
9997
BITCOIN_QT_CHECK([_BITCOIN_QT_FIND_LIBS_WITHOUT_PKGCONFIG])
10098
fi
10199
100+
BITCOIN_QT_CHECK([
101+
if test "x$bitcoin_cv_qt_minimumrequired" != xyes; then
102+
BITCOIN_QT_FAIL([Qt version not supported])
103+
fi
104+
])
105+
102106
dnl This is ugly and complicated. Yuck. Works as follows:
103107
dnl For Qt5, we can check a header to find out whether Qt is build
104108
dnl statically. When Qt is built statically, some plugins must be linked into
@@ -211,7 +215,6 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
211215
])
212216
esac
213217
214-
215218
dnl enable qt support
216219
AC_MSG_CHECKING(whether to build ]AC_PACKAGE_NAME[ GUI)
217220
BITCOIN_QT_CHECK([
@@ -257,9 +260,9 @@ dnl ----
257260
258261
dnl Internal. Check included version of Qt against minimum specified in doc/dependencies.md
259262
dnl Requires: INCLUDES must be populated as necessary.
260-
dnl Output: bitcoin_cv_qt5=yes|no
261-
AC_DEFUN([_BITCOIN_QT_CHECK_QT5],[
262-
AC_CACHE_CHECK(for Qt 5, bitcoin_cv_qt5,[
263+
dnl Output: bitcoin_cv_qt_minimumrequired=yes|no
264+
AC_DEFUN([_BITCOIN_QT_CHECK_MINIMUM_REQUIRED],[
265+
AC_CACHE_CHECK(for Qt >= 5.5.1, bitcoin_cv_qt_minimumrequired,[
263266
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
264267
#include <QtCore/qconfig.h>
265268
#ifndef QT_VERSION
@@ -271,15 +274,15 @@ AC_DEFUN([_BITCOIN_QT_CHECK_QT5],[
271274
choke
272275
#endif
273276
]])],
274-
[bitcoin_cv_qt5=yes],
275-
[bitcoin_cv_qt5=no])
277+
[bitcoin_cv_qt_minimumrequired=yes],
278+
[bitcoin_cv_qt_minimumrequired=no])
276279
])])
277280
278-
dnl Internal. Check if the included version of Qt is greater than Qt58.
281+
dnl Internal. Check if the included version of Qt is >= 5.8.
279282
dnl Requires: INCLUDES must be populated as necessary.
280283
dnl Output: bitcoin_cv_qt58=yes|no
281284
AC_DEFUN([_BITCOIN_QT_CHECK_QT58],[
282-
AC_CACHE_CHECK(for > Qt 5.7, bitcoin_cv_qt58,[
285+
AC_CACHE_CHECK(for >= Qt 5.8, bitcoin_cv_qt58,[
283286
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
284287
#include <QtCore/qconfig.h>
285288
#ifndef QT_VERSION
@@ -410,10 +413,6 @@ AC_DEFUN([_BITCOIN_QT_FIND_STATIC_PLUGINS],[
410413
])
411414
412415
dnl Internal. Find Qt libraries using pkg-config.
413-
dnl Inputs: bitcoin_qt_want_version (from --with-gui=). The version to check
414-
dnl first.
415-
dnl Inputs: $1: If bitcoin_qt_want_version is "auto", check for this version
416-
dnl first.
417416
dnl Outputs: All necessary QT_* variables are set.
418417
dnl Outputs: have_qt_test and have_qt_dbus are set (if applicable) to yes|no.
419418
AC_DEFUN([_BITCOIN_QT_FIND_LIBS_WITH_PKGCONFIG],[
@@ -434,14 +433,25 @@ AC_DEFUN([_BITCOIN_QT_FIND_LIBS_WITH_PKGCONFIG],[
434433
PKG_CHECK_MODULES([QT_DBUS], [${QT_LIB_PREFIX}DBus], [QT_DBUS_INCLUDES="$QT_DBUS_CFLAGS"; have_qt_dbus=yes], [have_qt_dbus=no])
435434
fi
436435
])
436+
BITCOIN_QT_CHECK([
437+
AC_CACHE_CHECK(for Qt >= 5.5.1,bitcoin_cv_qt_minimumrequired,
438+
PKG_CHECK_EXISTS(Qt5Core < 5.5.1,[bitcoin_cv_qt_minimumrequired=no],[bitcoin_cv_qt_minimumrequired=yes])
439+
)
440+
])
441+
BITCOIN_QT_CHECK([
442+
AC_CACHE_CHECK(for Qt >= 5.8.0,bitcoin_cv_qt58,
443+
PKG_CHECK_EXISTS(Qt5Core < 5.8.0,[bitcoin_cv_qt58=no],[bitcoin_cv_qt58=yes])
444+
)
445+
])
437446
])
438447
true; dnl
439448
])
440449
441450
dnl Internal. Find Qt libraries without using pkg-config. Version is deduced
442451
dnl from the discovered headers.
443452
dnl Inputs: bitcoin_qt_want_version (from --with-gui=). The version to use.
444-
dnl If "auto", the version will be discovered by _BITCOIN_QT_CHECK_QT5.
453+
dnl If "auto", the version will be discovered by _BITCOIN_QT_CHECK_MINIMUM_REQUIRED
454+
dnl and _BITCOIN_QT_CHECK_QT58.
445455
dnl Outputs: All necessary QT_* variables are set.
446456
dnl Outputs: have_qt_test and have_qt_dbus are set (if applicable) to yes|no.
447457
AC_DEFUN([_BITCOIN_QT_FIND_LIBS_WITHOUT_PKGCONFIG],[
@@ -462,7 +472,7 @@ AC_DEFUN([_BITCOIN_QT_FIND_LIBS_WITHOUT_PKGCONFIG],[
462472
463473
BITCOIN_QT_CHECK([
464474
if test "x$bitcoin_qt_want_version" = xauto; then
465-
_BITCOIN_QT_CHECK_QT5
475+
_BITCOIN_QT_CHECK_MINIMUM_REQUIRED
466476
_BITCOIN_QT_CHECK_QT58
467477
fi
468478
QT_LIB_PREFIX=Qt5

0 commit comments

Comments
 (0)