How do I hard code a version number into a cmake cpack with dynamic version number

Viewed 188

I have a CMakeLists.txt that specifies the project without a hard coded version number:

project (project_name C CXX)

Then a little further down includes a script and uses a function to figure out the version number based on git describe:

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

The result is lovely for building the project from the git repository using cmake, tagged commits have the right version, HEAD builds after that have an extra field (tweak version) with a counter for commits since the last tag.

The trouble is when using CPack to bundle a source tarball, the CMakeLists.txt in the tarball no longer has a way to determine it's own version (to .git directory and all that).

How do I change the generated CMakeLists.txt in the tarball to have a hard coded version number?

0 Answers
Related