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
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)