1# SPDX-License-Identifier: Apache-2.0 2# 3# Copyright (c) 2021, Nordic Semiconductor ASA 4 5# Configure SoC settings based on Kconfig settings and SoC root. 6# 7# This CMake module will set the following variables in the build system based 8# on Kconfig settings and selected SoC. 9# 10# If no implementation is available for the selected SoC an error will be raised. 11# 12# Outcome: 13# The following variables will be defined when this CMake module completes: 14# 15# - SOC_NAME: Name of the SoC in use, identical to CONFIG_SOC 16# - SOC_SERIES: Name of the SoC series in use, identical to CONFIG_SOC_SERIES 17# - SOC_FAMILY: Name of the SoC family, identical to CONFIG_SOC_FAMILY 18# - SOC_PATH: Path fragment defined by either SOC_NAME or SOC_FAMILY/SOC_SERIES. 19# - SOC_DIR: Directory containing the SoC implementation 20# - SOC_ROOT: SOC_ROOT with ZEPHYR_BASE appended 21# 22# Variable dependencies: 23# - SOC_ROOT: CMake list of SoC roots containing SoC implementations 24# 25# Variables set by this module and not mentioned above are considered internal 26# use only and may be removed, renamed, or re-purposed without prior notice. 27 28include_guard(GLOBAL) 29 30include(kconfig) 31 32if(HWMv1) 33 # 'SOC_ROOT' is a prioritized list of directories where socs may be 34 # found. It always includes ${ZEPHYR_BASE}/soc at the lowest priority. 35 list(APPEND SOC_ROOT ${ZEPHYR_BASE}) 36 37 set(SOC_NAME ${CONFIG_SOC}) 38 set(SOC_SERIES ${CONFIG_SOC_SERIES}) 39 set(SOC_TOOLCHAIN_NAME ${CONFIG_SOC_TOOLCHAIN_NAME}) 40 set(SOC_FAMILY ${CONFIG_SOC_FAMILY}) 41 42 if("${SOC_SERIES}" STREQUAL "") 43 set(SOC_PATH ${SOC_NAME}) 44 else() 45 set(SOC_PATH ${SOC_FAMILY}/${SOC_SERIES}) 46 endif() 47 48 # Use SOC to search for a 'CMakeLists.txt' file. 49 # e.g. zephyr/soc/xtensa/intel_adsp/CMakeLists.txt. 50 foreach(root ${SOC_ROOT}) 51 # Check that the root looks reasonable. 52 if(NOT IS_DIRECTORY "${root}/soc") 53 message(WARNING "\nSOC_ROOT element(s) without a 'soc' subdirectory: 54 ${root} 55 Hints: 56 - if your SoC family directory is '/foo/bar/soc/<ARCH>/my_soc_family', then add '/foo/bar' to SOC_ROOT, not the entire SoC family path 57 - if in doubt, use absolute paths\n") 58 endif() 59 60 if(EXISTS ${root}/soc/${ARCH}/${SOC_PATH}) 61 set(SOC_DIR ${root}/soc) 62 break() 63 endif() 64 endforeach() 65 66 if(NOT SOC_DIR) 67 message(FATAL_ERROR "Could not find SOC=${SOC_NAME} for BOARD=${BOARD},\n" 68 "please check your installation.\n" 69 "SOC roots searched:\n" 70 "${SOC_ROOT}\n" 71 ) 72 endif() 73 74 set(SOC_FULL_DIR ${SOC_DIR}/${ARCH}/${SOC_PATH}) 75endif() 76