blob: 76b748f340688c298c9e881445f5b6f7a598b63f [file] [log] [blame]
Patrick Williamsda295312023-12-05 16:48:56 -06001#
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}