pkg-cmake: install CMake files as part of a package
authorThomas Petazzoni <thomas.petazzoni@bootlin.com>
Sat, 24 Mar 2018 14:20:01 +0000 (15:20 +0100)
committerPeter Korsgaard <peter@korsgaard.com>
Sun, 25 Mar 2018 15:35:26 +0000 (17:35 +0200)
Currently, the toolchainfile.cmake and Buildroot.cmake files are
installed outside of any package, just triggered by the toolchain
target.

As part of the per-package SDK effort, we are trying to avoid anything
that installs to the global $(HOST_DIR), and this is one of the
remaining files installed in $(HOST_DIR) outside of any package. We
fix this by installing such files as part of the toolchain package
post-install staging hooks.

Yes, a post-install staging hook to install things to $(HOST_DIR) is a
bit weird, but the toolchain infrastructure is made of target packages
only, and they all install a lot of stuff to $(HOST_DIR) already.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
package/pkg-cmake.mk
toolchain/toolchain/toolchain.mk

index 9b07798a1e731dda3312ae70072dd22d2114de05..34b49bdbe57aef31dd9073d6402d7d487417e163 100644 (file)
@@ -253,8 +253,8 @@ endif
 # based on the toolchainfile.cmake file's location: $(HOST_DIR)/share/buildroot
 # In all the other variables, HOST_DIR will be replaced by RELOCATED_HOST_DIR,
 # so we have to strip "$(HOST_DIR)/" from the paths that contain it.
-$(HOST_DIR)/share/buildroot/toolchainfile.cmake:
-       @mkdir -p $(@D)
+define TOOLCHAIN_CMAKE_INSTALL_FILES
+       @mkdir -p $(HOST_DIR)/share/buildroot
        sed \
                -e 's#@@STAGING_SUBDIR@@#$(call qstrip,$(STAGING_SUBDIR))#' \
                -e 's#@@TARGET_CFLAGS@@#$(call qstrip,$(TARGET_CFLAGS))#' \
@@ -268,7 +268,9 @@ $(HOST_DIR)/share/buildroot/toolchainfile.cmake:
                -e 's#@@TOOLCHAIN_HAS_FORTRAN@@#$(if $(BR2_TOOLCHAIN_HAS_FORTRAN),1,0)#' \
                -e 's#@@CMAKE_BUILD_TYPE@@#$(if $(BR2_ENABLE_DEBUG),Debug,Release)#' \
                $(TOPDIR)/support/misc/toolchainfile.cmake.in \
-               > $@
+               > $(HOST_DIR)/share/buildroot/toolchainfile.cmake
+       $(Q)$(INSTALL) -D -m 0644 support/misc/Buildroot.cmake \
+               $(HOST_DIR)/share/buildroot/Platform/Buildroot.cmake
+endef
 
-$(HOST_DIR)/share/buildroot/Platform/Buildroot.cmake:
-       $(Q)$(INSTALL) -D -m 0644 support/misc/Buildroot.cmake $(@)
+TOOLCHAIN_POST_INSTALL_STAGING_HOOKS += TOOLCHAIN_CMAKE_INSTALL_FILES
index 179c09edf1adc79a4666797c30e031a8976fd647..91c9ca2eff6495610b4ef2e2500df446a860d305 100644 (file)
@@ -38,6 +38,3 @@ TOOLCHAIN_INSTALL_STAGING = YES
 endif
 
 $(eval $(virtual-package))
-
-toolchain: $(HOST_DIR)/share/buildroot/toolchainfile.cmake
-toolchain: $(HOST_DIR)/share/buildroot/Platform/Buildroot.cmake