Skip to content

cmake: reconfigure when .config changes - #20085

Open
r3wretrhy wants to merge 1 commit into
apache:masterfrom
r3wretrhy:cmake-reconfigure-dotconfig
Open

cmake: reconfigure when .config changes#20085
r3wretrhy wants to merge 1 commit into
apache:masterfrom
r3wretrhy:cmake-reconfigure-dotconfig

Conversation

@r3wretrhy

Copy link
Copy Markdown
Contributor

cmake: reconfigure when .config changes.

Summary

  • Why change is necessary: config.h and CONFIG_* are generated at configure time. kconfig-tweak (and other out-of-band .config edits) do not go through the menuconfig target, so Ninja left a stale include/nuttx/config.h.
  • What functional part of the code is being changed: CMakeLists.txt configure-depends for ${NUTTX_BINARY_DIR}/.config.
  • How: CMAKE_CONFIGURE_DEPENDS on .config. That file is only rewritten when it is missing or the board defconfig path changes, so watching it does not loop.
  • Related NuttX Issue: cmake system fails to update config.h #12322

Impact

  • Is new feature added? Is existing feature changed? NO
  • Impact on user (will user need to adapt to change)? NO
  • Impact on build (will build process change)? YES. Ninja re-runs CMake after an out-of-band .config edit, which is what the reporter expected (Re-running CMake...).
  • Impact on hardware (will arch(s) / board(s) / driver(s) change)? NO
  • Impact on documentation (is update required / provided)? NO
  • Impact on security (any sort of implications)? NO
  • Impact on compatibility (backward/forward/interoperability)? NO. Unchanged .config still does not reconfigure.

Testing

I confirm that changes are verified on local setup and works as intended:

  • Build Host(s): Windows 11, CMake 3.29.2, Ninja
  • Target(s): cmake -P lock that CMakeLists.txt watches .config; a Ninja mini-project with the same CMAKE_CONFIGURE_DEPENDS one-liner

Testing logs before change:

gh search code repo:apache/nuttx CMAKE_CONFIGURE_DEPENDS
[]

Testing logs after change:

cmake -P _tmp_test_cfgdep.cmake
-- CMAKELISTS_WATCHES_DOTCONFIG

cmake --build mini/b   # after editing watched.txt
[0/1] Re-running CMake...
-- Configuring done (0.0s)
-- Generating done (0.0s)

PR verification Self-Check

  • This PR introduces only one functional change.
  • I have updated all required description fields above.
  • My PR adheres to Contributing Guidelines and Documentation (git commit title and message, coding standard, etc).
  • My PR is still work in progress (not ready for review).
  • My PR is ready for review and can be safely merged into a codebase.

@github-actions github-actions Bot added Area: Build system Size: XS The size of the change in this PR is very small labels Sep 8, 2026
config.h and CONFIG_* are produced at configure time. kconfig-tweak
edits .config without going through the menuconfig target, so Ninja
left a stale header. Watch .config with CMAKE_CONFIGURE_DEPENDS.

Fixes apache#12322

Signed-off-by: Zhaoqi Xu <lzy00419@outlook.com>
@r3wretrhy
r3wretrhy force-pushed the cmake-reconfigure-dotconfig branch from ceefcf5 to eea9508 Compare September 8, 2026 00:46
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Build system Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants