From ba7e6fa69f0bf95f79d6ec02d035dd0c3b7e72d9 Mon Sep 17 00:00:00 2001 From: Torsten Rasmussen Date: Mon, 30 Oct 2023 11:18:51 +0100 Subject: [PATCH] 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 /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 `` 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 --- CMakeLists.txt | 14 +------------- soc/nios2/nios2-qemu/CMakeLists.txt | 1 + soc/nios2/nios2f-zephyr/CMakeLists.txt | 2 ++ soc/xtensa/dc233c/CMakeLists.txt | 1 + soc/xtensa/intel_adsp/CMakeLists.txt | 1 + soc/xtensa/intel_adsp/ace/CMakeLists.txt | 2 ++ soc/xtensa/intel_adsp/cavs/CMakeLists.txt | 3 ++- soc/xtensa/intel_adsp/common/CMakeLists.txt | 2 +- soc/xtensa/nxp_adsp/CMakeLists.txt | 1 + soc/xtensa/nxp_adsp/common/CMakeLists.txt | 3 ++- soc/xtensa/sample_controller/CMakeLists.txt | 2 ++ 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5a40538598b..c29fa6885a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/soc/nios2/nios2-qemu/CMakeLists.txt b/soc/nios2/nios2-qemu/CMakeLists.txt index 66d55c6ba96..b6dd454d035 100644 --- a/soc/nios2/nios2-qemu/CMakeLists.txt +++ b/soc/nios2/nios2-qemu/CMakeLists.txt @@ -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 "") diff --git a/soc/nios2/nios2f-zephyr/CMakeLists.txt b/soc/nios2/nios2f-zephyr/CMakeLists.txt index 66d55c6ba96..789c4c81fc9 100644 --- a/soc/nios2/nios2f-zephyr/CMakeLists.txt +++ b/soc/nios2/nios2f-zephyr/CMakeLists.txt @@ -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 "") diff --git a/soc/xtensa/dc233c/CMakeLists.txt b/soc/xtensa/dc233c/CMakeLists.txt index 8108448b61d..8012661a437 100644 --- a/soc/xtensa/dc233c/CMakeLists.txt +++ b/soc/xtensa/dc233c/CMakeLists.txt @@ -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 "") diff --git a/soc/xtensa/intel_adsp/CMakeLists.txt b/soc/xtensa/intel_adsp/CMakeLists.txt index 8a3b1f01f25..2cee15bbcf6 100644 --- a/soc/xtensa/intel_adsp/CMakeLists.txt +++ b/soc/xtensa/intel_adsp/CMakeLists.txt @@ -10,3 +10,4 @@ endif() if(CONFIG_INTEL_ADSP_CAVS) add_subdirectory(cavs) endif() +zephyr_include_directories(common/include) diff --git a/soc/xtensa/intel_adsp/ace/CMakeLists.txt b/soc/xtensa/intel_adsp/ace/CMakeLists.txt index fddb595fa6d..a5aa90b59d0 100644 --- a/soc/xtensa/intel_adsp/ace/CMakeLists.txt +++ b/soc/xtensa/intel_adsp/ace/CMakeLists.txt @@ -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) diff --git a/soc/xtensa/intel_adsp/cavs/CMakeLists.txt b/soc/xtensa/intel_adsp/cavs/CMakeLists.txt index 2b5bf93a592..5226f1b0535 100644 --- a/soc/xtensa/intel_adsp/cavs/CMakeLists.txt +++ b/soc/xtensa/intel_adsp/cavs/CMakeLists.txt @@ -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( diff --git a/soc/xtensa/intel_adsp/common/CMakeLists.txt b/soc/xtensa/intel_adsp/common/CMakeLists.txt index ff09b1e4ea8..c463e4453fc 100644 --- a/soc/xtensa/intel_adsp/common/CMakeLists.txt +++ b/soc/xtensa/intel_adsp/common/CMakeLists.txt @@ -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) diff --git a/soc/xtensa/nxp_adsp/CMakeLists.txt b/soc/xtensa/nxp_adsp/CMakeLists.txt index 575c7f47cca..a0ab21fb6a8 100644 --- a/soc/xtensa/nxp_adsp/CMakeLists.txt +++ b/soc/xtensa/nxp_adsp/CMakeLists.txt @@ -8,6 +8,7 @@ if(CONFIG_SOC_NXP_RT595) endif() add_subdirectory(common) +zephyr_include_directories(${SOC_SERIES}/include) # west sign diff --git a/soc/xtensa/nxp_adsp/common/CMakeLists.txt b/soc/xtensa/nxp_adsp/common/CMakeLists.txt index 8d6294a6777..02c2ef503e3 100644 --- a/soc/xtensa/nxp_adsp/common/CMakeLists.txt +++ b/soc/xtensa/nxp_adsp/common/CMakeLists.txt @@ -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) diff --git a/soc/xtensa/sample_controller/CMakeLists.txt b/soc/xtensa/sample_controller/CMakeLists.txt index 3aff8c6b8b3..20e40128eeb 100644 --- a/soc/xtensa/sample_controller/CMakeLists.txt +++ b/soc/xtensa/sample_controller/CMakeLists.txt @@ -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 "")