cmake: cleanup and simplify the standard include logic in Zephyr

Several paths are checked for existence before added as global Zephyr
include path.

The existence check was needed because some tooling emit warnings on
non-existing paths.

Only few SoCs are using those pre-defined paths, yet this code runs
for all SoCs. The principle originates back from Kbuild days, and with
CMake it's more common and generally more visible to let the CMake code
defining libraries to specify include paths.

Furthermore it appears that several SoC implementation following the
<soc-path>/include was unaware that the path would be automatically
added as include path, cause they contain lines like:
    zephyr_library_include_directories(include)

Remove pre-defineds path except the `<SOC_PATH>` path, which is
guaranteed to exists.
This simplifies the CMake logic in the top-level Zephyr CMakeLists.txt
file.

This cleanup further prepares for future work where SoCs need not to
be organised under architectures which is important for multi-arch SoCs.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2023-10-30 11:18:51 +01:00 committed by Anas Nashif
parent 30fe8702de
commit ba7e6fa69f
11 changed files with 16 additions and 16 deletions

View file

@ -118,19 +118,7 @@ zephyr_include_directories(
include(${ZEPHYR_BASE}/cmake/linker_script/${ARCH}/linker.cmake OPTIONAL)
# Don't add non-existing include directories, it creates noise and
# warnings in some tooling
foreach(optional_include_dir
${SOC_DIR}/${ARCH}/${SOC_PATH}
${SOC_DIR}/${ARCH}/${SOC_PATH}/include
${SOC_DIR}/${ARCH}/${SOC_PATH}/include/${SOC_NAME}
${SOC_DIR}/${ARCH}/${SOC_FAMILY}/include
${SOC_DIR}/${ARCH}/${SOC_FAMILY}/common/include
)
if(EXISTS ${optional_include_dir})
zephyr_include_directories(${optional_include_dir})
endif()
endforeach()
zephyr_include_directories(${SOC_DIR}/${ARCH}/${SOC_PATH})
# Don't inherit compiler flags from the environment
foreach(var AFLAGS CFLAGS CXXFLAGS CPPFLAGS LDFLAGS)

View file

@ -1,3 +1,4 @@
# SPDX-License-Identifier: Apache-2.0
zephyr_include_directories(include)
set(SOC_LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld CACHE INTERNAL "")

View file

@ -1,3 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
zephyr_include_directories(include)
set(SOC_LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld CACHE INTERNAL "")

View file

@ -1,5 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
zephyr_include_directories(include)
zephyr_library_sources_ifdef(CONFIG_XTENSA_MMU mmu.c)
set(SOC_LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/include/xtensa-dc233c.ld CACHE INTERNAL "")

View file

@ -10,3 +10,4 @@ endif()
if(CONFIG_INTEL_ADSP_CAVS)
add_subdirectory(cavs)
endif()
zephyr_include_directories(common/include)

View file

@ -13,6 +13,8 @@ zephyr_library_sources(
boot.c
)
zephyr_include_directories(include)
zephyr_include_directories(include/${SOC_NAME})
zephyr_library_sources_ifdef(CONFIG_SOC_INTEL_COMM_WIDGET comm_widget.c)
zephyr_library_sources_ifdef(CONFIG_SOC_INTEL_COMM_WIDGET comm_widget_messages.c)

View file

@ -3,7 +3,8 @@
# Copyright (c) 2022 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
zephyr_library_include_directories(include)
zephyr_include_directories(include)
zephyr_include_directories(include/${SOC_NAME})
zephyr_library_include_directories(${ZEPHYR_BASE}/drivers)
zephyr_library_sources(

View file

@ -6,7 +6,7 @@
zephyr_interface_library_named(INTEL_ADSP_COMMON)
zephyr_library_named(intel_adsp_common)
zephyr_library_include_directories(include)
zephyr_include_directories(include)
zephyr_library_include_directories(${ZEPHYR_BASE}/drivers)
zephyr_library_sources_ifdef(CONFIG_INTEL_ADSP_IPC ipc.c)

View file

@ -8,6 +8,7 @@ if(CONFIG_SOC_NXP_RT595)
endif()
add_subdirectory(common)
zephyr_include_directories(${SOC_SERIES}/include)
# west sign

View file

@ -3,10 +3,11 @@
# Copyright (c) 2021 NXP
# SPDX-License-Identifier: Apache-2.0
zephyr_include_directories(include)
zephyr_interface_library_named(NXP_ADSP_COMMON)
zephyr_library_named(nxp_adsp_common)
zephyr_library_include_directories(include)
zephyr_library_include_directories(${ZEPHYR_BASE}/drivers)
zephyr_library_sources(soc.c)

View file

@ -1,3 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
zephyr_include_directories(include)
set(SOC_LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/include/xtensa-sample-controller.ld CACHE INTERNAL "")