build,qt: Allow building Qt 5 bindings and Qt 6 bindings

* configure.ac: Remove "qt" from default_languages. Add "qt5 qt6" to
default_languages. Remove "qt" from help for --enable-languages. Don't
fail anymore if "qt5" and "qt6" are enabled. Warn that "qt" is
deprecated if it was enabled.
* lang/qt/src/Makefile.am (libqgpgme_la, libqgpgmeqt6_la): New.
(lib_LTLIBRARIES): Set Qt 5 and/or Qt 6 variant of libqgpgme.
(AM_CPPFLAGS): Replace with libqgpgme_la_CPPFLAGS for Qt 5 and
libqgpgmeqt6_la_CPPFLAGS for Qt 6.
--

This makes it possible to build QGpgME simultaneously for Qt 5 and Qt 6.
By default, QGpgME is now built for all versions of Qt that are found.
Specifying "qt" as language is deprecated.

GnuPG-bug-id: 7205
This commit is contained in:
Ingo Klöcker 2024-07-18 11:43:24 +02:00
parent e6830b58b6
commit 42e151b34b
No known key found for this signature in database
GPG Key ID: F5A5D1692277A1E9
3 changed files with 70 additions and 47 deletions

2
NEWS
View File

@ -17,6 +17,8 @@ Noteworthy changes in version 1.24.0 (unrelease)
* cpp: Add safer member function returning text describing an error. * cpp: Add safer member function returning text describing an error.
[T5960] [T5960]
* qt: Build QGpgME for Qt 5 and Qt 6 simultaneously. [T7205]
* qt: Install headers for Qt 5 and Qt 6 in separate folders. [T7161] * qt: Install headers for Qt 5 and Qt 6 in separate folders. [T7161]
* qt: Allow reading the data to decrypt/encrypt/sign/verify directly from * qt: Allow reading the data to decrypt/encrypt/sign/verify directly from

View File

