Skip to content

Commit

Permalink
Add client library version for Qt6
Browse files Browse the repository at this point in the history
  • Loading branch information
Gliese852 committed Sep 17, 2024
1 parent 3abc9fb commit 323855c
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 13 deletions.
33 changes: 32 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ if test x"$enable_liblightdm_qt5" != "xno"; then
fi
])

AC_CHECK_TOOLS(MOC5, [moc-qt5 moc])
QT5_VALIDATE_MOC(MOC5)
if test x$MOC5 = x; then
compile_liblightdm_qt5=no
if test "x$enable_liblightdm_qt5" != xauto; then
Expand All @@ -121,6 +121,35 @@ if test x"$enable_liblightdm_qt5" != "xno"; then
fi
AM_CONDITIONAL(COMPILE_LIBLIGHTDM_QT5, test x"$compile_liblightdm_qt5" != "xno")

AC_ARG_ENABLE(liblightdm-qt6,
AS_HELP_STRING([--enable-liblightdm-qt6],[Enable LightDM client Qt6 libraries [[default=auto]]]),
[enable_liblightdm_qt6=$enableval],
[enable_liblightdm_qt6="auto"])
compile_liblightdm_qt6=no
if test x"$enable_liblightdm_qt6" != "xno"; then
PKG_CHECK_MODULES(LIBLIGHTDM_QT6, [
Qt6Core
Qt6DBus
Qt6Gui
],
[compile_liblightdm_qt6=yes],
[if test "x$enable_liblightdm_qt6" != xauto; then
AC_MSG_FAILURE(
[--enable-liblightdm-qt6 was given, but test for Qt6 failed])
fi
])

QT6_VALIDATE_MOC(MOC6)
if test x$MOC6 = x; then
compile_liblightdm_qt6=no
if test "x$enable_liblightdm_qt6" != xauto; then
AC_MSG_FAILURE(
[--enable-liblightdm-qt6 was given, but MOC not found])
fi
fi
fi
AM_CONDITIONAL(COMPILE_LIBLIGHTDM_QT6, test x"$compile_liblightdm_qt6" != "xno")

AC_ARG_ENABLE([libaudit],
AS_HELP_STRING([--enable-libaudit],
[Enable libaudit logging of login and logout events [[default=auto]]]),
Expand Down Expand Up @@ -212,6 +241,7 @@ liblightdm-gobject/liblightdm-gobject-1.pc
liblightdm-gobject/Makefile
liblightdm-qt/Makefile
liblightdm-qt/liblightdm-qt5-3.pc
liblightdm-qt/liblightdm-qt6-3.pc
po/Makefile.in
src/Makefile
tests/Makefile
Expand All @@ -237,6 +267,7 @@ echo "
GObject introspection: $found_introspection
Vala bindings: $enable_vala
liblightdm-qt5: $compile_liblightdm_qt5
liblightdm-qt6: $compile_liblightdm_qt6
libaudit support: $use_libaudit
Enable tests: $enable_tests
"
23 changes: 23 additions & 0 deletions liblightdm-qt/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ common_libadd = \
liblightdm_qt5_3_la_LIBADD = \
$(LIBLIGHTDM_QT5_LIBS) \
$(common_libadd)
liblightdm_qt6_3_la_LIBADD = \
$(LIBLIGHTDM_QT6_LIBS) \
$(common_libadd)

common_cflags = \
$(WARN_CXXFLAGS) \
Expand All @@ -15,6 +18,11 @@ liblightdm_qt5_3_la_CXXFLAGS = \
-DQT_DISABLE_DEPRECATED_BEFORE="QT_VERSION_CHECK(4, 0, 0)" \
$(LIBLIGHTDM_QT5_CFLAGS) \
$(common_cflags)
liblightdm_qt6_3_la_CXXFLAGS = \
-fPIC \
-DQT_DISABLE_DEPRECATED_BEFORE="QT_VERSION_CHECK(5, 0, 0)" \
$(LIBLIGHTDM_QT6_CFLAGS) \
$(common_cflags)

common_headers = \
QLightDM/Greeter \
Expand All @@ -27,6 +35,7 @@ common_headers = \
QLightDM/usersmodel.h

liblightdm_qt5_3includedir=$(includedir)/lightdm-qt5-3/QLightDM
liblightdm_qt6_3includedir=$(includedir)/lightdm-qt6-3/QLightDM

common_sources = \
greeter.cpp \
Expand All @@ -36,6 +45,9 @@ common_sources = \
liblightdm_qt5_3_la_SOURCES = \
$(common_sources) \
$(liblightdm_qt5_3include_HEADERS)
liblightdm_qt6_3_la_SOURCES = \
$(common_sources) \
$(liblightdm_qt6_3include_HEADERS)

pkgconfigdir = $(libdir)/pkgconfig

Expand All @@ -56,9 +68,20 @@ BUILT_SOURCES += $(common_sources:.cpp=_moc5.cpp)
pkgconfig_DATA += liblightdm-qt5-3.pc
endif

if COMPILE_LIBLIGHTDM_QT6
lib_LTLIBRARIES += liblightdm-qt6-3.la
liblightdm_qt6_3include_HEADERS = $(common_headers)
BUILT_SOURCES += $(common_sources:.cpp=_moc6.cpp)
pkgconfig_DATA += liblightdm-qt6-3.pc
endif

# Support pretty printing MOC
AM_V_MOC5 = $(am__v_MOC5_$(V))
am__v_MOC5_ = $(am__v_MOC5_$(AM_DEFAULT_VERBOSITY))
am__v_MOC5_0 = @echo " MOC5 " $@;
%_moc5.cpp: QLightDM/%.h
$(AM_V_MOC5) $(MOC5) $< -o $@

# qt6
%_moc6.cpp: QLightDM/%.h
$(MOC6) $< -o $@
6 changes: 3 additions & 3 deletions liblightdm-qt/greeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ QString Greeter::motd() const
return QString::fromUtf8(lightdm_get_motd());
}

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include "greeter_moc5.cpp"
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include "greeter_moc6.cpp"
#else
#include "greeter_moc4.cpp"
#include "greeter_moc5.cpp"
#endif
11 changes: 11 additions & 0 deletions liblightdm-qt/liblightdm-qt6-3.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@

Name: liblightdm-qt6
Description: LightDM Qt6 client library
Version: @VERSION@
Requires: Qt6Core Qt6Gui Qt6DBus
Libs: -L${libdir} -llightdm-qt6-3
Cflags: -I${includedir}/lightdm-qt6-3
6 changes: 3 additions & 3 deletions liblightdm-qt/power.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ bool PowerInterface::restart()
return lightdm_restart (NULL);
}

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include "power_moc5.cpp"
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include "power_moc6.cpp"
#else
#include "power_moc4.cpp"
#include "power_moc5.cpp"
#endif
6 changes: 3 additions & 3 deletions liblightdm-qt/sessionsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ QVariant SessionsModel::data(const QModelIndex &index, int role) const
return QVariant();
}

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include "sessionsmodel_moc5.cpp"
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include "sessionsmodel_moc6.cpp"
#else
#include "sessionsmodel_moc4.cpp"
#include "sessionsmodel_moc5.cpp"
#endif
6 changes: 3 additions & 3 deletions liblightdm-qt/usersmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ QVariant UsersModel::data(const QModelIndex &index, int role) const
}


#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include "usersmodel_moc5.cpp"
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
#include "usersmodel_moc6.cpp"
#else
#include "usersmodel_moc4.cpp"
#include "usersmodel_moc5.cpp"
#endif
68 changes: 68 additions & 0 deletions m4/qt-validate-moc.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Detect Qt5 and Qt6 moc executable
# partially borrowed from freeciv qt m4 scripts

dnl Qt5
AC_DEFUN([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]))

dnl Set MOCCMD to $1 if it is the Qt 5 "moc".
AC_DEFUN([QT5_TRY_MOC],
[QT5_IF_QT5_MOC([$1], [MOCCMD="$1"])])

dnl If a usable moc command is found set $1
AC_DEFUN([QT5_VALIDATE_MOC], [
AC_MSG_CHECKING([the Qt 5 moc command])
dnl Try to find a Qt 5 'moc'
AS_IF([test "x$MOCCMD" = "x"],
[for mocpath in "moc" "qtchooser -run-tool=moc -qt=5" "moc-qt5"
do
if test "x$MOCCMD" = "x" ; then
QT5_TRY_MOC([$mocpath])
fi
done
AS_IF([test "x$MOCCMD" = "x"],
[AC_MSG_RESULT([not found]); AC_SUBST($1,"")],
[AC_MSG_RESULT([$MOCCMD]); AC_SUBST($1,"$MOCCMD")])
MOCCMD=""],
[AC_MSG_ERROR(["MOCCMD should not be set"])])])


dnl Qt6
AC_DEFUN([QT6_IF_QT6_MOC],
AS_IF([$1 -v >/dev/null 2>/dev/null &&
(test "`$1 -v 2<&1 | grep -o 'Qt [[[0-9]]]\+'`" = "Qt 6" ||
test "`$1 -v 2<&1 | grep -o 'moc [[[0-9]]]\+'`" = "moc 6" ||
test "`$1 -v 2<&1 | grep -o 'moc-qt[[[0-9]]]\+'`" = "moc-qt6")],
[$2]))

dnl Set MOCCMD to $1 if it is the Qt 6 "moc".
AC_DEFUN([QT6_TRY_MOC],
[QT6_IF_QT6_MOC([$1], [MOCCMD="$1"])])

dnl If a usable moc command is found set $1
AC_DEFUN([QT6_VALIDATE_MOC], [
AC_MSG_CHECKING([the Qt 6 moc command])
dnl Try to find a Qt 6 'moc'
AS_IF([test "x$MOCCMD" = "x"],
[for mocpath in "moc" "qtchooser -run-tool=moc -qt=6" "moc-qt6" \
"/usr/lib/qt6/moc" "/usr/lib/qt6/libexec/moc" \
"/usr/lib64/qt6/moc" "/usr/lib64/qt6/libexec/moc" \
"$prefix/lib/qt6/moc" "$prefix/lib/qt6/libexec/moc" \
"$libexecdir/moc" "$libexecdir/qt6/moc" \
"$libdir/qt6/moc" "$libdir/qt6/libexec/moc"
do
if test "x$MOCCMD" = "x" ; then
QT6_TRY_MOC([$mocpath])
fi
done
AS_IF([test "x$MOCCMD" = "x"],
[AC_MSG_RESULT([not found]); AC_SUBST($1,"")],
[AC_MSG_RESULT([$MOCCMD]); AC_SUBST($1,"$MOCCMD")])
MOCCMD=""],
[AC_MSG_ERROR(["MOCCMD should not be set"])])])

0 comments on commit 323855c

Please sign in to comment.