Skip to contentSkip to conversation

package/qt6: Add qmake functionality

PATCH In review Jesse Van Gavere 2 participants 2 messages Nov 3, 2022 – Feb 6, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/qt6: Add qmake functionality

The qmake functionality had been missing due to the new host/target build requirement, to get it working the main parts of the qt5 qmake has been kept, we're still making our own device spec which we use to run qmake with along with passing some additional device options for our flags/cross-compiler the biggest difference is that where previously qt.conf was used to fixup per-paths builds, this is now always created with changed contents so qmake looks at the correct target directories.

A big thanks to Angelo Compagnucci for the encouragement and testing.

---
 package/qt6/qt6.mk                  | 12 ++++++++++
 package/qt6/qt6base/qmake.conf.in   | 36 +++++++++++++++++++++++++++++
 package/qt6/qt6base/qplatformdefs.h |  1 +
 package/qt6/qt6base/qt.conf.in      |  7 ++++++
 package/qt6/qt6base/qt6base.mk      | 18 +++++++++++++++
 5 files changed, 74 insertions(+)
 create mode 100644 package/qt6/qt6base/qmake.conf.in
 create mode 100644 package/qt6/qt6base/qplatformdefs.h
 create mode 100644 package/qt6/qt6base/qt.conf.in
package/qt6/qt6.mk +12 -0
index 575b2f826c..bd8fb0ab51 100644
@@ -10,3 +10,15 @@ QT6_SOURCE_TARBALL_PREFIX = everywhere-src
 QT6_SITE = https://download.qt.io/archive/qt/$(QT6_VERSION_MAJOR)/$(QT6_VERSION)/submodules
 
 include $(sort $(wildcard package/qt6/*/*.mk))
+
+# The file "qt.conf" can be used to override the hard-coded paths that are
+# compiled into the Qt library. We need it to make "qmake" relocatable due
+# to the host/target build and tweak the per-package install pathes
+define QT6_INSTALL_QT_CONF
+	rm -f $(HOST_DIR)/bin/qt.conf
+	sed -e "s|@@HOST_DIR@@|$(HOST_DIR)|" -e "s|@@STAGING_DIR@@|$(STAGING_DIR)|" \
+		$(QT6BASE_PKGDIR)/qt.conf.in > $(HOST_DIR)/bin/qt.conf
+endef
+
+# Variable for other Qt applications to use
+QT6_QMAKE = $(HOST_DIR)/bin/qmake -spec devices/linux-buildroot-g++
package/qt6/qt6base/qmake.conf.in new file +36 -0
new file mode 100644
index 0000000000..ebb8497d2d
@@ -0,0 +1,36 @@
+# Qt6 has a mechanism to support "device" profiles, so that people can
+# specify the compiler, compiler flags and so on for a specific device.
+
+# We leverage this mechanism in the Buildroot packaging of qt6 to
+# simplify cross-compilation: we have our own "device" definition, which
+# allows us to easily pass the cross-compiler paths and flags from our
+# qt6.mk.
+
+include(../common/linux_device_pre.conf)
+
+# modifications to g++-unix.conf
+QMAKE_CC                = $${CROSS_COMPILE}gcc
+QMAKE_CXX               = $${CROSS_COMPILE}g++
+QMAKE_LINK		= $${CROSS_COMPILE}g++
+
+# modifications to gcc-base.conf
+QMAKE_CFLAGS           += $${BR_COMPILER_CFLAGS}
+QMAKE_CXXFLAGS         += $${BR_COMPILER_CXXFLAGS}
+# Remove all optimisation flags, we really only want our own.
+QMAKE_CFLAGS_OPTIMIZE       =
+QMAKE_CFLAGS_OPTIMIZE_DEBUG =
+QMAKE_CFLAGS_OPTIMIZE_FULL  =
+QMAKE_CFLAGS_OPTIMIZE_SIZE  =
+QMAKE_CFLAGS_DEBUG =
+QMAKE_CXXFLAGS_DEBUG =
+QMAKE_CFLAGS_RELEASE =
+QMAKE_CXXFLAGS_RELEASE =
+CONFIG                 += nostrip
+
+QMAKE_LIBS             += -lrt -lpthread -ldl
+QMAKE_CFLAGS_ISYSTEM   =
+
+@EGLFS_DEVICE@
+
+include(../common/linux_device_post.conf)
+load(qt_config)
package/qt6/qt6base/qplatformdefs.h new file +1 -0
new file mode 100644
index 0000000000..99e9a27923
@@ -0,0 +1 @@
+#include "../../linux-g++/qplatformdefs.h"
package/qt6/qt6base/qt.conf.in new file +7 -0
new file mode 100644
index 0000000000..4842bcb462
@@ -0,0 +1,7 @@
+[Paths]
+Prefix=/usr
+HostPrefix=@@HOST_DIR@@
+HostData=../target/usr
+Sysroot=@@STAGING_DIR@@
+SysrootifyPrefix=true
+TargetSpec=devices/linux-buildroot-g++
package/qt6/qt6base/qt6base.mk +18 -0
index b7ee6037f3..9e2f884e94 100644
@@ -35,6 +35,9 @@ QT6BASE_CONF_OPTS = \
 	-DFEATURE_system_zlib=ON \
 	-DFEATURE_system_libb2=ON
 
+QT6BASE_CFLAGS = $(TARGET_CFLAGS)
+QT6BASE_CXXFLAGS = $(TARGET_CXXFLAGS)
+
 # x86 optimization options. While we have a BR2_X86_CPU_HAS_AVX512, it
 # is not clear yet how it maps to all the avx512* options of Qt, so we
 # for now keeps them disabled.
@@ -215,5 +218,20 @@ else
 QT6BASE_CONF_OPTS += -DFEATURE_zstd=OFF
 endif
 
+define QT6BASE_MAKE_BR_SPEC
+	mkdir -p $(@D)/mkspecs/devices/linux-buildroot-g++/
+	sed 's/@EGLFS_DEVICE@/$(QT6BASE_EGLFS_DEVICE)/g' \
+		$(QT6BASE_PKGDIR)/qmake.conf.in > \
+		$(@D)/mkspecs/devices/linux-buildroot-g++/qmake.conf
+	$(INSTALL) -m 0644 -D $(QT6BASE_PKGDIR)/qplatformdefs.h \
+		$(@D)/mkspecs/devices/linux-buildroot-g++/qplatformdefs.h
+endef
+
+QT6BASE_CONF_OPTS += -DQT_QMAKE_DEVICE_OPTIONS=CROSS_COMPILE="$(TARGET_CROSS)";BR_COMPILER_CFLAGS="$(QT6BASE_CFLAGS)";BR_COMPILER_CXXFLAGS="$(QT6BASE_CXX_FLAGS)"
+
+QT6BASE_PRE_CONFIGURE_HOOKS += QT6BASE_MAKE_BR_SPEC
+
+QT6BASE_POST_INSTALL_STAGING_HOOKS += QT6_INSTALL_QT_CONF
+
 $(eval $(cmake-package))
 $(eval $(host-cmake-package))
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Tested-by on v1 1/1
#1 lore raw
Quoted 9 lines · Jesse Van Gavere

The qmake functionality had been missing due to the new host/target build requirement, to get it working the main parts of the qt5 qmake has been kept, we're still making our own device spec which we use to run qmake with along with passing some additional device options for our flags/cross-compiler the biggest difference is that where previously qt.conf was used to fixup per-paths builds, this is now always created with changed contents so qmake looks at the correct target directories.

Quoted 4 lines

A big thanks to Angelo Compagnucci for the encouragement and testing.

Quoted 143 lines
---
 package/qt6/qt6.mk                  | 12 ++++++++++
 package/qt6/qt6base/qmake.conf.in   | 36 +++++++++++++++++++++++++++++
 package/qt6/qt6base/qplatformdefs.h |  1 +
 package/qt6/qt6base/qt.conf.in      |  7 ++++++
 package/qt6/qt6base/qt6base.mk      | 18 +++++++++++++++
 5 files changed, 74 insertions(+)
 create mode 100644 package/qt6/qt6base/qmake.conf.in
 create mode 100644 package/qt6/qt6base/qplatformdefs.h
 create mode 100644 package/qt6/qt6base/qt.conf.in
package/qt6/qt6.mk +0 -0
index 575b2f826c..bd8fb0ab51 100644
@@ -10,3 +10,15 @@ QT6_SOURCE_TARBALL_PREFIX = everywhere-src
 QT6_SITE =

https://download.qt.io/archive/qt/$(QT6_VERSION_MAJOR)/$(QT6_VERSION)/submodules

include $(sort $(wildcard package/qt6/*/*.mk))

