New version scheme to support branchy workflow

Prepare to switch to the workflow described by "git help workflows".  In
this workflow, the "master" branch is always used to integrate topics
ready for release.  Brand new work merges into a "next" branch instead.
We need a new versioning scheme to work this way because the version on
"master" must always increase.

We no longer use an even/odd minor number to distinguish releases from
development versions.  Since we still support cvs checkout of our source
tree we cannot depend on "git describe" to compute a version number
based on the history graph.  We can use the CCYYMMDD nightly date stamp
to get a monotonically increasing version component.

The new version format is "major.minor.patch.(tweak|date)".  Releases
use a tweak level in the half-open range [0,20000000), which is smaller
than any current or future date.  For tweak=0 we do not show the tweak
component, leaving the format "major.minor.patch" for most releases.
Development versions use date=CCYYMMDD for the tweak level.  The
major.minor.patch part of development versions on "master" always
matches the most recent release.

For example, a first-parent traversal of "master" might see

        v2.8.1      2.8.1.20100422    v2.8.2
           |              |              |
  ----o----o----o----o----o----o----o----o----

Since the date appears in the tweak component, the next release can
increment the patch level (or any more significant component) to be
greater than any version leading to it.  Topic branches not ready for
release are published only on "next" so we know that all versions on
master lead between two releases.
This commit is contained in:
Brad King 2010-04-23 09:44:23 -04:00
parent 7049dff85a
commit 5bfffd6f29
8 changed files with 58 additions and 44 deletions

View File

@ -339,18 +339,29 @@ ENDMACRO (CMAKE_BUILD_UTILITIES)
SET(CMake_VERSION_MAJOR 2) SET(CMake_VERSION_MAJOR 2)
SET(CMake_VERSION_MINOR 9) SET(CMake_VERSION_MINOR 9)
SET(CMake_VERSION_PATCH 0) SET(CMake_VERSION_PATCH 0)
#SET(CMake_VERSION_TWEAK 0)
# We use odd minor numbers for development versions. # Releases define a tweak level.
# Use a date for the development patch level. IF(DEFINED CMake_VERSION_TWEAK)
IF("${CMake_VERSION_MINOR}" MATCHES "[13579]$") SET(CMake_VERSION_IS_RELEASE 1)
ELSE()
SET(CMake_VERSION_IS_RELEASE 0)
# Use the date as the tweak level.
INCLUDE(${CMake_SOURCE_DIR}/Source/kwsys/kwsysDateStamp.cmake) INCLUDE(${CMake_SOURCE_DIR}/Source/kwsys/kwsysDateStamp.cmake)
SET(CMake_VERSION_PATCH SET(CMake_VERSION_TWEAK
"${KWSYS_DATE_STAMP_YEAR}${KWSYS_DATE_STAMP_MONTH}${KWSYS_DATE_STAMP_DAY}" "${KWSYS_DATE_STAMP_YEAR}${KWSYS_DATE_STAMP_MONTH}${KWSYS_DATE_STAMP_DAY}"
) )
ENDIF("${CMake_VERSION_MINOR}" MATCHES "[13579]$") ENDIF()
SET(CMake_VERSION "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}") # Compute the full version string.
SET(CMake_VERSION_FULL "${CMake_VERSION}.${CMake_VERSION_PATCH}") SET(CMake_VERSION ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH})
IF(${CMake_VERSION_TWEAK} GREATER 0)
SET(CMake_VERSION ${CMake_VERSION}.${CMake_VERSION_TWEAK})
ENDIF()
IF(CMake_VERSION_RC)
SET(CMake_VERSION ${CMake_VERSION}-rc${CMake_VERSION_RC})
ENDIF()
# Include the standard Dart testing module # Include the standard Dart testing module
ENABLE_TESTING() ENABLE_TESTING()
@ -370,9 +381,9 @@ SET(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL
# install tree. # install tree.
SET(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.") SET(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.")
SET(CMAKE_DATA_DIR "/share/cmake-${CMake_VERSION}" CACHE STRING SET(CMAKE_DATA_DIR "/share/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}" CACHE STRING
"Install location for data (relative to prefix).") "Install location for data (relative to prefix).")
SET(CMAKE_DOC_DIR "/doc/cmake-${CMake_VERSION}" CACHE STRING SET(CMAKE_DOC_DIR "/doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}" CACHE STRING
"Install location for documentation (relative to prefix).") "Install location for documentation (relative to prefix).")
SET(CMAKE_MAN_DIR "/man" CACHE STRING SET(CMAKE_MAN_DIR "/man" CACHE STRING
"Install location for man pages (relative to prefix).") "Install location for man pages (relative to prefix).")

View File

@ -250,13 +250,21 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
"This specifies the patch version of the CMake" "This specifies the patch version of the CMake"
" executable being run.",false, " executable being run.",false,
"Variables that Provide Information"); "Variables that Provide Information");
cm->DefineProperty
("CMAKE_TWEAK_VERSION", cmProperty::VARIABLE,
"The tweak version of cmake (i.e. the 1 in X.X.X.1).",
"This specifies the tweak version of the CMake executable being run. "
"Releases use tweak < 20000000 and development versions use the date "
"format CCYYMMDD for the tweak level."
,false, "Variables that Provide Information");
cm->DefineProperty cm->DefineProperty
("CMAKE_VERSION", cmProperty::VARIABLE, ("CMAKE_VERSION", cmProperty::VARIABLE,
"The full version of cmake in major.minor.patch format.", "The full version of cmake in major.minor.patch[.tweak] format.",
"This specifies the full version of the CMake executable being run. " "This specifies the full version of the CMake executable being run. "
"This variable is defined by versions 2.6.3 and higher. " "This variable is defined by versions 2.6.3 and higher. "
"See variables CMAKE_MAJOR_VERSION, CMAKE_MINOR_VERSION, and " "See variables CMAKE_MAJOR_VERSION, CMAKE_MINOR_VERSION, "
"CMAKE_PATCH_VERSION for individual version components.", false, "CMAKE_PATCH_VERSION, and CMAKE_TWEAK_VERSION "
"for individual version components.", false,
"Variables that Provide Information"); "Variables that Provide Information");
cm->DefineProperty cm->DefineProperty

