1# SPDX-License-Identifier: Apache-2.0 2# 3# Copyright (c) 2021-2023, Nordic Semiconductor ASA 4 5# Convert Zephyr roots to absolute paths. 6# 7# This CMake module will convert all relative paths in existing ROOT lists to 8# absolute path relative from APPLICATION_SOURCE_DIR. 9# 10# Optional variables: 11# - ARCH_ROOT: CMake list of arch roots containing arch implementations 12# - SOC_ROOT: CMake list of SoC roots containing SoC implementations 13# - BOARD_ROOT: CMake list of board roots containing board and shield implementations 14# - MODULE_EXT_ROOT: CMake list of module external roots containing module glue code 15# - SCA_ROOT: CMake list of SCA roots containing static code analysis integration code 16# - DTS_ROOT: CMake list of DTS roots containing device tree bindings or includes 17# 18# If a root is defined it will check the list of paths in the root and convert 19# any relative path to absolute path and update the root list. 20# If a root is undefined it will still be undefined when this module has loaded. 21 22include_guard(GLOBAL) 23 24include(extensions) 25 26# Merge in variables from other sources (e.g. sysbuild) 27zephyr_get(MODULE_EXT_ROOT MERGE SYSBUILD GLOBAL) 28zephyr_get(BOARD_ROOT MERGE SYSBUILD GLOBAL) 29zephyr_get(SOC_ROOT MERGE SYSBUILD GLOBAL) 30zephyr_get(ARCH_ROOT MERGE SYSBUILD GLOBAL) 31zephyr_get(SCA_ROOT MERGE SYSBUILD GLOBAL) 32zephyr_get(SNIPPET_ROOT MERGE SYSBUILD GLOBAL) 33zephyr_get(DTS_ROOT MERGE SYSBUILD GLOBAL) 34 35# Convert paths to absolute, relative from APPLICATION_SOURCE_DIR 36zephyr_file(APPLICATION_ROOT MODULE_EXT_ROOT) 37zephyr_file(APPLICATION_ROOT BOARD_ROOT) 38zephyr_file(APPLICATION_ROOT SOC_ROOT) 39zephyr_file(APPLICATION_ROOT ARCH_ROOT) 40zephyr_file(APPLICATION_ROOT SCA_ROOT) 41zephyr_file(APPLICATION_ROOT SNIPPET_ROOT) 42zephyr_file(APPLICATION_ROOT DTS_ROOT) 43 44if(unittest IN_LIST Zephyr_FIND_COMPONENTS) 45 # Zephyr used in unittest mode, use dedicated unittest root. 46 set(BOARD_ROOT ${ZEPHYR_BASE}/subsys/testsuite) 47 set(ARCH_ROOT ${ZEPHYR_BASE}/subsys/testsuite) 48 set(SOC_ROOT ${ZEPHYR_BASE}/subsys/testsuite) 49endif() 50