1# SPDX-License-Identifier: Apache-2.0
2
3# FIXME: SHADOW_VARS: Remove this once we have enabled -Wshadow globally.
4#
5# Limit warning of shadow variables to in-tree SoC files for now.
6cmake_path(IS_PREFIX ZEPHYR_BASE "${SOC_DIR}" NORMALIZE _SOC_IS_IN_TREE)
7if(_SOC_IS_IN_TREE)
8  add_compile_options($<TARGET_PROPERTY:compiler,warning_shadow_variables>)
9endif()
10unset(_SOC_IS_IN_TREE)
11
12add_subdirectory(common)
13
14if(HWMv1)
15  message(DEPRECATION "
16          ---------------------------------------------------------------------
17          --- WARNING: Functionality to describe SoCs in HWMv1 is           ---
18          --- deprecated and should be replaced with HWMv2, including       ---
19          --- boards. HWMv1 SoCs support remains only to ease the migration ---
20          --- of out-of-tree SoCs and associated boards. It will not be     ---
21          --- possible to build using HWMv1 SoCs at all in future releases. ---
22          ---------------------------------------------------------------------"
23         )
24
25  if(EXISTS ${SOC_DIR}/${ARCH}/CMakeLists.txt)
26    add_subdirectory(${SOC_DIR}/${ARCH} soc/${ARCH})
27  else()
28    add_subdirectory(${SOC_DIR}/${ARCH}/${SOC_PATH} soc/${ARCH}/${SOC_PATH})
29  endif()
30elseif(HWMv2)
31  # Below is inclusion of HWMv2 SoC CMake lists.
32  string(TOUPPER SOC_FAMILY_${SOC_FAMILY}_DIR family_setting_dir)
33  string(TOUPPER SOC_SERIES_${SOC_SERIES}_DIR series_setting_dir)
34  string(TOUPPER SOC_${SOC_NAME}_DIR soc_setting_dir)
35
36  if(DEFINED ${soc_setting_dir})
37    add_subdirectory(${${soc_setting_dir}} soc/${SOC_NAME})
38  elseif(DEFINED ${series_setting_dir})
39    add_subdirectory(${${series_setting_dir}} soc/${SOC_SERIES})
40  elseif(DEFINED ${family_setting_dir})
41    add_subdirectory(${${family_setting_dir}} soc/${SOC_FAMILY})
42  else()
43    message(FATAL_ERROR "No CMakeLists.txt file found for SoC: ${SOC_NAME}, "
44                        "series: ${SOC_SERIES}, family: ${SOC_FAMILY}")
45  endif()
46
47  # Include all SoC roots except Zephyr, as we are already in the Zephyr SoC root.
48  set(local_soc_root ${SOC_ROOT})
49  list(REMOVE_ITEM local_soc_root ${ZEPHYR_BASE})
50  foreach(root ${local_soc_root})
51    cmake_path(GET root FILENAME name)
52    # A SoC root for HWMv1 may not contain a CMakeLists.txt file on this so
53    # let's check for existence before including.
54    if(EXISTS ${root}/soc/CMakeLists.txt)
55      add_subdirectory(${root}/soc soc/${name})
56    endif()
57  endforeach()
58endif()
59