1# SPDX-License-Identifier: Apache-2.0 2# 3# Copyright (c) 2022, Nordic Semiconductor ASA 4 5# 6# This CMake module is only valid for hw model v1. 7# In hw model v1, then arch is determined by the board folder structure. 8# 9# Configure ARCH settings based on board directory and arch root. 10# 11# This CMake module will set the following variables in the build system based 12# on board directory and arch root. 13# 14# If no implementation is available for the current arch an error will be raised. 15# 16# Outcome: 17# The following variables will be defined when this CMake module completes: 18# 19# - ARCH: Name of the arch in use. 20# - ARCH_DIR: Directory containing the arch implementation. 21# - ARCH_ROOT: ARCH_ROOT with ZEPHYR_BASE appended 22# 23# Variable dependencies: 24# - ARCH_ROOT: CMake list of arch roots containing arch implementations 25# - BOARD_DIR: CMake variable specifying the directory of the selected BOARD 26# 27# Variables set by this module and not mentioned above are considered internal 28# use only and may be removed, renamed, or re-purposed without prior notice. 29 30include_guard(GLOBAL) 31 32if(HWMv1) 33 # 'ARCH_ROOT' is a prioritized list of directories where archs may be 34 # found. It always includes ${ZEPHYR_BASE} at the lowest priority (except for unittesting). 35 if(NOT unittest IN_LIST Zephyr_FIND_COMPONENTS) 36 list(APPEND ARCH_ROOT ${ZEPHYR_BASE}) 37 endif() 38 39 cmake_path(GET BOARD_DIR PARENT_PATH board_arch_dir) 40 cmake_path(GET board_arch_dir FILENAME ARCH) 41 42 foreach(root ${ARCH_ROOT}) 43 if(EXISTS ${root}/arch/${ARCH}/CMakeLists.txt) 44 set(ARCH_DIR ${root}/arch) 45 break() 46 endif() 47 endforeach() 48 49 if(NOT ARCH_DIR) 50 message(FATAL_ERROR "Could not find ARCH=${ARCH} for BOARD=${BOARD}, \ 51please check your installation. ARCH roots searched: \n\ 52${ARCH_ROOT}") 53 endif() 54endif() 55