package/qt6/qt6.mk +7 -0
+
+# The file "qt.conf" can be used to override the hard-coded paths that are
+# compiled into the Qt library. We need it to make "qmake" relocatable due
+# to the host/target build and tweak the per-package install pathes
+define QT6_INSTALL_QT_CONF
+       rm -f $(HOST_DIR)/bin/qt.conf
+       sed -e "s|@@HOST_DIR@@|$(HOST_DIR)|" -e "s|@@STAGING_DIR@@|$(STAGING_DIR)|"

\

package/qt6/qt6.mk +5 -0
+               $(QT6BASE_PKGDIR)/qt.conf.in > $(HOST_DIR)/bin/qt.conf
+endef
+
+# Variable for other Qt applications to use
+QT6_QMAKE = $(HOST_DIR)/bin/qmake -spec devices/linux-buildroot-g++
package/qt6/qt6base/ renamed from package/qt6/qt6base/qmake.conf.in +0 -0

qmake.conf.in
new file mode 100644
index 0000000000..ebb8497d2d

package/qt6/qt6base/qmake.conf.in new file +36 -0
@@ -0,0 +1,36 @@
+# Qt6 has a mechanism to support "device" profiles, so that people can
+# specify the compiler, compiler flags and so on for a specific device.
+
+# We leverage this mechanism in the Buildroot packaging of qt6 to
+# simplify cross-compilation: we have our own "device" definition, which
+# allows us to easily pass the cross-compiler paths and flags from our
+# qt6.mk.
+
+include(../common/linux_device_pre.conf)
+
+# modifications to g++-unix.conf
+QMAKE_CC                = $${CROSS_COMPILE}gcc
+QMAKE_CXX               = $${CROSS_COMPILE}g++
+QMAKE_LINK             = $${CROSS_COMPILE}g++
+
+# modifications to gcc-base.conf
+QMAKE_CFLAGS           += $${BR_COMPILER_CFLAGS}
+QMAKE_CXXFLAGS         += $${BR_COMPILER_CXXFLAGS}
+# Remove all optimisation flags, we really only want our own.
+QMAKE_CFLAGS_OPTIMIZE       =
+QMAKE_CFLAGS_OPTIMIZE_DEBUG =
+QMAKE_CFLAGS_OPTIMIZE_FULL  =
+QMAKE_CFLAGS_OPTIMIZE_SIZE  =
+QMAKE_CFLAGS_DEBUG =
+QMAKE_CXXFLAGS_DEBUG =
+QMAKE_CFLAGS_RELEASE =
+QMAKE_CXXFLAGS_RELEASE =
+CONFIG                 += nostrip
+
+QMAKE_LIBS             += -lrt -lpthread -ldl
+QMAKE_CFLAGS_ISYSTEM   =
+
+@EGLFS_DEVICE@
+
+include(../common/linux_device_post.conf)
+load(qt_config)
package/qt6/qt6base/qplatformdefs.h new file +1 -0
new file mode 100644
index 0000000000..99e9a27923
@@ -0,0 +1 @@
+#include "../../linux-g++/qplatformdefs.h"
package/qt6/qt6base/ renamed from package/qt6/qt6base/qt.conf.in +0 -0

