Skip to content

Commit 738fc4a

Browse files
committed
Merge #21363: build, qt: Improve Qt static plugins/libs check code
32b8dc6 build, refactor: Fix indentation (Hennadii Stepanov) 57b6522 build, qt: Make Qt static libs check regardless of plugindir (Hennadii Stepanov) 6203457 build, refactor: Rename internal _BITCOIN_QT_FIND_STATIC_PLUGINS macro (Hennadii Stepanov) bf24774 build, qt: Refactor internal _BITCOIN_QT_CHECK_STATIC_PLUGINS macro (Hennadii Stepanov) Pull request description: Qt version bump is around the corner (#21376). As a preparation, this PR makes Qt static plugins/libs check code more correct, and easier to reason about. `configure` script log (for `HOST=x86_64-pc-linux-gnu`): - master (b4d2265): ``` checking for static Qt plugins: -lqminimal... yes checking for static Qt plugins: -lqxcb -lxcb-static... yes ``` - this PR: ``` checking for QMinimalIntegrationPlugin (-lqminimal)... yes checking for QXcbIntegrationPlugin (-lqxcb -lxcb-static)... yes ``` ACKs for top commit: fanquake: ACK 32b8dc6 Tree-SHA512: a9ed8178cdbe3586898adc145b474355804ca00c5cee85dcdb8fb33a16575fc469298ef532c973d3aae53e1cb49569a9232595d609f232fae2bf05862fb34781
2 parents 6c156e4 + 32b8dc6 commit 738fc4a

File tree

1 file changed

+49
-45
lines changed

1 file changed

+49
-45
lines changed

build-aux/m4/bitcoin_qt.m4

Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,7 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
111111
dnl For Qt5, we can check a header to find out whether Qt is build
112112
dnl statically. When Qt is built statically, some plugins must be linked into
113113
dnl the final binary as well.
114-
dnl With Qt5, languages moved into core and the WindowsIntegration plugin was
115-
dnl added.
116-
dnl _BITCOIN_QT_CHECK_STATIC_PLUGINS does a quick link-check and appends the
114+
dnl _BITCOIN_QT_CHECK_STATIC_PLUGIN does a quick link-check and appends the
117115
dnl results to QT_LIBS.
118116
BITCOIN_QT_CHECK([
119117
TEMP_CPPFLAGS=$CPPFLAGS
@@ -122,20 +120,31 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[
122120
CXXFLAGS="$PIC_FLAGS $CXXFLAGS"
123121
_BITCOIN_QT_IS_STATIC
124122
if test "x$bitcoin_cv_static_qt" = xyes; then
125-
_BITCOIN_QT_FIND_STATIC_PLUGINS
123+
_BITCOIN_QT_CHECK_STATIC_LIBS
124+
125+
if test "x$qt_plugin_path" != x; then
126+
QT_LIBS="$QT_LIBS -L$qt_plugin_path/platforms"
127+
if test -d "$qt_plugin_path/accessible"; then
128+
QT_LIBS="$QT_LIBS -L$qt_plugin_path/accessible"
129+
fi
130+
if test -d "$qt_plugin_path/platforms/android"; then
131+
QT_LIBS="$QT_LIBS -L$qt_plugin_path/platforms/android -lqtfreetype -lEGL"
132+
fi
133+
fi
134+
126135
AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static])
127136
if test "x$TARGET_OS" != xandroid; then
128-
_BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QMinimalIntegrationPlugin)],[-lqminimal])
137+
_BITCOIN_QT_CHECK_STATIC_PLUGIN([QMinimalIntegrationPlugin], [-lqminimal])
129138
AC_DEFINE(QT_QPA_PLATFORM_MINIMAL, 1, [Define this symbol if the minimal qt platform exists])
130139
fi
131140
if test "x$TARGET_OS" = xwindows; then
132-
_BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)],[-lqwindows])
141+
_BITCOIN_QT_CHECK_STATIC_PLUGIN([QWindowsIntegrationPlugin], [-lqwindows])
133142
AC_DEFINE(QT_QPA_PLATFORM_WINDOWS, 1, [Define this symbol if the qt platform is windows])
134143
elif test "x$TARGET_OS" = xlinux; then
135-
_BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)],[-lqxcb -lxcb-static])
144+
_BITCOIN_QT_CHECK_STATIC_PLUGIN([QXcbIntegrationPlugin], [-lqxcb -lxcb-static])
136145
AC_DEFINE(QT_QPA_PLATFORM_XCB, 1, [Define this symbol if the qt platform is xcb])
137146
elif test "x$TARGET_OS" = xdarwin; then
138-
_BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin)],[-lqcocoa])
147+
_BITCOIN_QT_CHECK_STATIC_PLUGIN([QCocoaIntegrationPlugin], [-lqcocoa])
139148
AC_DEFINE(QT_QPA_PLATFORM_COCOA, 1, [Define this symbol if the qt platform is cocoa])
140149
elif test "x$TARGET_OS" = xandroid; then
141150
QT_LIBS="-Wl,--export-dynamic,--undefined=JNI_OnLoad -lqtforandroid -ljnigraphics -landroid -lqtfreetype -lQt5EglSupport $QT_LIBS"
@@ -284,51 +293,46 @@ AC_DEFUN([_BITCOIN_QT_IS_STATIC],[
284293
])
285294
])
286295

