From patchwork Tue Aug 6 08:28:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Niestroj X-Patchwork-Id: 1142655 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=grinn-global.com Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 462npR5Mdqz9sN1 for ; Tue, 6 Aug 2019 18:28:31 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id D50C187BD3; Tue, 6 Aug 2019 08:28:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id B6NQyld4nB0T; Tue, 6 Aug 2019 08:28:28 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id BEBF087B3C; Tue, 6 Aug 2019 08:28:27 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 32AB71BF281 for ; Tue, 6 Aug 2019 08:28:27 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 2FF6221503 for ; Tue, 6 Aug 2019 08:28:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MXQSynY2xPlN for ; Tue, 6 Aug 2019 08:28:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from smtp.megiteam.pl (smtp.megiteam.pl [31.186.83.105]) by silver.osuosl.org (Postfix) with ESMTPS id 7ADC5214E9 for ; Tue, 6 Aug 2019 08:28:25 +0000 (UTC) Received: from [95.143.241.142] (helo=localhost.localdomain) by smtp.megiteam.pl with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1huupR-0003Ww-Mo; Tue, 06 Aug 2019 10:28:22 +0200 From: Marcin Niestroj To: buildroot@buildroot.org Date: Tue, 6 Aug 2019 10:28:10 +0200 Message-Id: <20190806082810.24082-1-m.niestroj@grinn-global.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Subject: [Buildroot] [PATCH] package/meson: support cmake exported packages X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcin Niestroj Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" So far meson was not able to find CMake modules in cross compiled environments such as Buildroot. Added patch allows to do that now. Additionally meson needs to know path to cmake binary in order to finalize CMake module import. Signed-off-by: Marcin Niestroj --- ...port-for-crosscompiled-CMake-modules.patch | 60 +++++++++++++++++++ package/meson/cross-compilation.conf.in | 1 + package/pkg-meson.mk | 1 + 3 files changed, 62 insertions(+) create mode 100644 package/meson/0002-Improve-support-for-crosscompiled-CMake-modules.patch diff --git a/package/meson/0002-Improve-support-for-crosscompiled-CMake-modules.patch b/package/meson/0002-Improve-support-for-crosscompiled-CMake-modules.patch new file mode 100644 index 0000000000..eeeab4962b --- /dev/null +++ b/package/meson/0002-Improve-support-for-crosscompiled-CMake-modules.patch @@ -0,0 +1,60 @@ +From 61edbcf60e20dbf730e6074f055f78e0e217f4ed Mon Sep 17 00:00:00 2001 +From: Marcin Niestroj +Date: Thu, 1 Aug 2019 11:01:49 +0200 +Subject: [PATCH] Improve support for crosscompiled CMake modules + +commit 987539e2331f2c78e94cbcf3623a82a66dd52267 upstream. + +There are two variables that CMake takes into account during +find_package() in cross-compiled environments, which are: CMAKE_SYSROOT +and CMAKE_FIND_ROOT_PATH. Those are used in cmFindCommon::RerootPaths() +function, which blindly prepends all search paths with those specified +via CMAKE_SYSROOT and CMAKE_FIND_ROOT_PATH. + +Extend search paths by using CMAKE_SYSROOT and CMAKE_FIND_ROOT_PATH in a +similar way as CMake does, so we successfully find CMake packages +information in cross-compiled environments. + +Signed-off-by: Marcin Niestroj +--- + mesonbuild/dependencies/base.py | 11 ++++++++++- + mesonbuild/dependencies/data/CMakePathInfo.txt | 2 ++ + 2 files changed, 12 insertions(+), 1 deletion(-) + +diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py +index 21da8e24..98b02ff7 100644 +--- a/mesonbuild/dependencies/base.py ++++ b/mesonbuild/dependencies/base.py +@@ -1178,7 +1178,16 @@ class CMakeDependency(ExternalDependency): + return None + + # Extract the variables and sanity check them +- module_paths = sorted(set(self.get_cmake_var('MESON_PATHS_LIST'))) ++ root_paths = set(self.get_cmake_var('MESON_FIND_ROOT_PATH')) ++ root_paths.update(set(self.get_cmake_var('MESON_CMAKE_SYSROOT'))) ++ root_paths = sorted(root_paths) ++ root_paths = list(filter(lambda x: os.path.isdir(x), root_paths)) ++ module_paths = set(self.get_cmake_var('MESON_PATHS_LIST')) ++ rooted_paths = [] ++ for j in [Path(x) for x in root_paths]: ++ for i in [Path(x) for x in module_paths]: ++ rooted_paths.append(str(j / i.relative_to(i.anchor))) ++ module_paths = sorted(module_paths.union(rooted_paths)) + module_paths = list(filter(lambda x: os.path.isdir(x), module_paths)) + archs = self.get_cmake_var('MESON_ARCH_LIST') + +diff --git a/mesonbuild/dependencies/data/CMakePathInfo.txt b/mesonbuild/dependencies/data/CMakePathInfo.txt +index 713c2da3..662ec583 100644 +--- a/mesonbuild/dependencies/data/CMakePathInfo.txt ++++ b/mesonbuild/dependencies/data/CMakePathInfo.txt +@@ -25,5 +25,7 @@ endif() + set(MESON_ARCH_LIST ${LIB_ARCH_LIST}) + set(MESON_PATHS_LIST ${TMP_PATHS_LIST}) + set(MESON_CMAKE_ROOT ${CMAKE_ROOT}) ++set(MESON_CMAKE_SYSROOT ${CMAKE_SYSROOT}) ++set(MESON_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH}) + + message(STATUS ${TMP_PATHS_LIST}) +-- +2.22.0 + diff --git a/package/meson/cross-compilation.conf.in b/package/meson/cross-compilation.conf.in index fc8e27f7eb..cd466dbd05 100644 --- a/package/meson/cross-compilation.conf.in +++ b/package/meson/cross-compilation.conf.in @@ -9,6 +9,7 @@ cpp = '@TARGET_CROSS@g++' ar = '@TARGET_CROSS@ar' strip = '@TARGET_CROSS@strip' pkgconfig = '@HOST_DIR@/usr/bin/pkg-config' +cmake = ['@BR2_CMAKE@', '-DCMAKE_TOOLCHAIN_FILE=@HOST_DIR@/share/buildroot/toolchainfile.cmake'] [properties] needs_exe_wrapper = true diff --git a/package/pkg-meson.mk b/package/pkg-meson.mk index 0b811d1cc0..ec3e89dc1a 100644 --- a/package/pkg-meson.mk +++ b/package/pkg-meson.mk @@ -79,6 +79,7 @@ define $(2)_CONFIGURE_CMDS -e "s%@TARGET_LDFLAGS@%$$($(2)_MESON_SED_LDFLAGS)%g" \ -e "s%@TARGET_CXXFLAGS@%$$($(2)_MESON_SED_CXXFLAGS)%g" \ -e "s%@HOST_DIR@%$$(HOST_DIR)%g" \ + -e "s%@BR2_CMAKE@%$$(BR2_CMAKE)%g" \ package/meson/cross-compilation.conf.in \ > $$($$(PKG)_SRCDIR)/build/cross-compilation.conf PATH=$$(BR_PATH) $$($$(PKG)_CONF_ENV) $$(MESON) \