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
    <choice> (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 <raiden00@railab.me>
This commit is contained in:
raiden00pl
2025-02-22 13:49:44 +01:00
committed by Xiang Xiao
parent e0b221016f
commit 1178bf4c57

View File

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