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
14# Below is inclusion of HWMv2 SoC CMake lists.
15string(TOUPPER SOC_FAMILY_${SOC_FAMILY}_DIR family_setting_dir)
16string(TOUPPER SOC_SERIES_${SOC_SERIES}_DIR series_setting_dir)
17string(TOUPPER SOC_${SOC_NAME}_DIR soc_setting_dir)
18
19if(DEFINED ${soc_setting_dir})
20  add_subdirectory(${${soc_setting_dir}} soc/${SOC_NAME})
21elseif(DEFINED ${series_setting_dir})
22  add_subdirectory(${${series_setting_dir}} soc/${SOC_SERIES})
23elseif(DEFINED ${family_setting_dir})
24  add_subdirectory(${${family_setting_dir}} soc/${SOC_FAMILY})
25else()
26  message(FATAL_ERROR "No CMakeLists.txt file found for SoC: ${SOC_NAME}, "
27                      "series: ${SOC_SERIES}, family: ${SOC_FAMILY}")
28endif()
29
30# Include all SoC roots except Zephyr, as we are already in the Zephyr SoC root.
31set(local_soc_root ${SOC_ROOT})
32list(REMOVE_ITEM local_soc_root ${ZEPHYR_BASE})
33foreach(root ${local_soc_root})
34  cmake_path(GET root FILENAME name)
35  # A SoC root for HWMv1 may not contain a CMakeLists.txt file on this so
36  # let's check for existence before including.
37  if(EXISTS ${root}/soc/CMakeLists.txt)
38    add_subdirectory(${root}/soc soc/${name})
39  endif()
40endforeach()
41