(Yet another) automatic version generation for C++ CMake projects.
- Generates version information using information from git (tags) with fallback options when building without git (e.g. when building from sources with exported archives).
- Use custom templates for generated sources (e.g. also create resource files (see examples))
- Uses semantic versioning (https://semver.org/)
- Best suited with git-flow workflows
- Generated version strings are compatible to/and can be used by debian and rpm packages.
Defines
LAST_TAG_VERSION: latest tagged version (e.g. 1.2.0 for tag v1.2.0) or 0.0.0 if no tag exists.DIST: commit count distance to latest version tag.
Version Number rules:
- on master:
X.Y.Z[-DIST] (usingLAST_TAG_VERSION), whileDISTshould always be 0 on the master branch. - on develop and other branches:
X.Y.Z-ALPHA_FLAG.DIST(usingLAST_TAG_VERSION,Yincremented by 1) - on release branches:
X.Y.Z-RC_FLAG.DIST(extractingX.Y.Zfrom release branch name or from develop as fallback).
DISTis either calculated to last version tag or to the closestrc-X.Y.Ztag. DISTis added to all version numbers, except:- Versions on master and on hotfix branches with
DISTequal to 0
- Versions on master and on hotfix branches with
- All version numbers have a pre-release identifier set, except:
- Version on master and
- versions on hotfix branches with
DISTequal to 0
- When creating the version string and the PATCH number is 0 - the patch number is omitted. (e.g. 1.2.0 will be 1.2)
Have a look at CMakeLists.txt and all fles in the examples directory.