Make CMake version suffix available to code

Make the string (e.g. "rc1" or "gSHA-dirty") available to the code.
This commit is contained in:
Tobias Hunger 2016-07-01 09:40:09 +02:00 committed by Brad King
parent 7af4bc69c5
commit 6a077b5d63
2 changed files with 9 additions and 4 deletions

View File

@ -12,9 +12,13 @@ endif()
# Compute the full version string.
set(CMake_VERSION ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH})
if(CMake_VERSION_RC)
set(CMake_VERSION ${CMake_VERSION}-rc${CMake_VERSION_RC})
endif()
if(CMake_VERSION_SOURCE)
set(CMake_VERSION ${CMake_VERSION}-${CMake_VERSION_SOURCE})
set(CMake_VERSION_SUFFIX "${CMake_VERSION_SOURCE}")
elseif(CMake_VERSION_RC)
set(CMake_VERSION_SUFFIX "rc${CMake_VERSION_RC}")
else()
set(CMake_VERSION_SUFFIX "")
endif()
if(CMake_VERSION_SUFFIX)
set(CMake_VERSION ${CMake_VERSION}-${CMake_VERSION_SUFFIX})
endif()

View File

@ -12,4 +12,5 @@
#define CMake_VERSION_MAJOR @CMake_VERSION_MAJOR@
#define CMake_VERSION_MINOR @CMake_VERSION_MINOR@
#define CMake_VERSION_PATCH @CMake_VERSION_PATCH@
#define CMake_VERSION_SUFFIX "@CMake_VERSION_SUFFIX@"
#define CMake_VERSION "@CMake_VERSION@"