CMakeVersion: Preserve Git information during 'git archive'

Use `export-subst` to get information about the Git commit used to
produce an archive.
This commit is contained in:
Brad King
2019-07-25 09:17:53 -04:00
parent 0505a66cbf
commit fe2c558ba6
2 changed files with 5 additions and 0 deletions

View File

@@ -1,2 +1,4 @@
CMakeVersion.cmake export-subst
# Do not format third-party sources.
/kwsys/** -format.clang-format-6.0

View File

@@ -39,6 +39,9 @@ if(COMMAND _git)
# Get the commit checked out in this work tree.
_git(log -n 1 HEAD "--pretty=format:%h %s" --)
set(git_info "${_git_out}")
else()
# Get the commit exported by 'git archive'.
set(git_info [==[$Format:%h %s$]==])
endif()
# Extract commit information if available.