diff options
author | Brad King <brad.king@kitware.com> | 2019-07-25 12:51:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-07-29 15:25:44 (GMT) |
commit | ac48259333b1b5b5a75e0c2d2f8413bbab782a3e (patch) | |
tree | 4f871f8ee90fe1c602990211fddc86b39bc3b74a | |
parent | 311f232f7a045cd781171c2660ef005fb8074e3d (diff) | |
download | CMake-ac48259333b1b5b5a75e0c2d2f8413bbab782a3e.zip CMake-ac48259333b1b5b5a75e0c2d2f8413bbab782a3e.tar.gz CMake-ac48259333b1b5b5a75e0c2d2f8413bbab782a3e.tar.bz2 |
CMakeVersion: Re-order logic to obviate addition of each component
-rw-r--r-- | Source/CMakeVersion.cmake | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d3e734c..d3d866e 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -4,7 +4,20 @@ set(CMake_VERSION_MINOR 15) set(CMake_VERSION_PATCH 20190726) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) -set(CMake_VERSION_SOURCE "") + +# Start with the full version number used in tags. It has no dev info. +set(CMake_VERSION + "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}") +if(DEFINED CMake_VERSION_RC) + set(CMake_VERSION "${CMake_VERSION}-rc${CMake_VERSION_RC}") +endif() + +# Releases define a small patch level. +if("${CMake_VERSION_PATCH}" VERSION_LESS 20000000) + set(CMake_VERSION_IS_RELEASE 1) +else() + set(CMake_VERSION_IS_RELEASE 0) +endif() if(EXISTS ${CMake_SOURCE_DIR}/.git) find_package(Git QUIET) @@ -21,16 +34,12 @@ if(EXISTS ${CMake_SOURCE_DIR}/.git) endif() endif() -# Releases define a small patch level. -if("${CMake_VERSION_PATCH}" VERSION_LESS 20000000) - set(CMake_VERSION_IS_RELEASE 1) -else() - set(CMake_VERSION_IS_RELEASE 0) +if(NOT CMake_VERSION_IS_RELEASE) # Try to identify the current development source version. if(COMMAND _git) _git(rev-parse --verify -q --short=4 HEAD) if(_git_out) - set(CMake_VERSION_SOURCE "g${_git_out}") + set(CMake_VERSION "${CMake_VERSION}-g${_git_out}") _git(update-index -q --refresh) _git(diff-index --name-only HEAD --) if(_git_out) @@ -40,18 +49,12 @@ else() endif() endif() -# Compute the full version string. -set(CMake_VERSION ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}) -if(CMake_VERSION_SOURCE) - set(CMake_VERSION_SUFFIX "${CMake_VERSION_SOURCE}") -elseif(DEFINED CMake_VERSION_RC) - set(CMake_VERSION_SUFFIX "rc${CMake_VERSION_RC}") +# Extract the version suffix component. +if(CMake_VERSION MATCHES "-(.*)$") + set(CMake_VERSION_SUFFIX "${CMAKE_MATCH_1}") else() set(CMake_VERSION_SUFFIX "") endif() -if(CMake_VERSION_SUFFIX) - set(CMake_VERSION ${CMake_VERSION}-${CMake_VERSION_SUFFIX}) -endif() if(CMake_VERSION_IS_DIRTY) set(CMake_VERSION ${CMake_VERSION}-dirty) endif() |