buildsystem: reconfigure when git HEAD or current ref changes#1800
Open
nicolassanchez02 wants to merge 1 commit into
Open
buildsystem: reconfigure when git HEAD or current ref changes#1800nicolassanchez02 wants to merge 1 commit into
nicolassanchez02 wants to merge 1 commit into
Conversation
31ec13d to
3277e9e
Compare
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.
3277e9e to
e1574ac
Compare
3 tasks
Contributor
Author
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.
Merge Checklist
make checkmergePROJECT_VERSIONis set once at configure time fromgit describeand baked into config.h, so it goes stale on every commit until someone re-runs cmake by hand. This pointsCMAKE_CONFIGURE_DEPENDSat.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 globCONFIGURE_DEPENDSanyway, so tagging stays a manual reconfigure.Closes #381.