cmake:adapt BOARD_CONFIG absolute paths and relative paths when reconfig

Define `NUTTX_DEFCONFIG` and `NUTTX_BOARD_ABS_DIR` instead of `BOARD_CONFIG`

when reconfiguring a custom configuration,
because ${BOARD_CONFIG} uses a relative path,
it will cause the following error:
CMake Error at CMakeLists.txt:134 (message)
  No config file found at

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
This commit is contained in:
xuxin19 2024-02-04 21:42:05 +08:00 committed by Xiang Xiao
parent 3e5d558f4c
commit 92987708ec
1 changed files with 7 additions and 2 deletions

View File

@ -84,7 +84,12 @@ if(NOT KCONFIGLIB)
$ pip install kconfiglib")
endif()
if(EXISTS ${BOARD_CONFIG} AND EXISTS ${BOARD_CONFIG}/defconfig)
# BOARD CONFIG can be set to directory path, or <board-name>[/:]<config-name>
# configuration pair
if((EXISTS ${BOARD_CONFIG} AND EXISTS ${BOARD_CONFIG}/defconfig)
OR (EXISTS ${NUTTX_DIR}/${BOARD_CONFIG}
AND EXISTS ${NUTTX_DIR}/${BOARD_CONFIG}/defconfig))
get_filename_component(NUTTX_BOARD_ABS_DIR ${BOARD_CONFIG} ABSOLUTE BASE_DIR
${NUTTX_DIR})
@ -103,7 +108,7 @@ if(EXISTS ${BOARD_CONFIG} AND EXISTS ${BOARD_CONFIG}/defconfig)
string(REGEX REPLACE "(.*)/(.*)/${NUTTX_CONFIG}" "\\1" NUTTX_BOARD_DIR
${NUTTX_BOARD_ABS_DIR})
set(NUTTX_DEFCONFIG ${BOARD_CONFIG}/defconfig)
set(NUTTX_DEFCONFIG ${NUTTX_BOARD_ABS_DIR}/defconfig)
else()
if(BOARD_CONFIG MATCHES "/")
set(MATCH_REGEX "/")