287-
dnl Internal. Check if the link-requirements for static plugins are met.
296+
dnl Internal. Check if the link-requirements for a static plugin are met.
297+
dnl
298+
dnl _BITCOIN_QT_CHECK_STATIC_PLUGIN(PLUGIN, LIBRARIES)
299+
dnl --------------------------------------------------
300+
dnl
288301
dnl Requires: INCLUDES and LIBS must be populated as necessary.
289-
dnl Inputs: $1: A series of Q_IMPORT_PLUGIN().
302+
dnl Inputs: $1: A static plugin name.
290303
dnl Inputs: $2: The libraries that resolve $1.
291304
dnl Output: QT_LIBS is prepended or configure exits.
292-
AC_DEFUN([_BITCOIN_QT_CHECK_STATIC_PLUGINS],[
293-
AC_MSG_CHECKING(for static Qt plugins: $2)
305+
AC_DEFUN([_BITCOIN_QT_CHECK_STATIC_PLUGIN], [
306+
AC_MSG_CHECKING([for $1 ($2)])
294307
CHECK_STATIC_PLUGINS_TEMP_LIBS="$LIBS"
295308
LIBS="$2${qt_lib_suffix} $QT_LIBS $LIBS"
296-
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
297-
#define QT_STATICPLUGIN
298-
#include <QtPlugin>
299-
$1]],
300-
[[return 0;]])],
301-
[AC_MSG_RESULT(yes); QT_LIBS="$2${qt_lib_suffix} $QT_LIBS"],
302-
[AC_MSG_RESULT(no); BITCOIN_QT_FAIL(Could not resolve: $2)])
309+
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <QtPlugin> Q_IMPORT_PLUGIN($1)]])],
310+
[AC_MSG_RESULT([yes]); QT_LIBS="$2${qt_lib_suffix} $QT_LIBS"],
311+
[AC_MSG_RESULT([no]); BITCOIN_QT_FAIL([$1 not found.])])
303312
LIBS="$CHECK_STATIC_PLUGINS_TEMP_LIBS"
304313
])
305314

