Skip to content

Document how to use GetGitRevisionDescription "offline" #57

@alerque

Description

@alerque

I am not a CMake expert; I'm far more accustomed to raw GNU Make. One of the idioms I usually bake into build systems is automatic version updating such that the version string is determined from git tags and updated on each commit. This works great for simplifying release workflows, and as long as everybody (including automated deployments, etc.) builds from git working trees it works great.

For more traditional software release paradigms where a source tarball is distributed, this is a little more complicated. Since people will not always be building from a git working tree but may be working from a source tarball, one has to include a fallback to determine the version number.

Using GNU Make based builds I know how to do this by bundling a version file with the latest string into the source, and falling back to reading it in the event git is not available. This way make dist or whatever will produce a tarball with an internal data file that can be read in lieu of git describe.

I am trying to contribute a similar workflow to a project that uses CMake. I've successfully included GetGitRevisionDescription from this repository and adapted the build to fetch the version string and define project() using it.

include(GetGitRevisionDescription)
git_describe(GIT_VERSION --tags --always)
string(REGEX REPLACE "-([0-9]*).*" ".\\1" VERSION "${GIT_VERSION}")
project (myproject
	VERSION "${VERSION}")

What I can't figure out is where and how I should cache this project data such that the project can also be build from source tarballs.

It would be nice to see the documentation comments for GetGitRevisionDescription include some notes on the best way to go about using it "offline".

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions