diff options
| author | Jacob McDonnell <jacob@jacobmcdonnell.com> | 2026-02-26 19:45:16 -0500 |
|---|---|---|
| committer | Jacob McDonnell <jacob@jacobmcdonnell.com> | 2026-02-26 19:45:16 -0500 |
| commit | 8edb6adb91191ef329b6044ea298d74b11c7835d (patch) | |
| tree | 62f6520f549527b2fbbde10f479f156d01849262 | |
| parent | fae96ecc9db4080c009274e6c7e002e2c05e5d3f (diff) | |
fix: No Longer Resourcing Defconfig during build
When building, the cmake environment would rerun the configuration
stage, including sourcing the original defconfig and overriding the
local .config. Now the config.cmake is generated when the defconfig is
sourced, and if it exists already, then the defconfig is ignored.
| -rw-r--r-- | cmake/Kconfig.cmake | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/cmake/Kconfig.cmake b/cmake/Kconfig.cmake index 232a11f..47f8295 100644 --- a/cmake/Kconfig.cmake +++ b/cmake/Kconfig.cmake @@ -7,25 +7,44 @@ set(TOOL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tools) set(KCONFIG_DIR ${TOOL_DIR}/Kconfiglib) set(LOCAL_CONFIG ${CMAKE_CURRENT_SOURCE_DIR}/.config) -if(DEFCONFIG) +if(DEFCONFIG AND NOT EXISTS ${CMAKE_BINARY_DIR}/config.cmake) execute_process( COMMAND ${KCONFIG_DIR}/defconfig.py ${CMAKE_CURRENT_SOURCE_DIR}/configs/${DEFCONFIG} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) + + execute_process( + COMMAND ${KCONFIG_DIR}/genconfig.py --header-path ${CMAKE_BINARY_DIR}/generated.h --config-out + ${CMAKE_BINARY_DIR}/config.make + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + + execute_process( + COMMAND ${TOOL_DIR}/make-cmake-config ${CMAKE_BINARY_DIR}/config.make + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + + set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS + ${CMAKE_BINARY_DIR}/config.cmake + ) + +elseif(EXISTS ${CMAKE_BINARY_DIR}/config.cmake) + message("Ignoring DEFCONFIG") else() message(FATAL_ERROR "DEFCONFIG not set.") endif() +include(${CMAKE_BINARY_DIR}/config.cmake) + add_custom_target(menuconfig COMMAND ${KCONFIG_DIR}/menuconfig.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) -add_custom_target(genconfig +add_custom_command(TARGET menuconfig POST_BUILD COMMAND ${KCONFIG_DIR}/genconfig.py --header-path ${CMAKE_BINARY_DIR}/generated.h --config-out ${CMAKE_BINARY_DIR}/config.make COMMAND ${TOOL_DIR}/make-cmake-config ${CMAKE_BINARY_DIR}/config.make - COMMAND cmake -B ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) |
