diff mbox series

cmake-native: support RUNTIME_DEPENDENCIES for OE cross compiling

Message ID 20250302043802.3279519-1-hongxu.jia@windriver.com
State New
Headers show
Series cmake-native: support RUNTIME_DEPENDENCIES for OE cross compiling | expand

Commit Message

Hongxu Jia March 2, 2025, 4:38 a.m. UTC
While software uses RUNTIME_DEPENDENCIES for cmake build, it failed in
OE cross compiling
...
  install TARGETS RUNTIME_DEPENDENCIES is not supported when cross-compiling.
...

This commit adds environment OECMAKE_FORCE_CROSSCOMPILING to force support
RUNTIME_DEPENDENCIES for OE cross compile

export OECMAKE_FORCE_CROSSCOMPILING ??= "0" in cmake.bbclass, when users
encounter the error and explicitly set OECMAKE_FORCE_CROSSCOMPILING = "1"
in recipe, they should be aware of the probably regression of
RUNTIME_DEPENDENCIES in cross compiling situation

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 meta/classes-recipe/cmake.bbclass             |  2 +
 .../cmake/cmake-native_3.31.5.bb              |  1 +
 ..._DEPENDENCIES-for-oe-cross-compiling.patch | 52 +++++++++++++++++++
 3 files changed, 55 insertions(+)
 create mode 100644 meta/recipes-devtools/cmake/cmake/0001-support-RUNTIME_DEPENDENCIES-for-oe-cross-compiling.patch

Comments

Alexander Kanavin March 4, 2025, 6:09 p.m. UTC | #1
On Sun, 2 Mar 2025 at 05:38, hongxu via lists.openembedded.org
<hongxu.jia=eng.windriver.com@lists.openembedded.org> wrote:
> +Subject: [PATCH] support RUNTIME_DEPENDENCIES for oe cross compiling
> +
> +According to upstream cmake doc[1]:
> +...
> +``RUNTIME_DEPENDENCIES``
> +  .. versionadded:: 3.21
> +
> +  This option causes all runtime dependencies of installed executable, shared
> +  library, and module targets to be installed along with the targets
> +  themselves. The ``RUNTIME``, ``LIBRARY``, ``FRAMEWORK``, and generic
> +  arguments are used to determine the properties (``DESTINATION``,
> +  ``COMPONENT``, etc.) of the installation of these dependencies.
> +...
> +
> +But it does not support cross compiling, this commit adds environment
> +OECMAKE_FORCE_CROSSCOMPILING to force support RUNTIME_DEPENDENCIES for
> +OE cross compiling
> +
> +[1] https://gitlab.kitware.com/cmake/cmake/-/commit/72f2448e82d8b3e90fa733cb6c631298083ae06b
> +
> +Upstream-Status: Inappropriate [oe specific]
> +
> +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> +---
> + Source/cmInstallCommand.cxx | 7 +++++--

I'm not sure. This doesn't seem to be common, can we rather just patch
specific components instead, and not alter cmake behaviour?

At the very least, a patch like this needs an upstream ticket
describing the problem to upstream.

Alex
Vyacheslav Yurkov March 5, 2025, 8:47 a.m. UTC | #2
On 04.03.2025 19:09, Alexander Kanavin via lists.openembedded.org wrote:
> On Sun, 2 Mar 2025 at 05:38, hongxu via lists.openembedded.org
> <hongxu.jia=eng.windriver.com@lists.openembedded.org> wrote:
>> +Subject: [PATCH] support RUNTIME_DEPENDENCIES for oe cross compiling
>> +
>> +According to upstream cmake doc[1]:
>> +...
>> +``RUNTIME_DEPENDENCIES``
>> +  .. versionadded:: 3.21
>> +
>> +  This option causes all runtime dependencies of installed executable, shared
>> +  library, and module targets to be installed along with the targets
>> +  themselves. The ``RUNTIME``, ``LIBRARY``, ``FRAMEWORK``, and generic
>> +  arguments are used to determine the properties (``DESTINATION``,
>> +  ``COMPONENT``, etc.) of the installation of these dependencies.
>> +...
>> +
>> +But it does not support cross compiling, this commit adds environment
>> +OECMAKE_FORCE_CROSSCOMPILING to force support RUNTIME_DEPENDENCIES for
>> +OE cross compiling
>> +
>> +[1] https://gitlab.kitware.com/cmake/cmake/-/commit/72f2448e82d8b3e90fa733cb6c631298083ae06b
>> +
>> +Upstream-Status: Inappropriate [oe specific]
>> +
>> +Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
>> +---
>> + Source/cmInstallCommand.cxx | 7 +++++--
> I'm not sure. This doesn't seem to be common, can we rather just patch
> specific components instead, and not alter cmake behaviour?
>
> At the very least, a patch like this needs an upstream ticket
> describing the problem to upstream.
>
> Alex
>

I'm inclined to agree with Alex here.

Slava
diff mbox series

Patch

diff --git a/meta/classes-recipe/cmake.bbclass b/meta/classes-recipe/cmake.bbclass
index e79f8a7435..9393e6133e 100644
--- a/meta/classes-recipe/cmake.bbclass
+++ b/meta/classes-recipe/cmake.bbclass
@@ -64,6 +64,8 @@  OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM = "ONLY"
 
 EXTRA_OECMAKE:append = " ${PACKAGECONFIG_CONFARGS}"
 
+export OECMAKE_FORCE_CROSSCOMPILING ??= "0"
+
 export CMAKE_BUILD_PARALLEL_LEVEL
 CMAKE_BUILD_PARALLEL_LEVEL:task-compile = "${@oe.utils.parallel_make(d, False)}"
 CMAKE_BUILD_PARALLEL_LEVEL:task-install = "${@oe.utils.parallel_make(d, True)}"
diff --git a/meta/recipes-devtools/cmake/cmake-native_3.31.5.bb b/meta/recipes-devtools/cmake/cmake-native_3.31.5.bb
index e285a17681..9446e1c2c5 100644
--- a/meta/recipes-devtools/cmake/cmake-native_3.31.5.bb
+++ b/meta/recipes-devtools/cmake/cmake-native_3.31.5.bb
@@ -7,6 +7,7 @@  SRC_URI += "file://OEToolchainConfig.cmake \
             file://environment.d-cmake.sh \
             file://0005-Disable-use-of-ext2fs-ext2_fs.h-by-cmake-s-internal-.patch \
             file://0001-CMakeLists.txt-disable-USE_NGHTTP2.patch \
+            file://0001-support-RUNTIME_DEPENDENCIES-for-oe-cross-compiling.patch \
             "
 
 LICENSE:append = " & BSD-1-Clause & MIT & BSD-2-Clause & curl"
diff --git a/meta/recipes-devtools/cmake/cmake/0001-support-RUNTIME_DEPENDENCIES-for-oe-cross-compiling.patch b/meta/recipes-devtools/cmake/cmake/0001-support-RUNTIME_DEPENDENCIES-for-oe-cross-compiling.patch
new file mode 100644
index 0000000000..163dd3c140
--- /dev/null
+++ b/meta/recipes-devtools/cmake/cmake/0001-support-RUNTIME_DEPENDENCIES-for-oe-cross-compiling.patch
@@ -0,0 +1,52 @@ 
+From 7b3c3674df6ad8f90475d51f9c104e825656ebcc Mon Sep 17 00:00:00 2001
+From: Hongxu Jia <hongxu.jia@windriver.com>
+Date: Fri, 21 Feb 2025 20:28:39 +0800
+Subject: [PATCH] support RUNTIME_DEPENDENCIES for oe cross compiling
+
+According to upstream cmake doc[1]:
+...
+``RUNTIME_DEPENDENCIES``
+  .. versionadded:: 3.21
+
+  This option causes all runtime dependencies of installed executable, shared
+  library, and module targets to be installed along with the targets
+  themselves. The ``RUNTIME``, ``LIBRARY``, ``FRAMEWORK``, and generic
+  arguments are used to determine the properties (``DESTINATION``,
+  ``COMPONENT``, etc.) of the installation of these dependencies.
+...
+
+But it does not support cross compiling, this commit adds environment
+OECMAKE_FORCE_CROSSCOMPILING to force support RUNTIME_DEPENDENCIES for
+OE cross compiling
+
+[1] https://gitlab.kitware.com/cmake/cmake/-/commit/72f2448e82d8b3e90fa733cb6c631298083ae06b
+
+Upstream-Status: Inappropriate [oe specific]
+
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+---
+ Source/cmInstallCommand.cxx | 7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
+index 89cf028d38..cd4336b2a3 100644
+--- a/Source/cmInstallCommand.cxx
++++ b/Source/cmInstallCommand.cxx
+@@ -648,9 +648,12 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
+                  system, '"'));
+       return false;
+     }
+-    if (helper.Makefile->IsOn("CMAKE_CROSSCOMPILING")) {
++    std::string oe_force = cmSystemTools::GetEnvVar("OECMAKE_FORCE_CROSSCOMPILING").
++      value_or(std::string());
++    if (helper.Makefile->IsOn("CMAKE_CROSSCOMPILING") && (oe_force != "1")) {
+       status.SetError("TARGETS RUNTIME_DEPENDENCIES is not supported "
+-                      "when cross-compiling.");
++                      "when cross-compiling. "
++                      "Please export OECMAKE_FORCE_CROSSCOMPILING='1' to force run");
+       return false;
+     }
+     if (helper.Makefile->GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME") ==
+-- 
+2.25.1
+