Skip to content

cmake: stop freezing the SVNDATE banner string at first configure - #483

Merged
mrjimenez merged 1 commit into
amule-project:masterfrom
got3nks:fix-cmake-svndate-cache
Apr 26, 2026
Merged

cmake: stop freezing the SVNDATE banner string at first configure#483
mrjimenez merged 1 commit into
amule-project:masterfrom
got3nks:fix-cmake-svndate-cache

Conversation

@got3nks

@got3nks got3nks commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The current if (NOT SVNDATE) ... set(SVNDATE ... CACHE STRING FORCE) pattern derives the revision string from git describe only on the first configure, then FORCEs it into the cache. On every subsequent configure the if (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 in config.h, version.rc, and the --version / amuled startup banner output.
  • Fix: detect the distro-override case explicitly via 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.
  • 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.

Test plan

  • On a clean tree: cmake -B build && cmake --build build && ./build/src/amuled --version prints the current git describe rev.
  • After a commit on top: cmake --build build (no explicit reconfigure) regenerates the version string — amuled --version reflects the new commit.
  • -DSVNDATE='rev. distro-foo' on the configure line is respected and survives subsequent cmake --build invocations.
  • No .git (tarball case): build proceeds, SVNDATE remains undefined and the existing #ifdef SVNDATE consumers fall back gracefully.

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.
@mrjimenez
mrjimenez merged commit f7af54f into amule-project:master Apr 26, 2026
9 checks passed
@got3nks
got3nks deleted the fix-cmake-svndate-cache branch May 3, 2026 15:19
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants