Skip to content

buildsystem: reconfigure when git HEAD or current ref changes#1800

Closed
nickk02 wants to merge 1 commit into
SFTtech:masterfrom
nickk02:feature/reconfigure-on-git-hash
Closed

buildsystem: reconfigure when git HEAD or current ref changes#1800
nickk02 wants to merge 1 commit into
SFTtech:masterfrom
nickk02:feature/reconfigure-on-git-hash

Conversation

@nickk02

@nickk02 nickk02 commented May 28, 2026

Copy link
Copy Markdown
Contributor

Merge Checklist

PROJECT_VERSION is set once at configure time from git describe and baked into config.h, so it goes stale on every commit until someone re-runs cmake by hand. This points CMAKE_CONFIGURE_DEPENDS at .git/HEAD, the ref HEAD points to, and .git/packed-refs, so a plain make/ninja reconfigures itself on a branch switch or a new commit.

New tags won't trigger it: globbing .git/refs/tags/ scales badly once a repo has a lot of tags, and the cmake docs warn against glob CONFIGURE_DEPENDS anyway, so tagging stays a manual reconfigure.

Closes #381.

@nickk02 nickk02 force-pushed the feature/reconfigure-on-git-hash branch 2 times, most recently from 3277e9e to e1574ac Compare May 29, 2026 06:20
@nickk02

nickk02 commented May 29, 2026

Copy link
Copy Markdown
Contributor Author

The macOS-CI failure here isn't anything in this PR: configure aborts at find_package(Eigen3 3.3) rejecting the Eigen 5 the runner ships, before the build runs. That's the issue #1801 fixes. Once #1801 lands I'll rebase this onto master and the check goes green.

PROJECT_VERSION is set once during cmake configure via "git describe"
and then baked into config.h, so PROJECT_VERSION goes stale on every
commit until the user explicitly reruns cmake. Tell cmake to depend on
.git/HEAD and the file HEAD currently points at (plus .git/packed-refs
for the case where the ref has been packed). With this, switching
branches or committing on the current branch triggers a reconfigure on
the next "make" / "ninja" invocation, and the version string stays in
sync.

New tags don't trigger reconfigure here, since watching .git/refs/tags/
as a glob would scale poorly on repos with a lot of tags. Tag pushes
remain a manual-cmake situation.

Closes #381.
@nickk02 nickk02 force-pushed the feature/reconfigure-on-git-hash branch from e1574ac to 6b3394d Compare June 6, 2026 21:16
@nickk02 nickk02 closed this by deleting the head repository Jun 26, 2026
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.

Trigger reconfigure when git commit hash changes

1 participant