View File

@ -2368,11 +2368,9 @@ void cmMakefile::AddDefaultDefinitions()
this->AddDefinition("CMAKE_MAJOR_VERSION", temp); this->AddDefinition("CMAKE_MAJOR_VERSION", temp);
sprintf(temp, "%d", cmVersion::GetPatchVersion()); sprintf(temp, "%d", cmVersion::GetPatchVersion());
this->AddDefinition("CMAKE_PATCH_VERSION", temp); this->AddDefinition("CMAKE_PATCH_VERSION", temp);
sprintf(temp, "%u.%u.%u", sprintf(temp, "%d", cmVersion::GetTweakVersion());
cmVersion::GetMajorVersion(), this->AddDefinition("CMAKE_TWEAK_VERSION", temp);
cmVersion::GetMinorVersion(), this->AddDefinition("CMAKE_VERSION", cmVersion::GetCMakeVersion());
cmVersion::GetPatchVersion());
this->AddDefinition("CMAKE_VERSION", temp);
this->AddDefinition("CMAKE_FILES_DIRECTORY", this->AddDefinition("CMAKE_FILES_DIRECTORY",
cmake::GetCMakeFilesDirectory()); cmake::GetCMakeFilesDirectory());

View File

@ -16,8 +16,9 @@
unsigned int cmVersion::GetMajorVersion() { return CMake_VERSION_MAJOR; } unsigned int cmVersion::GetMajorVersion() { return CMake_VERSION_MAJOR; }
unsigned int cmVersion::GetMinorVersion() { return CMake_VERSION_MINOR; } unsigned int cmVersion::GetMinorVersion() { return CMake_VERSION_MINOR; }
unsigned int cmVersion::GetPatchVersion() { return CMake_VERSION_PATCH; } unsigned int cmVersion::GetPatchVersion() { return CMake_VERSION_PATCH; }
unsigned int cmVersion::GetTweakVersion() { return CMake_VERSION_TWEAK; }
const char* cmVersion::GetCMakeVersion() const char* cmVersion::GetCMakeVersion()
{ {
return CMake_VERSION_FULL CMake_VERSION_RC_SUFFIX; return CMake_VERSION;
} }

View File

@ -28,6 +28,7 @@ public:
static unsigned int GetMajorVersion(); static unsigned int GetMajorVersion();
static unsigned int GetMinorVersion(); static unsigned int GetMinorVersion();
static unsigned int GetPatchVersion(); static unsigned int GetPatchVersion();
static unsigned int GetTweakVersion();
static const char* GetCMakeVersion(); static const char* GetCMakeVersion();
}; };

View File

@ -12,4 +12,5 @@
#define CMake_VERSION_MAJOR @CMake_VERSION_MAJOR@ #define CMake_VERSION_MAJOR @CMake_VERSION_MAJOR@
#define CMake_VERSION_MINOR @CMake_VERSION_MINOR@ #define CMake_VERSION_MINOR @CMake_VERSION_MINOR@
#define CMake_VERSION_PATCH @CMake_VERSION_PATCH@ #define CMake_VERSION_PATCH @CMake_VERSION_PATCH@
#cmakedefine CMake_VERSION_RC @CMake_VERSION_RC@ #define CMake_VERSION_TWEAK @CMake_VERSION_TWEAK@
#define CMake_VERSION "@CMake_VERSION@"

