Skip to content

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

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

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

Conversation

@nicolassanchez02
Copy link
Copy Markdown
Contributor

@nicolassanchez02 nicolassanchez02 commented May 28, 2026

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.

@nicolassanchez02 nicolassanchez02 force-pushed the feature/reconfigure-on-git-hash branch from 31ec13d to 3277e9e Compare May 29, 2026 03:55
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 SFTtech#381.
@nicolassanchez02
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.

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