summaryrefslogtreecommitdiffstats
path: root/meta/classes-recipe
diff options
context:
space:
mode:
authorAdrian Freihofer <adrian.freihofer@gmail.com>2023-11-20 15:46:27 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-11-30 08:43:03 +0000
commit07462992787a1e762e13c48d3888c3915e4a4a4b (patch)
tree729886388ee04364a1dba32f002ab59049ca9563 /meta/classes-recipe
parent3e50e45917831d9da2d86e69fb908a1a78483b62 (diff)
downloadpoky-07462992787a1e762e13c48d3888c3915e4a4a4b.tar.gz
cmake-qemu.bbclass: support qemu for cmake
Define the CMAKE_CROSSCOMPILING_EMULATOR variable similar to what the meson bbclass does. This allows for example to execute cross compilied unit tests on the build machine when using an SDK. CMAKE_CROSSCOMPILING_EMULATOR is a semi colon separated list of paramters which could directly handle the -L and the -E parameters. Creating a wrapper script is not absolutely mandatory. But anyway lets do it similar to what the meson.bbclass does and also disable pseudo. Further information can be found in the camke documentation in the CMAKE_CROSSCOMPILING_EMULATOR section. Keep the code optional, as the core does not need this function and does not intend to use it in the future. [YOCTO #15214] (From OE-Core rev: b197d0b0de1fa5f295d32dbda2eb815ca0153299) Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe')
-rw-r--r--meta/classes-recipe/cmake-qemu.bbclass28
1 files changed, 28 insertions, 0 deletions
diff --git a/meta/classes-recipe/cmake-qemu.bbclass b/meta/classes-recipe/cmake-qemu.bbclass
new file mode 100644
index 0000000000..76b748f340
--- /dev/null
+++ b/meta/classes-recipe/cmake-qemu.bbclass
@@ -0,0 +1,28 @@
1#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6# Not all platforms are supported by Qemu. Using qemu-user therefore
7# involves a certain risk, which is also the reason why this feature
8# is not activated by default.
9
10inherit qemu
11
12CMAKE_EXEWRAPPER_ENABLED:class-native = "False"
13CMAKE_EXEWRAPPER_ENABLED:class-nativesdk = "False"
14CMAKE_EXEWRAPPER_ENABLED ?= "${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'True', 'False', d)}"
15DEPENDS:append = "${@' qemu-native' if d.getVar('CMAKE_EXEWRAPPER_ENABLED') == 'True' else ''}"
16
17cmake_do_generate_toolchain_file:append:class-target() {
18 if [ "${CMAKE_EXEWRAPPER_ENABLED}" = "True" ]; then
19 # Write out a qemu wrapper that will be used as exe_wrapper so that camake
20 # can run target helper binaries through that. This also allows to execute ctest.
21 qemu_binary="${@qemu_wrapper_cmdline(d, '${STAGING_DIR_HOST}', ['${STAGING_DIR_HOST}/${libdir}','${STAGING_DIR_HOST}/${base_libdir}'])}"
22 echo "#!/bin/sh" > "${WORKDIR}/cmake-qemuwrapper"
23 echo "$qemu_binary \"\$@\"" >> "${WORKDIR}/cmake-qemuwrapper"
24 chmod +x "${WORKDIR}/cmake-qemuwrapper"
25 echo "set( CMAKE_CROSSCOMPILING_EMULATOR ${WORKDIR}/cmake-qemuwrapper)" \
26 >> ${WORKDIR}/toolchain.cmake
27 fi
28}