zephyr/cmake/modules/root.cmake

42 lines
1.5 KiB
CMake
Raw Normal View History

# SPDX-License-Identifier: Apache-2.0
#
# Copyright (c) 2021, Nordic Semiconductor ASA
# Convert Zephyr roots to absolute paths.
#
# This CMake module will convert all relative paths in existing ROOT lists to
# absolute path relative from APPLICATION_SOURCE_DIR.
#
# Optional variables:
# - ARCH_ROOT: CMake list of arch roots containing arch implementations
# - SOC_ROOT: CMake list of SoC roots containing SoC implementations
# - BOARD_ROOT: CMake list of board roots containing board and shield implementations
# - MODULE_EXT_ROOT: CMake list of module external roots containing module glue code
#
# If a root is defined it will check the list of paths in the root and convert
# any relative path to absolute path and update the root list.
# If a root is undefined it will still be undefined when this module has loaded.
include_guard(GLOBAL)
include(extensions)
# Convert paths to absolute, relative from APPLICATION_SOURCE_DIR
zephyr_file(APPLICATION_ROOT MODULE_EXT_ROOT)
# Convert paths to absolute, relative from APPLICATION_SOURCE_DIR
zephyr_file(APPLICATION_ROOT BOARD_ROOT)
# Convert paths to absolute, relative from APPLICATION_SOURCE_DIR
zephyr_file(APPLICATION_ROOT SOC_ROOT)
# Convert paths to absolute, relative from APPLICATION_SOURCE_DIR
zephyr_file(APPLICATION_ROOT ARCH_ROOT)
cmake: kconfig: introduce dedicated unit testing board This commit introduces a dedicated unit testing board. Today, a dedicated Zephyr unit testing scheme exists but is different from how a Zephyr build generally works. For example Kconfig is not possible, resulting on various different hacks to pass Kconfig settings from test cases / testcase.yaml through CMake to the code. Some directly as compile definitions, some as header files with forced inclusion on sources, some with wrapper flags which again results in different define being enabled. There is even cases where a second forced header inclusion undefines previous defines. Unit test often does a manual check for the right boards, like this: > if (NOT BOARD STREQUAL unit_testing) > message(FATAL_ERROR "This project can only be used with...") > endif() Introducing a dedicated unit_testing board under `tests/root` allows us to use Kconfig in unit test samples, and thus proper `prj.conf` and extra Kconfig fragments. Generation of autoconf.h so the overall architecture follows regular Zephyr builds. Proper and uniform error messages when invalid board is selected. The unit_testing board and arch is located under: `subsys/testsuite` so that it is only available when find_package(Zephyr COMPONENTS unittest) is used, and not available for regular Zephyr builds. Kconfig generates autoconf.h which is applied as compile flag to test binary which means that kconfig defines placed in ztest.h can now be removed. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2022-08-05 17:09:26 +08:00
if(unittest IN_LIST Zephyr_FIND_COMPONENTS)
# Zephyr used in unittest mode, use dedicated unittest root.
set(BOARD_ROOT ${ZEPHYR_BASE}/subsys/testsuite)
set(ARCH_ROOT ${ZEPHYR_BASE}/subsys/testsuite)
set(SOC_ROOT ${ZEPHYR_BASE}/subsys/testsuite)
endif()