How do I regenerate CMake component file lists?
Every component's src/CMakeLists.txt=/=tests/CMakeLists.txt include()=s
a generated =component_files.cmake instead of using
file(GLOB_RECURSE ...) — see
Replace GLOB_RECURSE with explicit source lists across the build.
A generated file is a snapshot, not a live glob: a rebase or merge
that lands new source files on components you didn't personally
touch leaves your checked-out component_files.cmake stale, and the
build fails with undefined-reference linker errors for the files it
doesn't know about yet — indistinguishable from a real bug unless you
know to check this first.
Question
How do I regenerate CMake component file lists?
Answer
After any rebase or merge onto a branch that may have added or removed source files (not just your own branch's changes) — before your next build:
python3 projects/ores.codegen/scripts/regenerate_cmake_component_files.py --all
Check what changed — if
git statusshows anycomponent_files.cmaketouched, that component gained/lost files upstream of your branch; commit the regenerated file(s) alongside your own changes:git status --short -- '**/component_files.cmake'To check for drift without writing (e.g. as a pre-build sanity check, or to confirm nothing is stale before opening a PR) — exits non-zero if anything would change:
python3 projects/ores.codegen/scripts/regenerate_cmake_component_files.py --all --check
- Symptom if you skip this after a rebase: a linker error naming a
symbol that's clearly defined somewhere in the tree (e.g.
undefined reference to `ores::nats::parse_wire_format(...)`) — the.cppdefining it exists on disk, but the stalecomponent_files.cmakefrom before the rebase never listed it. Re-run step 1 and rebuild.
Script
projects/ores.codegen/scripts/regenerate_cmake_component_files.py
— see
How do I add a new source file to a component?
for how it's implemented (the ores.cmake.component.files_src=/
=files_tests codegen archetypes).
Tested by
Manually: this exact failure mode (a rebase landing
ores.nats/domain/wire_codec.cpp from a concurrently-merged PR,
producing undefined-reference linker errors until --all was
re-run) was hit and fixed while closing
Replace GLOB_RECURSE with explicit source lists across the build.
See also
- How do I add a new source file to a component? — the single-component, single-file-add case.
- Replace GLOB_RECURSE with explicit source lists across the build — the story this recipe documents.