[Buildroot] [PATCH 2/3] package/pkg-cmake.mk: fix absolute paths in .cmake files for per-package builds

Adam Duskett aduskett at gmail.com
Mon Jan 3 23:02:48 UTC 2022


Some packages (notably qmake packages) generate .cmake files with absolute
paths. Unfortunately, doing so breaks per-package builds because the paths in
the .cmake files point outside the per-package sysroot.

Add the new pre-configure-hook "FIXUP_CMAKECONFIG_ABSOLUTE_PATHS" in
package/pkg-cmake.mk which searches for all .cmake files in a  per-package
staging directory and removes the $(STAGING_DIR)/ prefix from in them.
This simple fix allows non-qt5base qt5 packages to build with per-package
enabled.

Based off of Louis-Paul's earlier work found here:
https://lore.kernel.org/buildroot/a339f273-33f3-f232-eac4-6e50427abf6d@cordier.org/

And Yann Morin's feedback found here:
https://patchwork.ozlabs.org/project/buildroot/patch/20200217212350.29750-21-anaumann@ultratronik.de/

Signed-off-by: Adam Duskett <aduskett at gmail.com>
---
 package/pkg-cmake.mk | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
index 3b1db35fb6..47234fbdd9 100644
--- a/package/pkg-cmake.mk
+++ b/package/pkg-cmake.mk
@@ -65,6 +65,17 @@ else
 $(2)_BUILDDIR			= $$($(2)_SRCDIR)/buildroot-build
 endif
 
+# Some packages may generate cmake files with absolute paths. Remove the
+# absolute paths from the generated cmake files to keep per-package isolation
+# with the build sysroot.
+ifeq ($(BR2_PER_PACKAGE_DIRECTORIES),y)
+define FIXUP_CMAKECONFIG_ABSOLUTE_PATHS
+	$(Q)find $(STAGING_DIR)/ -name "*.cmake" | xargs --no-run-if-empty \
+		$(SED) "s:$(STAGING_DIR)::g"
+endef
+$(2)_PRE_CONFIGURE_HOOKS += FIXUP_CMAKECONFIG_ABSOLUTE_PATHS
+endif
+
 #
 # Configure step. Only define it if not already defined by the package
 # .mk file. And take care of the differences between host and target
-- 
2.33.1




More information about the buildroot mailing list