306-
dnl Internal. Find paths necessary for linking qt static plugins
307-
dnl Inputs: qt_plugin_path. optional.
308-
dnl Outputs: QT_LIBS is appended
309-
AC_DEFUN([_BITCOIN_QT_FIND_STATIC_PLUGINS],[
310-
if test "x$qt_plugin_path" != x; then
311-
QT_LIBS="$QT_LIBS -L$qt_plugin_path/platforms"
312-
if test -d "$qt_plugin_path/accessible"; then
313-
QT_LIBS="$QT_LIBS -L$qt_plugin_path/accessible"
314-
fi
315-
if test -d "$qt_plugin_path/platforms/android"; then
316-
QT_LIBS="$QT_LIBS -L$qt_plugin_path/platforms/android -lqtfreetype -lEGL"
317-
fi
318-
PKG_CHECK_MODULES([QTFONTDATABASE], [Qt5FontDatabaseSupport${qt_lib_suffix}], [QT_LIBS="-lQt5FontDatabaseSupport${qt_lib_suffix} $QT_LIBS"])
319-
PKG_CHECK_MODULES([QTEVENTDISPATCHER], [Qt5EventDispatcherSupport${qt_lib_suffix}], [QT_LIBS="-lQt5EventDispatcherSupport${qt_lib_suffix} $QT_LIBS"])
320-
PKG_CHECK_MODULES([QTTHEME], [Qt5ThemeSupport${qt_lib_suffix}], [QT_LIBS="-lQt5ThemeSupport${qt_lib_suffix} $QT_LIBS"])
321-
PKG_CHECK_MODULES([QTDEVICEDISCOVERY], [Qt5DeviceDiscoverySupport${qt_lib_suffix}], [QT_LIBS="-lQt5DeviceDiscoverySupport${qt_lib_suffix} $QT_LIBS"])
322-
PKG_CHECK_MODULES([QTACCESSIBILITY], [Qt5AccessibilitySupport${qt_lib_suffix}], [QT_LIBS="-lQt5AccessibilitySupport${qt_lib_suffix} $QT_LIBS"])
323-
PKG_CHECK_MODULES([QTFB], [Qt5FbSupport${qt_lib_suffix}], [QT_LIBS="-lQt5FbSupport${qt_lib_suffix} $QT_LIBS"])
324-
if test "x$TARGET_OS" = xlinux; then
325-
PKG_CHECK_MODULES([QTXCBQPA], [Qt5XcbQpa], [QT_LIBS="$QTXCBQPA_LIBS $QT_LIBS"])
326-
elif test "x$TARGET_OS" = xdarwin; then
327-
PKG_CHECK_MODULES([QTCLIPBOARD], [Qt5ClipboardSupport${qt_lib_suffix}], [QT_LIBS="-lQt5ClipboardSupport${qt_lib_suffix} $QT_LIBS"])
328-
PKG_CHECK_MODULES([QTGRAPHICS], [Qt5GraphicsSupport${qt_lib_suffix}], [QT_LIBS="-lQt5GraphicsSupport${qt_lib_suffix} $QT_LIBS"])
329-
PKG_CHECK_MODULES([QTCGL], [Qt5CglSupport${qt_lib_suffix}], [QT_LIBS="-lQt5CglSupport${qt_lib_suffix} $QT_LIBS"])
330-
fi
331-
fi
315+
dnl Internal. Check Qt static libs with PKG_CHECK_MODULES.
316+
dnl
317+
dnl _BITCOIN_QT_CHECK_STATIC_LIBS
318+
dnl -----------------------------
319+
dnl
320+
dnl Inputs: no inputs.
321+
dnl Outputs: QT_LIBS is prepended.
322+
AC_DEFUN([_BITCOIN_QT_CHECK_STATIC_LIBS], [
323+
PKG_CHECK_MODULES([QTFONTDATABASE], [Qt5FontDatabaseSupport${qt_lib_suffix}], [QT_LIBS="-lQt5FontDatabaseSupport${qt_lib_suffix} $QT_LIBS"])
324+
PKG_CHECK_MODULES([QTEVENTDISPATCHER], [Qt5EventDispatcherSupport${qt_lib_suffix}], [QT_LIBS="-lQt5EventDispatcherSupport${qt_lib_suffix} $QT_LIBS"])
325+
PKG_CHECK_MODULES([QTTHEME], [Qt5ThemeSupport${qt_lib_suffix}], [QT_LIBS="-lQt5ThemeSupport${qt_lib_suffix} $QT_LIBS"])
326+
PKG_CHECK_MODULES([QTDEVICEDISCOVERY], [Qt5DeviceDiscoverySupport${qt_lib_suffix}], [QT_LIBS="-lQt5DeviceDiscoverySupport${qt_lib_suffix} $QT_LIBS"])
327+
PKG_CHECK_MODULES([QTACCESSIBILITY], [Qt5AccessibilitySupport${qt_lib_suffix}], [QT_LIBS="-lQt5AccessibilitySupport${qt_lib_suffix} $QT_LIBS"])
328+
PKG_CHECK_MODULES([QTFB], [Qt5FbSupport${qt_lib_suffix}], [QT_LIBS="-lQt5FbSupport${qt_lib_suffix} $QT_LIBS"])
329+
if test "x$TARGET_OS" = xlinux; then
330+
PKG_CHECK_MODULES([QTXCBQPA], [Qt5XcbQpa], [QT_LIBS="$QTXCBQPA_LIBS $QT_LIBS"])
331+
elif test "x$TARGET_OS" = xdarwin; then
332+
PKG_CHECK_MODULES([QTCLIPBOARD], [Qt5ClipboardSupport${qt_lib_suffix}], [QT_LIBS="-lQt5ClipboardSupport${qt_lib_suffix} $QT_LIBS"])
333+
PKG_CHECK_MODULES([QTGRAPHICS], [Qt5GraphicsSupport${qt_lib_suffix}], [QT_LIBS="-lQt5GraphicsSupport${qt_lib_suffix} $QT_LIBS"])
334+
PKG_CHECK_MODULES([QTCGL], [Qt5CglSupport${qt_lib_suffix}], [QT_LIBS="-lQt5CglSupport${qt_lib_suffix} $QT_LIBS"])
335+
fi
332336
])
333337

334338
dnl Internal. Find Qt libraries using pkg-config.

0 commit comments

Comments
 (0)