cmake: stop freezing the SVNDATE banner string at first configure - #483
Merged
Merged
Conversation
The previous logic was
if (NOT SVNDATE)
... git describe ...
set (SVNDATE 'rev. ...' CACHE STRING ... FORCE)
endif()
which behaved correctly the first time CMake ran (cache empty -> derive
from git -> set with FORCE) but broke on every subsequent configure: the
cached value made 'NOT SVNDATE' false, so the if-block was skipped and
the FORCE-cached value persisted. Result: every incremental build
thereafter embedded the revision string from the FIRST configure forever,
even after committing or switching branches. This matters because
SVNDATE is consumed by config.h.cm and version.rc.in and ends up in
the binary's --version output and the amuled startup banner.
Fix:
* Detect the distro-override case explicitly via DEFINED CACHE{SVNDATE}
so a -DSVNDATE='rev. foo' on the cmake command line still wins (used
when packaging from a tarball without .git).
* In the source-tree case, derive the value as a regular (non-cached)
variable so it refreshes on every configure.
* Add .git/HEAD as a CMAKE_CONFIGURE_DEPENDS entry so 'cmake --build'
alone re-runs configure when HEAD moves (commit, pull, checkout) —
no manual 'cmake -B build' needed to refresh the banner.
5 tasks
mrjimenez
pushed a commit
to mrjimenez/amule
that referenced
this pull request
Jul 15, 2026
…headers are missing (amule-project#483) FindReadline set HAVE_LIBREADLINE from a check_function_exists(readline) that a bare runtime library -- or libedit's readline() compatibility symbol -- also satisfies, while the header probes look only for <readline.h> / <readline/readline.h>. On a box with the library but no development headers (e.g. Alpine with libedit-dev but no readline-dev), config.h carried HAVE_LIBREADLINE with no header macro, and ExternalConnector.cpp -- which gates its rl_* block on HAVE_LIBREADLINE alone -- failed deep in the build with "rl_compentry_func_t does not name a type" and friends (amule-project#481). Require a usable header too: when the library is found but neither header is, stop at configure time with a message naming the missing package (Alpine readline-dev / Debian libreadline-dev / Fedora readline-devel / Homebrew readline) instead of a confusing mid-build error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
if (NOT SVNDATE) ... set(SVNDATE ... CACHE STRING FORCE)pattern derives the revision string fromgit describeonly on the first configure, thenFORCEs it into the cache. On every subsequent configure theif (NOT SVNDATE)is false (cache wins), so the revision string is frozen forever — every incremental rebuild after a commit / pull / branch switch still embeds the original revision inconfig.h,version.rc, and the--version/ amuled startup banner output.DEFINED CACHE{SVNDATE}so-DSVNDATE='rev. foo'on the cmake command line still wins (used when packaging from a tarball without.git). In the source-tree case, derive a regular (non-cached) variable so it refreshes on every configure..git/HEADas aCMAKE_CONFIGURE_DEPENDSentry socmake --buildalone re-runs configure when HEAD moves (commit / pull / checkout) — no manualcmake -B buildneeded to refresh the banner.Test plan
cmake -B build && cmake --build build && ./build/src/amuled --versionprints the currentgit describerev.cmake --build build(no explicit reconfigure) regenerates the version string —amuled --versionreflects the new commit.-DSVNDATE='rev. distro-foo'on the configure line is respected and survives subsequentcmake --buildinvocations..git(tarball case): build proceeds, SVNDATE remains undefined and the existing#ifdef SVNDATEconsumers fall back gracefully.