[v6,4/6] package/pkg-qmake: support Qt6

Message ID 20260925064257.1162394-5-dario.binacchi@amarulasolutions.com
State New
Headers show
Series
  • Support qmake for Qt6
Related show

Commit Message

Dario Binacchi Sept. 25, 2026, 6:42 a.m. UTC
The qmake infrastructure hardcodes qt5base as the Qt provider. Select
the Qt major version from BR2_PACKAGE_QT5, which is mutually exclusive
with BR2_PACKAGE_QT6, and use it to pick the qt<N>base dependency, the
QT<N>_QMAKE command and the QT<N>_QT_CONF_FIXUP hook.

The header sync hook now takes the version from QT<N>_VERSION_MAJOR and
QT<N>_VERSION instead of hardcoding 5.15.

Document in the manual which Qt base package is added to the dependencies.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---

Changes v4 -> v5:
  - Drop the hardcoded Qt versions, only select the major version from
    BR2_PACKAGE_QT5
  - Take the version for the header sync hook from QT<N>_VERSION_MAJOR
    and QT<N>_VERSION
  - Document in the manual which Qt base package is added to the
    dependencies
  - Update the commit message

 docs/manual/adding-packages-qmake.adoc |  4 ++++
 package/pkg-qmake.mk                   | 18 +++++++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

Patch

diff --git a/docs/manual/adding-packages-qmake.adoc b/docs/manual/adding-packages-qmake.adoc
index e09da166b909..1d97556abe79 100644
--- a/docs/manual/adding-packages-qmake.adoc
+++ b/docs/manual/adding-packages-qmake.adoc
@@ -55,6 +55,10 @@  All the package metadata information variables that exist in the
 xref:generic-package-reference[generic package infrastructure] also
 exist in the QMake infrastructure.
 
+The Qt base package the package is built against, +qt5base+ or
++qt6base+, is automatically added to its dependencies, depending on
+whether +BR2_PACKAGE_QT5+ or +BR2_PACKAGE_QT6+ is enabled.
+
 A few additional variables, specific to the QMake infrastructure, can
 also be defined.
 
diff --git a/package/pkg-qmake.mk b/package/pkg-qmake.mk
index ccf78692e885..7f73c3087b5f 100644
--- a/package/pkg-qmake.mk
+++ b/package/pkg-qmake.mk
@@ -20,11 +20,19 @@ 
 #
 ################################################################################
 
+# Qt5 and Qt6 are mutually exclusive
+ifeq ($(BR2_PACKAGE_QT5),y)
+QT_VERSION_MAJOR = 5
+else
+QT_VERSION_MAJOR = 6
+endif
+QT_BASE = qt$(QT_VERSION_MAJOR)base
+
 #
 # Hook to sync Qt headers
 #
 define QT_HEADERS_SYNC_HOOK
-	sed -e '/^MODULE_VERSION/s/5\.15\.[3456789]/$(QT5_VERSION)/' -i \
+	sed -e '/^MODULE_VERSION/s/$(subst .,\.,$(QT$(QT_VERSION_MAJOR)_VERSION_MAJOR))\.[0-9]*/$(QT$(QT_VERSION_MAJOR)_VERSION)/' -i \
 		$($(PKG)_BUILDDIR)/.qmake.conf
 	touch $($(PKG)_BUILDDIR)/.git
 endef
@@ -45,15 +53,15 @@  define inner-qmake-package
 $(2)_INSTALL_STAGING_OPTS	?= install
 $(2)_INSTALL_TARGET_OPTS	?= $$($(2)_INSTALL_STAGING_OPTS)
 
-ifneq ($(1),qt5base)
-$(2)_DEPENDENCIES 		+= qt5base
+ifneq ($(1),$(QT_BASE))
+$(2)_DEPENDENCIES 		+= $(QT_BASE)
 endif
 
 ifeq ($$($(2)_SYNC_QT_HEADERS),YES)
 $(2)_PRE_CONFIGURE_HOOKS        += QT_HEADERS_SYNC_HOOK
 endif
 
-$(2)_POST_PREPARE_HOOKS += QT5_QT_CONF_FIXUP
+$(2)_POST_PREPARE_HOOKS += QT$(QT_VERSION_MAJOR)_QT_CONF_FIXUP
 
 #
 # Configure step. Only define it if not already defined by the package
@@ -62,7 +70,7 @@  $(2)_POST_PREPARE_HOOKS += QT5_QT_CONF_FIXUP
 ifndef $(2)_CONFIGURE_CMDS
 define $(2)_CONFIGURE_CMDS
 	cd $$($(2)_BUILDDIR) && \
-	$$(TARGET_MAKE_ENV) $$($(2)_CONF_ENV) $$(QT5_QMAKE) $$($(2)_CONF_OPTS)
+	$$(TARGET_MAKE_ENV) $$($(2)_CONF_ENV) $$(QT$(QT_VERSION_MAJOR)_QMAKE) $$($(2)_CONF_OPTS)
 endef
 endif