diff options
author | Brad King <brad.king@kitware.com> | 2020-02-13 19:27:56 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-02-13 19:27:56 (GMT) |
commit | dfe0586c6d8f304e8e30acf97d27581088265533 (patch) | |
tree | 20b33de1137c548c59a842c804dbefa50569f513 /src/Version.cmake | |
parent | e5008ad993bd20e9bfd91e06748357734cc151d2 (diff) | |
parent | 0df30dbdbf9c28905ce424a1cfbeb5101c9ea0b0 (diff) | |
download | CastXML-dfe0586c6d8f304e8e30acf97d27581088265533.zip CastXML-dfe0586c6d8f304e8e30acf97d27581088265533.tar.gz CastXML-dfe0586c6d8f304e8e30acf97d27581088265533.tar.bz2 |
Merge branch 'release-0.2'
Diffstat (limited to 'src/Version.cmake')
-rw-r--r-- | src/Version.cmake | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/src/Version.cmake b/src/Version.cmake index 9aa0720..6b9fb14 100644 --- a/src/Version.cmake +++ b/src/Version.cmake @@ -12,7 +12,12 @@ if(CastXML_VERSION_RC) set(CastXML_VERSION "${CastXML_VERSION}-rc${CastXML_VERSION_RC}") endif() -if(EXISTS ${CastXML_SOURCE_DIR}/.git) +# If this source was exported by 'git archive', use its commit info. +set(git_info "$Format:%h %s$") + +# Otherwise, try to identify the current development source version. +if(NOT git_info MATCHES "^([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]?[0-9a-f]?)[0-9a-f]* " + AND EXISTS ${CastXML_SOURCE_DIR}/.git) find_package(Git QUIET) if(GIT_FOUND) macro(_git) @@ -25,34 +30,23 @@ if(EXISTS ${CastXML_SOURCE_DIR}/.git) ) endmacro() endif() -endif() -# Try to identify the current development source version. -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$") + # Try to identify the current development source version. + 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}") + endif() endif() # Extract commit information if available. -if(git_info MATCHES "^([0-9a-f]+) (.*)$") +if(git_info MATCHES "^([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]?[0-9a-f]?)[0-9a-f]* (.*)$") set(git_hash "${CMAKE_MATCH_1}") set(git_subject "${CMAKE_MATCH_2}") # If this is not the exact commit of a release, add dev info. if(NOT "${git_subject}" MATCHES "^[Cc]ast[Xx][Mm][Ll] ${CastXML_VERSION}$") - set(git_suffix "-g${git_hash}") - if(COMMAND _git) - # Use version suffix computed by 'git describe' if this version has been tagged. - _git(describe --tags --match "v${CastXML_VERSION}" HEAD) - if(_git_out MATCHES "^v${CastXML_VERSION}(-[0-9]+-g[0-9a-f]+)?$") - set(git_suffix "${CMAKE_MATCH_1}") - endif() - endif() - set(CastXML_VERSION "${CastXML_VERSION}${git_suffix}") + set(CastXML_VERSION "${CastXML_VERSION}-g${git_hash}") endif() # If this is a work tree, check whether it is dirty. |