@ -257,7 +257,7 @@ have_macos_system=no
build_w32_glib=no build_w32_glib=no
build_w32_qt=no build_w32_qt=no
available_languages="cl cpp python qt qt5 qt6" available_languages="cl cpp python qt qt5 qt6"
default_languages="cl cpp python qt" default_languages="cl cpp python qt5 qt6"
case "${host}" in case "${host}" in
x86_64-*mingw32*) x86_64-*mingw32*)
have_w64_system=yes have_w64_system=yes
@ -375,8 +375,7 @@ AC_ARG_ENABLE([no-direct-extern-access],
AC_ARG_ENABLE([languages], AC_ARG_ENABLE([languages],
AS_HELP_STRING([--enable-languages=languages], AS_HELP_STRING([--enable-languages=languages],
[enable only specific language bindings: [enable only specific language bindings:
cl cpp python qt qt5 qt6 (qt selects qt5 or qt6, cl cpp python qt5 qt6]),
and qt5 and qt6 exclude each other)]),
[enabled_languages=`echo $enableval | \ [enabled_languages=`echo $enableval | \
tr ',:' ' ' | tr '[A-Z]' '[a-z]' | \ tr ',:' ' ' | tr '[A-Z]' '[a-z]' | \
sed 's/c++/cpp/'`], sed 's/c++/cpp/'`],
@ -402,76 +401,95 @@ for language in $enabled_languages; do
fi fi
done done
# Check whether Qt5 and/or Qt6 are enabled explicitly # Check whether qt5 and/or qt6 are enabled
want_qt5="no"; want_qt5="no"
LIST_MEMBER("qt5", $enabled_languages) LIST_MEMBER("qt5", $enabled_languages)
if test "$found" = "1"; then if test "$found" = "1"; then
want_qt5="yes"; if test "$explicit_languages" = "1"; then
want_qt5="yes"
else
want_qt5="maybe"
fi
# Remove qt5; further down qt will be added # Remove qt5; further down qt will be added
enabled_languages=$(echo $enabled_languages | sed 's/qt5//') enabled_languages=$(echo $enabled_languages | sed 's/qt5//')
fi fi
want_qt6="no"; want_qt6="no"
LIST_MEMBER("qt6", $enabled_languages) LIST_MEMBER("qt6", $enabled_languages)
if test "$found" = "1"; then if test "$found" = "1"; then
want_qt6="yes"; if test "$explicit_languages" = "1"; then
want_qt6="yes"
else
want_qt6="maybe"
fi
# Remove qt6; further down qt will be added # Remove qt6; further down qt will be added
enabled_languages=$(echo $enabled_languages | sed 's/qt6//') enabled_languages=$(echo $enabled_languages | sed 's/qt6//')
fi fi
if test "$want_qt5" = "yes" -a "$want_qt6" = "yes"; then
AC_MSG_ERROR([[ # Check whether qt is enabled; if yes then it has been enabled explicitly
want_qt="no"
LIST_MEMBER("qt", $enabled_languages)
if test "$found" = "1"; then
# Ignore qt if specified together with qt5 or qt6
if test "$want_qt5" = "no" -a "$want_qt6" = "no"; then
want_qt="yes"
fi
# Remove qt
enabled_languages=$(echo $enabled_languages | sed 's/qt//')
AC_MSG_WARN([[
*** ***
*** The bindings for Qt5 and Qt6 cannot be built simultaneously. *** Language binding "qt" is deprecated and will be removed in a future version.
*** Use "qt5" and/or "qt6" instead.
***]]) ***]])
fi fi
# Ensure that pkg-config is available for all calls of FIND_QT5/FIND_QT6 # Ensure that pkg-config is available for all calls of FIND_QT5/FIND_QT6
PKG_PROG_PKG_CONFIG PKG_PROG_PKG_CONFIG
# If the generic qt is enabled, then check for Qt5 or Qt6 (in this order) # Check for Qt 5 (if qt5 or qt is enabled)
LIST_MEMBER("qt", $enabled_languages) if test "$want_qt" = "yes"; then
if test "$found" = "1"; then want_qt5="maybe"
# Remove the generic qt (qt5 and qt6 have already been removed) fi
enabled_languages=$(echo $enabled_languages | sed 's/qt//') if test "$want_qt5" != "no"; then
FIND_QT5 FIND_QT5
if test "$have_qt5_libs" = "yes"; then if test "$have_qt5_libs" = "yes"; then
want_qt5="yes"; want_qt5="yes"
else elif test "$want_qt5" = "yes"; then
FIND_QT6
if test "$have_qt6_libs" = "yes"; then
want_qt6="yes";
else
if test "$explicit_languages" = "1"; then
AC_MSG_ERROR([[
***
*** Qt5 (Qt5Core) or Qt6 (Qt6Core) is required for the Qt binding.
***]])
else
AC_MSG_WARN([[
***
*** Qt5 (Qt5Core) and Qt6 (Qt6Core) not found. Qt Binding will be disabled.
***]])
fi
fi
fi
elif test "$want_qt5" = "yes"; then
FIND_QT5
if test "$have_qt5_libs" != "yes"; then
AC_MSG_ERROR([[ AC_MSG_ERROR([[
*** ***
*** Qt5 (Qt5Core) is required for the Qt 5 binding. *** Qt5 (Qt5Core) is required for the Qt 5 binding.
***]]) ***]])
else
want_qt5="no"
fi fi
elif test "$want_qt6" = "yes"; then fi
# Check for Qt 6 (if qt6 is enabled or if qt is enabled and Qt 5 wasn't found)
if test "$want_qt" = "yes" -a "$have_qt5_libs" != "yes"; then
want_qt6="maybe"
fi
if test "$want_qt6" != "no"; then
FIND_QT6 FIND_QT6
if test "$have_qt6_libs" != "yes"; then if test "$have_qt6_libs" = "yes"; then
want_qt6="yes";
elif test "$want_qt6" = "yes"; then
AC_MSG_ERROR([[ AC_MSG_ERROR([[
*** ***
*** Qt6 (Qt6Core) is required for the Qt 6 binding. *** Qt6 (Qt6Core) is required for the Qt 6 binding.
***]]) ***]])
else
want_qt6="no"
fi fi
fi fi
# Check that cpp is enabled if qt5 or qt6 is enabled # Check if any Qt was found (if qt is enabled)
if test "$want_qt" = "yes" -a "$have_qt5_libs" != "yes" -a "$have_qt6_libs" != "yes"; then
AC_MSG_ERROR([[
***
*** Qt5 (Qt5Core) or Qt6 (Qt6Core) is required for the Qt bindings.
***]])
fi
# Check that cpp is enabled if qt5 or qt6 is enabled and was found
if test "$want_qt5" = "yes" -o "$want_qt6" = "yes"; then if test "$want_qt5" = "yes" -o "$want_qt6" = "yes"; then
LIST_MEMBER("cpp", $enabled_languages) LIST_MEMBER("cpp", $enabled_languages)
if test "$found" = "0"; then if test "$found" = "0"; then
@ -522,7 +540,7 @@ if test "$found" = "1" -a "$HAVE_CXX17" != "1"; then
fi fi
fi fi
# Now append qt to the list of language bindings # Now append qt to the list of language bindings (to enable the subdir in lang)
if test "$want_qt5" = "yes" -o "$want_qt6" = "yes"; then if test "$want_qt5" = "yes" -o "$want_qt6" = "yes"; then
enabled_languages=$(echo $enabled_languages qt) enabled_languages=$(echo $enabled_languages qt)
fi fi
@ -1145,7 +1163,9 @@ AC_CONFIG_FILES([lang/python/Makefile
AC_CONFIG_FILES([lang/python/setup.py], [chmod a+x lang/python/setup.py]) AC_CONFIG_FILES([lang/python/setup.py], [chmod a+x lang/python/setup.py])
AC_OUTPUT AC_OUTPUT
if test "$want_qt5" = "yes"; then if test "$want_qt5" = "yes" -a "$want_qt6" = "yes"; then
enabled_languages_v=$(echo ${enabled_languages_v:-$enabled_languages} | sed "s/qt/qt (Qt 5, Qt 6)/")
elif test "$want_qt5" = "yes"; then
enabled_languages_v=$(echo ${enabled_languages_v:-$enabled_languages} | sed "s/qt/qt (Qt 5)/") enabled_languages_v=$(echo ${enabled_languages_v:-$enabled_languages} | sed "s/qt/qt (Qt 5)/")
elif test "$want_qt6" = "yes"; then elif test "$want_qt6" = "yes"; then
enabled_languages_v=$(echo ${enabled_languages_v:-$enabled_languages} | sed "s/qt/qt (Qt 6)/") enabled_languages_v=$(echo ${enabled_languages_v:-$enabled_languages} | sed "s/qt/qt (Qt 6)/")

View File

@ -20,11 +20,12 @@
# 02111-1307, USA # 02111-1307, USA
if WANT_QT5 if WANT_QT5
lib_LTLIBRARIES = libqgpgme.la libqgpgme_la = libqgpgme.la
endif endif
if WANT_QT6 if WANT_QT6
lib_LTLIBRARIES = libqgpgmeqt6.la libqgpgmeqt6_la = libqgpgmeqt6.la
endif endif
lib_LTLIBRARIES = $(libqgpgme_la) $(libqgpgmeqt6_la)
EXTRA_DIST = QGpgmeConfig.cmake.in.in QGpgmeConfigVersion.cmake.in \ EXTRA_DIST = QGpgmeConfig.cmake.in.in QGpgmeConfigVersion.cmake.in \
qgpgme_debug.h qgpgme_version.h.in \ qgpgme_debug.h qgpgme_version.h.in \
@ -373,7 +374,7 @@ $(qgpgme_moc6_forward_headers): Makefile.am | $(moc6_dir)
endif endif
if WANT_QT5 if WANT_QT5
AM_CPPFLAGS = -I./$(moc5_dir) -I$(top_builddir)/lang/cpp/src -I$(top_builddir)/src \ libqgpgme_la_CPPFLAGS = -I./moc5 -I$(top_builddir)/lang/cpp/src -I$(top_builddir)/src \
@GPGME_QT5_CFLAGS@ @GPG_ERROR_CFLAGS@ @LIBASSUAN_CFLAGS@ \ @GPGME_QT5_CFLAGS@ @GPG_ERROR_CFLAGS@ @LIBASSUAN_CFLAGS@ \
-DBUILDING_QGPGME -Wsuggest-override \ -DBUILDING_QGPGME -Wsuggest-override \
-Wzero-as-null-pointer-constant -Wzero-as-null-pointer-constant
@ -388,7 +389,7 @@ libqgpgme_la_LDFLAGS = -no-undefined -version-info \
@LIBQGPGME_LT_CURRENT@:@LIBQGPGME_LT_REVISION@:@LIBQGPGME_LT_AGE@ @LIBQGPGME_LT_CURRENT@:@LIBQGPGME_LT_REVISION@:@LIBQGPGME_LT_AGE@
endif endif
if WANT_QT6 if WANT_QT6
AM_CPPFLAGS = -I./$(moc6_dir) -I$(top_builddir)/lang/cpp/src -I$(top_builddir)/src \ libqgpgmeqt6_la_CPPFLAGS = -I./moc6 -I$(top_builddir)/lang/cpp/src -I$(top_builddir)/src \
@GPGME_QT6_CFLAGS@ @GPG_ERROR_CFLAGS@ @LIBASSUAN_CFLAGS@ \ @GPGME_QT6_CFLAGS@ @GPG_ERROR_CFLAGS@ @LIBASSUAN_CFLAGS@ \
-DBUILDING_QGPGME -Wsuggest-override \ -DBUILDING_QGPGME -Wsuggest-override \
-Wzero-as-null-pointer-constant -Wzero-as-null-pointer-constant