Refactor CMake version handling

Move the CMake version number components out of "CMakeLists.txt" into
dedicated file "Source/CMakeVersion.cmake".  Set the TWEAK level to the
date explicitly.  Add a "Source/CMakeVersion.bash" script to update the
date, thus replacing KWSys DateStamp for CMake.  Teach the bootstrap
script to extract the version components from their new location.
This commit is contained in:
Brad King 2012-04-20 11:20:48 -04:00
parent 20ba4fe1bf
commit 0c7029c642
4 changed files with 17 additions and 27 deletions

View File

@ -422,26 +422,13 @@ ENDIF()
# The main section of the CMakeLists file
#
#-----------------------------------------------------------------------
# The CMake version number.
SET(CMake_VERSION_MAJOR 2)
SET(CMake_VERSION_MINOR 8)
SET(CMake_VERSION_PATCH 8)
#SET(CMake_VERSION_TWEAK 0)
#SET(CMake_VERSION_RC 1)
# Releases define a tweak level.
IF(DEFINED CMake_VERSION_TWEAK)
INCLUDE(Source/CMakeVersion.cmake)
# Releases define a small tweak level.
IF("${CMake_VERSION_TWEAK}" VERSION_LESS 20000000)
SET(CMake_VERSION_IS_RELEASE 1)
SET(CMake_VERSION_SOURCE "")
ELSE()
SET(CMake_VERSION_IS_RELEASE 0)
# Use the date as the tweak level.
INCLUDE(${CMake_SOURCE_DIR}/Source/kwsys/kwsysDateStamp.cmake)
SET(CMake_VERSION_TWEAK
"${KWSYS_DATE_STAMP_YEAR}${KWSYS_DATE_STAMP_MONTH}${KWSYS_DATE_STAMP_DAY}"
)
INCLUDE(${CMake_SOURCE_DIR}/Source/CMakeVersionSource.cmake)
ENDIF()

7
Source/CMakeVersion.bash Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
# Update the version component if it looks like a date or -f is given.
if test "x$1" = "x-f"; then shift ; n='*' ; else n='\{8\}' ; fi
if test "$#" -gt 0; then echo 1>&2 "usage: CMakeVersion.bash [-f]"; exit 1; fi
sed -i -e '
s/\(^SET(CMake_VERSION_TWEAK\) [0-9]'"$n"'\(.*\)/\1 '"$(date +%Y%m%d)"'\2/
' "${BASH_SOURCE%/*}/CMakeVersion.cmake"

View File

@ -0,0 +1,6 @@
# CMake version number components.
SET(CMake_VERSION_MAJOR 2)
SET(CMake_VERSION_MINOR 8)
SET(CMake_VERSION_PATCH 8)
SET(CMake_VERSION_TWEAK 20120420)
#SET(CMake_VERSION_RC 1)

View File

@ -18,18 +18,11 @@ die() {
# Version number extraction function.
cmake_version_component()
{
cat "${cmake_source_dir}/CMakeLists.txt" | sed -n "
cat "${cmake_source_dir}/Source/CMakeVersion.cmake" | sed -n "
/^SET(CMake_VERSION_${1}/ {s/SET(CMake_VERSION_${1} *\([0-9]*\))/\1/;p;}
"
}
cmake_date_stamp_component()
{
cat "${cmake_source_dir}/Source/kwsys/kwsysDateStamp.cmake" | sed -n "
/KWSYS_DATE_STAMP_${1}/ {s/^.* \([0-9][0-9]*\))$/\1/;p;}
"
}
cmake_toupper()
{
echo "$1" | sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'
@ -46,9 +39,6 @@ cmake_version_minor="`cmake_version_component MINOR`"
cmake_version_patch="`cmake_version_component PATCH`"
cmake_version="${cmake_version_major}.${cmake_version_minor}.${cmake_version_patch}"
cmake_version_tweak="`cmake_version_component TWEAK`"
if [ "x$cmake_version_tweak" = "x" ]; then
cmake_version_tweak="`cmake_date_stamp_component YEAR``cmake_date_stamp_component MONTH``cmake_date_stamp_component DAY`"
fi
if [ "$cmake_version_tweak" != "0" ]; then
cmake_version="${cmake_version}.${cmake_version_tweak}"
fi