FairProjectConfig
Added in version 1.0.0.
Requires CMake 3.12 or later.
fair_get_git_version()
fair_get_git_version([OUTVAR_PREFIX prefix]
[TAGS_ONLY] [REQUIRED])
The function checks git attributes of the current tree. If it can’t detect anything useful (becausee Git is not installed, or because there is no git repository), it will not touch any output variables at all.
OUTVAR_PREFIXThis option sets the prefix for created variables. It defaults to
"PROJECT".TAGS_ONLYThis option tells Git to search for tags and use them as base for the returned information. If this option is not given, Git can also return a (shortened) commit hash. (Current implementation detail: not passing this option will pass
--alwaystogit describe.)REQUIREDIf no suitable information can be detected (for example
TAGS_ONLYis given, but no tags exist, or no git repository exists) then a fatal error is raised.
Output variables:
<prefix>_GIT_VERSIONA version string that is created from the output of
git describe.
Note
The function sets the output variables with set(... PARENT_SCOPE)
and only if it detected a version. Standard CMake variable scoping
rules apply.
A project can therefore let its users provide a fallback version
(for example when building from a tarball without Git metadata) by
documenting its <prefix> and accepting
cmake -D<prefix>_GIT_VERSION=3.1.4 ...
The fallback does not work together with the REQUIRED option.
A detected Git version takes precedence over the fallback.