Rather than failing the build when it can't determine a version number, the build system should have a fallback (which should probably be something like vNEXT-rc, so bug reports built from that build system can be identified).
Any system-specific versionings (like debians changelog) should be parsed in the system-specific build instruction, and the result passed as environment variable or similar. cmake can then check its presense.
Order or precedence (First one that produces a non-empty string wins)
cmake -DDSPDFVIEWER_VERSION=1.2.3.4
If the directory .git exists, run git describe
System specific, given in environment variable
fallback version number, in CMakeLists.txt.
Update this on a release tag to the current version number, and immediatly after to "something higher".
The fallback mechanic can be tested by doing something along the lines of
TEMPDIR=$(mktemp -d)
git archive HEAD | tar -C $TEMPDIR -x && \
cd $TEMPDIR && \
mkdir build && \
cd build && \
cmake .. && \
make
Rather than failing the build when it can't determine a version number, the build system should have a fallback (which should probably be something like
vNEXT-rc
, so bug reports built from that build system can be identified).Any system-specific versionings (like debians changelog) should be parsed in the system-specific build instruction, and the result passed as environment variable or similar. cmake can then check its presense.
Order or precedence (First one that produces a non-empty string wins)
cmake -DDSPDFVIEWER_VERSION=1.2.3.4
.git
exists, rungit describe
CMakeLists.txt
.The fallback mechanic can be tested by doing something along the lines of