Skip to content

Commit

Permalink
cmake:bugfix kconfig menu in cmake cannot be generated recursively
Browse files Browse the repository at this point in the history
the ${MENUCONFIG} file in the output directory is enough,
as invoking nuttx_generate_kconfig() will generate this
file in the output directory.
Since we are collecting these files recursively,
the nuttx_generate_kconfig() function of the parent directory
will be called after all the subdirectories' nuttx_generate_kconfig()
functions have been invoked.

Signed-off-by: xuxin19 <[email protected]>
  • Loading branch information
xuxin930 authored and anchao committed Nov 18, 2024
1 parent 637a0f5 commit 6d629b3
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions cmake/nuttx_kconfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -136,22 +136,31 @@ function(nuttx_generate_kconfig)
file(WRITE ${KCONFIG_OUTPUT_FILE} "menu \"${MENUDESC}\"\n")
else()
set(KCONFIG_OUTPUT_FILE ${NUTTX_APPS_BINDIR}/Kconfig)
file(
GLOB subdir
LIST_DIRECTORIES false
${NUTTX_APPS_BINDIR} ${NUTTX_APPS_BINDIR}/*_Kconfig)
foreach(dir ${subdir})
file(APPEND ${KCONFIG_OUTPUT_FILE} "source \"${dir}\"\n")
endforeach()
endif()

file(
GLOB subdir
GLOB SUB_CMAKESCRIPTS
LIST_DIRECTORIES false
${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/*/Kconfig)

foreach(dir ${subdir})
file(APPEND ${KCONFIG_OUTPUT_FILE} "source \"${dir}\"\n")
${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/*/CMakeLists.txt)

# we need to recursively generate the Kconfig menus of multi-level
# directories.
#
# when generating a Kconfig file for the current directory, it should include
# and invoke all the Kconfig files gathered from its subdirectories.
foreach(SUB_CMAKESCRIPT ${SUB_CMAKESCRIPTS})
string(REPLACE "CMakeLists.txt" "Kconfig" SUB_KCONFIG ${SUB_CMAKESCRIPT})
string(REPLACE "/" "_" MENUCONFIG ${SUB_KCONFIG})
if(WIN32)
string(REPLACE ":" "_" MENUCONFIG ${MENUCONFIG})
endif()
# check whether the subdirectory will include a generated Kconfig file.
if(EXISTS ${NUTTX_APPS_BINDIR}/${MENUCONFIG})
file(APPEND ${KCONFIG_OUTPUT_FILE}
"source \"${NUTTX_APPS_BINDIR}/${MENUCONFIG}\"\n")
elseif(EXISTS ${SUB_KCONFIG})
file(APPEND ${KCONFIG_OUTPUT_FILE} "source \"${SUB_KCONFIG}\"\n")
endif()
endforeach()

if(MENUDESC)
Expand Down

0 comments on commit 6d629b3

Please sign in to comment.