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....@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

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....@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....@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
+
-- 
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#212185): 
https://lists.openembedded.org/g/openembedded-core/message/212185
Mute This Topic: https://lists.openembedded.org/mt/111465628/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to