New in version v21.10.00.
Generate a C++ header file that holds git revision information of the calling project.
rapids_cmake_write_git_revision_file(<target_name> file_path [PREFIX <prefix>])
Creates a global interface target called target_name that holds the includes to
the generated header with the macros for git branch, sha1, version, and if any uncommitted
changes exist. Users of the header file must use
target_link_libraries to the target
so that the header is generated before it is used.
Prefix for all the C++ macros. By default if not explicitly specified it will be equal to the projects name ( CMake variable PROJECT_NAME ).
This information will be recorded in the following defines:
<PREFIX>_GIT_BRANCH Will store the current git branch name, otherwise when in a detached HEAD state will store HEAD.
<PREFIX>_GIT_SHA1 Will store the full SHA1 for the current git commit if one exists.
<PREFIX>_GIT_IS_DIRTY Will exist if any git tracked file has any modifications that aren’t committed ( dirty ).
<PREFIX>_GIT_VERSION Will store <tag>[-<distance>-g<sha1>[-dirty]] computed from running git describe –tags –dirty –always. For example “v21.10.00a-18-g7efb04f-dirty” indicates that the latest commit is “7efb04f” but has uncommitted changes (-dirty), and that we are “18” commits after tag “v21.10.00a”.
Either an absolute or relative path. When a relative path, the absolute location will be computed from
If git doesn’t exist or the project doesn’t use git, the header will still be written. The branch, sha1, and version defines will be set to unknown and the project won’t be considered dirty.
- target_name target will be created. Consuming libraries/executables
of the generated header must use the target via
target_link_librariesfor correct builds.