From fe2c558ba66dd6a12cf9289adf692c9a76c71ef4 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 25 Jul 2019 09:17:53 -0400 Subject: CMakeVersion: Preserve Git information during 'git archive' Use `export-subst` to get information about the Git commit used to produce an archive. --- Source/.gitattributes | 2 ++ Source/CMakeVersion.cmake | 3 +++ 2 files changed, 5 insertions(+) diff --git a/Source/.gitattributes b/Source/.gitattributes index 7c160cc..d0aedc2 100644 --- a/Source/.gitattributes +++ b/Source/.gitattributes @@ -1,2 +1,4 @@ +CMakeVersion.cmake export-subst + # Do not format third-party sources. /kwsys/** -format.clang-format-6.0 diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 32a40f9..193c14f 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -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. -- cgit v0.12