View File

@ -14,22 +14,9 @@
#include "cmVersionConfig.h" #include "cmVersionConfig.h"
#define CMAKE_TO_STRING(x) CMAKE_TO_STRING0(x) #define CMake_VERSION_TWEAK_IS_RELEASE(tweak) ((tweak) < 20000000)
#define CMAKE_TO_STRING0(x) #x #if CMake_VERSION_TWEAK_IS_RELEASE(CMake_VERSION_TWEAK)
# define CMake_VERSION_IS_RELEASE 1
#define CMake_VERSION \
CMAKE_TO_STRING(CMake_VERSION_MAJOR) "." \
CMAKE_TO_STRING(CMake_VERSION_MINOR)
#define CMake_VERSION_FULL \
CMAKE_TO_STRING(CMake_VERSION_MAJOR) "." \
CMAKE_TO_STRING(CMake_VERSION_MINOR) "." \
CMAKE_TO_STRING(CMake_VERSION_PATCH)
#if !(CMake_VERSION_MINOR & 1) && defined(CMake_VERSION_RC)
# define CMake_VERSION_RC_SUFFIX "-rc" CMAKE_TO_STRING(CMake_VERSION_RC)
#else
# define CMake_VERSION_RC_SUFFIX ""
#endif #endif
#endif #endif

View File

@ -30,17 +30,22 @@ cmake_date_stamp_component()
cmake_system=`uname` cmake_system=`uname`
cmake_source_dir=`cd "\`dirname \"$0\"\`";pwd` cmake_source_dir=`cd "\`dirname \"$0\"\`";pwd`
cmake_binary_dir=`pwd` cmake_binary_dir=`pwd`
# Load version information.
cmake_version_major="`cmake_version_component MAJOR`" cmake_version_major="`cmake_version_component MAJOR`"
cmake_version_minor="`cmake_version_component MINOR`" cmake_version_minor="`cmake_version_component MINOR`"
if echo "${cmake_version_minor}" | grep "[0-9]*[13579]" > /dev/null 2>&1; then
cmake_version_patch="`cmake_date_stamp_component YEAR``cmake_date_stamp_component MONTH``cmake_date_stamp_component DAY`"
else
cmake_version_patch="`cmake_version_component PATCH`" 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 fi
cmake_version="${cmake_version_major}.${cmake_version_minor}" if [ "$cmake_version_tweak" != "0" ]; then
cmake_version_full="${cmake_version_major}.${cmake_version_minor}.${cmake_version_patch}" cmake_version="${cmake_version}.${cmake_version_tweak}"
cmake_data_dir="/share/cmake-${cmake_version}" fi
cmake_doc_dir="/doc/cmake-${cmake_version}"
cmake_data_dir="/share/cmake-${cmake_version_major}.${cmake_version_minor}"
cmake_doc_dir="/doc/cmake-${cmake_version_major}.${cmake_version_minor}"
cmake_man_dir="/man" cmake_man_dir="/man"
cmake_init_file="" cmake_init_file=""
cmake_bootstrap_system_libs="" cmake_bootstrap_system_libs=""
@ -312,7 +317,7 @@ Directory and file names:
# Display CMake bootstrap usage # Display CMake bootstrap usage
cmake_version_display() cmake_version_display()
{ {
echo "CMake ${cmake_version_full}, Copyright 2000-2009 Kitware, Inc." echo "CMake ${cmake_version}, Copyright 2000-2009 Kitware, Inc."
} }
# Display CMake bootstrap error, display the log file and exit # Display CMake bootstrap error, display the log file and exit
@ -1246,6 +1251,8 @@ fi
cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MAJOR ${cmake_version_major}" cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MAJOR ${cmake_version_major}"
cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MINOR ${cmake_version_minor}" cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_MINOR ${cmake_version_minor}"
cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_PATCH ${cmake_version_patch}" cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_PATCH ${cmake_version_patch}"
cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION_TWEAK ${cmake_version_tweak}"
cmake_report cmVersionConfig.h${_tmp} "#define CMake_VERSION \"${cmake_version}\""
cmake_report cmConfigure.h${_tmp} "#define CMAKE_ROOT_DIR \"${cmake_root_dir}\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_ROOT_DIR \"${cmake_root_dir}\""
cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"${cmake_data_dir}\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"${cmake_data_dir}\""
cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP" cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP"