diff mbox series

[1/4] cmake-qemu.bbclass: make it more usable

Message ID 20231207205251.4152034-1-adrian.freihofer@siemens.com
State Accepted, archived
Commit 5cb05ca6542aa6239e0371dd9df4705b168d245e
Headers show
Series [1/4] cmake-qemu.bbclass: make it more usable | expand

Commit Message

Adrian Freihofer Dec. 7, 2023, 8:52 p.m. UTC
Make the cmake-qemu.bbclass more usable:
- Drop the CMAKE_EXEWRAPPER_ENABLED variable (which does not make much
  sense without the second commit of the original patch series).
- Inherit qemu to make the cmake-qemu a drop in replacement for cmake.

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
---
 meta/classes-recipe/cmake-qemu.bbclass | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/cmake-qemu.bbclass b/meta/classes-recipe/cmake-qemu.bbclass
index 76b748f3406..46a89e2827b 100644
--- a/meta/classes-recipe/cmake-qemu.bbclass
+++ b/meta/classes-recipe/cmake-qemu.bbclass
@@ -5,18 +5,22 @@ 
 #
 # Not all platforms are supported by Qemu. Using qemu-user therefore
 # involves a certain risk, which is also the reason why this feature
-# is not activated by default.
+# is not part of the main cmake class by default.
+#
+# One use case is the execution of cross-compiled unit tests with CTest
+# on the build machine. If CMAKE_EXEWRAPPER_ENABLED is configured,
+#   cmake --build --target test
+# works transparently with qemu-user. If the cmake project is developed
+# with this use case in mind this works very nicely also out of an IDE
+# configured to use cmake-native for cross compiling.
 
-inherit qemu
+inherit qemu cmake
 
-CMAKE_EXEWRAPPER_ENABLED:class-native = "False"
-CMAKE_EXEWRAPPER_ENABLED:class-nativesdk = "False"
-CMAKE_EXEWRAPPER_ENABLED ?= "${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'True', 'False', d)}"
-DEPENDS:append = "${@' qemu-native' if d.getVar('CMAKE_EXEWRAPPER_ENABLED') == 'True' else ''}"
+DEPENDS:append:class-target = "${@' qemu-native' if bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', True, False, d) else ''}"
 
 cmake_do_generate_toolchain_file:append:class-target() {
-    if [ "${CMAKE_EXEWRAPPER_ENABLED}" = "True" ]; then
-        # Write out a qemu wrapper that will be used as exe_wrapper so that camake
+    if [ "${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'True', 'False', d)}" ]; then
+        # Write out a qemu wrapper that will be used as exe_wrapper so that cmake
         # can run target helper binaries through that. This also allows to execute ctest.
         qemu_binary="${@qemu_wrapper_cmdline(d, '${STAGING_DIR_HOST}', ['${STAGING_DIR_HOST}/${libdir}','${STAGING_DIR_HOST}/${base_libdir}'])}"
         echo "#!/bin/sh" > "${WORKDIR}/cmake-qemuwrapper"