From 1178bf4c57ff6b6fce6a9196c3839ca88cab12d9 Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Sat, 22 Feb 2025 13:49:44 +0100 Subject: [PATCH] CMakeLists.txt: fix warnings when using upstream boards in out-of-tree configs When we use upstream board as a target in out-of-tree board configurations we should not link dummy/Kconfig with a board Kconfig otherwise this file is included twice which cause cmake warnings. For example, when out-of-tree configuration is like this: CONFIG_ARCH_BOARD_CUSTOM=y CONFIG_ARCH_BOARD_CUSTOM_DIR="boards/arm/stm32/b-g431b-esc1/" CONFIG_ARCH_BOARD_CUSTOM_DIR_RELPATH=y CONFIG_ARCH_BOARD_CUSTOM_NAME="b-g431b-esc1" this results with many warnings during configuration stage: CMake Warning at cmake/nuttx_kconfig.cmake:171 (message): Kconfig Configuration Error: warning: the default selection BOARD_STM32_BG431BESC1_USE_HSI (defined at boards/arm/stm32/b-g431b-esc1/Kconfig:12, /home/raiden00/git/railab/dawn/build_esc1/boards/dummy/Kconfig:12) of (defined at boards/arm/stm32/b-g431b-esc1/Kconfig:8) is not contained in the choice warning: the choice symbol BOARD_STM32_BG431BESC1_USE_HSI (defined at boards/arm/stm32/b-g431b-esc1/Kconfig:12, /home/raiden00/git/railab/dawn/build_esc1/boards/dummy/Kconfig:12) is defined with a prompt outside the choice warning: the choice symbol BOARD_STM32_BG431BESC1_USE_HSE (defined at boards/arm/stm32/b-g431b-esc1/Kconfig:15, /home/raiden00/git/railab/dawn/build_esc1/boards/dummy/Kconfig:15) is defined with a prompt outside the choice warning: the choice symbol BOARD_STM32_BG431BESC1_USE_HSI (defined at boards/arm/stm32/b-g431b-esc1/Kconfig:12, /home/raiden00/git/railab/dawn/build_esc1/boards/dummy/Kconfig:12) is defined with a prompt outside the choice warning: the choice symbol BOARD_STM32_BG431BESC1_USE_HSE (defined at boards/arm/stm32/b-g431b-esc1/Kconfig:15, /home/raiden00/git/railab/dawn/build_esc1/boards/dummy/Kconfig:15) is defined with a prompt outside the choice Signed-off-by: raiden00pl --- CMakeLists.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ae45cdb2ea..ec6a3a0e56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -250,8 +250,16 @@ else() file(TOUCH ${CMAKE_BINARY_DIR}/boards/dummy/Kconfig) endif() +# check if board custom dir points to NuttX upstream board. This is useful when +# an out-of-tree configuration uses an upstream board directory +string(FIND "${CONFIG_ARCH_BOARD_CUSTOM_DIR}" "boards/" IS_NUTTX_BOARD) + if(NOT EXISTS ${CMAKE_BINARY_DIR}/boards/dummy/Kconfig) - if(CONFIG_ARCH_BOARD_CUSTOM AND EXISTS ${NUTTX_BOARD_ABS_DIR}/Kconfig) + # link dummy/Kconfig only if this is not upstream board otherwise the same + # Kconfig file is included twice which cause CMake warnings + if(CONFIG_ARCH_BOARD_CUSTOM + AND EXISTS ${NUTTX_BOARD_ABS_DIR}/Kconfig + AND NOT (IS_NUTTX_BOARD EQUAL 0)) nuttx_create_symlink(${NUTTX_BOARD_ABS_DIR}/Kconfig ${CMAKE_BINARY_DIR}/boards/dummy/Kconfig) else()