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 32# 'SOC_ROOT' is a prioritized list of directories where socs may be 33# found. It always includes ${ZEPHYR_BASE}/soc at the lowest priority. 34list(APPEND SOC_ROOT ${ZEPHYR_BASE}) 35 36set(SOC_NAME ${CONFIG_SOC}) 37set(SOC_SERIES ${CONFIG_SOC_SERIES}) 38set(SOC_TOOLCHAIN_NAME ${CONFIG_SOC_TOOLCHAIN_NAME}) 39set(SOC_FAMILY ${CONFIG_SOC_FAMILY}) 40 41if("${SOC_SERIES}" STREQUAL "") 42 set(SOC_PATH ${SOC_NAME}) 43else() 44 set(SOC_PATH ${SOC_FAMILY}/${SOC_SERIES}) 45endif() 46 47# Use SOC to search for a 'CMakeLists.txt' file. 48# e.g. zephyr/soc/xtensa/intel_adsp/CMakeLists.txt. 49foreach(root ${SOC_ROOT}) 50 # Check that the root looks reasonable. 51 if(NOT IS_DIRECTORY "${root}/soc") 52 message(WARNING "\nSOC_ROOT element(s) without a 'soc' subdirectory: 53${root} 54Hints: 55 - 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 56 - if in doubt, use absolute paths\n") 57 endif() 58 59 if(EXISTS ${root}/soc/${ARCH}/${SOC_PATH}) 60 set(SOC_DIR ${root}/soc) 61 break() 62 endif() 63endforeach() 64 65if(NOT SOC_DIR) 66 message(FATAL_ERROR "Could not find SOC=${SOC_NAME} for BOARD=${BOARD},\n" 67 "please check your installation.\n" 68 "SOC roots searched:\n" 69 "${SOC_ROOT}\n" 70 ) 71endif() 72