qt.conf.in
new file mode 100644
index 0000000000..4842bcb462

package/qt6/qt6base/qt.conf.in new file +7 -0
@@ -0,0 +1,7 @@
+[Paths]
+Prefix=/usr
+HostPrefix=@@HOST_DIR@@
+HostData=../target/usr
+Sysroot=@@STAGING_DIR@@
+SysrootifyPrefix=true
+TargetSpec=devices/linux-buildroot-g++
package/qt6/qt6base/ renamed from package/qt6/qt6base/qt6base.mk +0 -0

qt6base.mk
index b7ee6037f3..9e2f884e94 100644

package/qt6/qt6base/qt6base.mk +18 -2
@@ -35,6 +35,9 @@ QT6BASE_CONF_OPTS = \
        -DFEATURE_system_zlib=ON \
        -DFEATURE_system_libb2=ON
 
+QT6BASE_CFLAGS = $(TARGET_CFLAGS)
+QT6BASE_CXXFLAGS = $(TARGET_CXXFLAGS)
+
 # x86 optimization options. While we have a BR2_X86_CPU_HAS_AVX512, it
 # is not clear yet how it maps to all the avx512* options of Qt, so we
 # for now keeps them disabled.
@@ -215,5 +218,20 @@ else
 QT6BASE_CONF_OPTS += -DFEATURE_zstd=OFF
 endif
 
+define QT6BASE_MAKE_BR_SPEC
+       mkdir -p $(@D)/mkspecs/devices/linux-buildroot-g++/
+       sed 's/@EGLFS_DEVICE@/$(QT6BASE_EGLFS_DEVICE)/g' \
+               $(QT6BASE_PKGDIR)/qmake.conf.in > \
+               $(@D)/mkspecs/devices/linux-buildroot-g++/qmake.conf
+       $(INSTALL) -m 0644 -D $(QT6BASE_PKGDIR)/qplatformdefs.h \
+               $(@D)/mkspecs/devices/linux-buildroot-g++/qplatformdefs.h
+endef
+
+QT6BASE_CONF_OPTS +=
-DQT_QMAKE_DEVICE_OPTIONS=CROSS_COMPILE="$(TARGET_CROSS)";BR_COMPILER_CFLAGS="$(QT6BASE_CFLAGS)";BR_COMPILER_CXXFLAGS="$(QT6BASE_CXX_FLAGS)"
+
+QT6BASE_PRE_CONFIGURE_HOOKS += QT6BASE_MAKE_BR_SPEC
+
+QT6BASE_POST_INSTALL_STAGING_HOOKS += QT6_INSTALL_QT_CONF
+
 $(eval $(cmake-package))
 $(eval $(host-cmake-package))
--

2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

Signature · 15 lines
Angelo Compagnucci

Software Engineer

[email protected]
__________________________________
Amarula Solutions SRL

Via le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 (0)42 243 5310
[email protected]

www.amarulasolutions.com
[`as] https://www.amarulasolutions.com|

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot