Commit 98c51ff6 authored by Brad King's avatar Brad King

ENH: Overhaul CMake version numbering

This moves the version numbers into an isolated configured header so
that not all of CMake needs to rebuild when the version changes.

Previously we had spaces, dashes and/or the word 'patch' randomly chosen
before the patch number.  Now we always report version numbers in the
traditional format "<major>.<minor>.<patch>[-rc<rc>]".

We still use odd minor numbers for development versions.  Now we also
use the CCYYMMDD date as the patch number of development versions, thus
allowing tests for exact CMake versions.
parent 83f39ba4
......@@ -18,18 +18,13 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt")
SET(CPACK_PACKAGE_VERSION_MAJOR "${CMake_VERSION_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${CMake_VERSION_MINOR}")
# if version date is set then use that as the patch
IF(CMake_VERSION_DATE)
SET(CPACK_PACKAGE_VERSION_PATCH "${CMake_VERSION_DATE}")
ELSE(CMake_VERSION_DATE)
SET(CPACK_PACKAGE_VERSION_PATCH "${CMake_VERSION_PATCH}")
ENDIF(CMake_VERSION_DATE)
SET(CPACK_PACKAGE_VERSION_PATCH "${CMake_VERSION_PATCH}")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME
"cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
"cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}")
IF(CMake_VERSION_RC)
SET(CPACK_SOURCE_PACKAGE_FILE_NAME
"${CPACK_SOURCE_PACKAGE_FILE_NAME}-RC-${CMake_VERSION_RC}")
"${CPACK_SOURCE_PACKAGE_FILE_NAME}-rc${CMake_VERSION_RC}")
ENDIF(CMake_VERSION_RC)
IF(NOT DEFINED CPACK_SYSTEM_NAME)
# make sure package is not Cygwin-unknown, for Cygwin just
......@@ -82,7 +77,7 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
SET(CPACK_PACKAGE_NAME cmake)
# setup the name of the package for cygwin cmake-2.4.3
SET(CPACK_PACKAGE_FILE_NAME
"${CPACK_PACKAGE_NAME}-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
"${CPACK_PACKAGE_NAME}-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}")
# the source has the same name as the binary
SET(CPACK_SOURCE_PACKAGE_FILE_NAME ${CPACK_PACKAGE_FILE_NAME})
# Create a cygwin version number in case there are changes for cygwin
......
......@@ -361,11 +361,11 @@ SET(CMake_VERSION_MAJOR 2)
SET(CMake_VERSION_MINOR 7)
SET(CMake_VERSION_PATCH 0)
# CVS versions are odd, if this is an odd minor version
# then set the CMake_VERSION_DATE variable
# We use odd minor numbers for development versions.
# Use a date for the development patch level.
IF("${CMake_VERSION_MINOR}" MATCHES "[13579]$")
INCLUDE(${CMake_SOURCE_DIR}/Source/kwsys/kwsysDateStamp.cmake)
SET(CMake_VERSION_DATE
SET(CMake_VERSION_PATCH
"${KWSYS_DATE_STAMP_YEAR}${KWSYS_DATE_STAMP_MONTH}${KWSYS_DATE_STAMP_DAY}"
)
ENDIF("${CMake_VERSION_MINOR}" MATCHES "[13579]$")
......@@ -425,10 +425,6 @@ IF(BUILD_QtDialog)
IF(APPLE)
SET(CMAKE_BUNDLE_NAME
"CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}-${CMake_VERSION_PATCH}")
IF(CMake_VERSION_DATE)
SET(CMAKE_BUNDLE_NAME
"CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}-${CMake_VERSION_DATE}")
ENDIF(CMake_VERSION_DATE)
SET(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}")
# make sure CMAKE_INSTALL_PREFIX ends in /
STRING(LENGTH "${CMAKE_INSTALL_PREFIX}" LEN)
......
......@@ -12,6 +12,10 @@ CONFIGURE_FILE(
"${CMake_SOURCE_DIR}/Source/cmConfigure.cmake.h.in"
"${CMake_BINARY_DIR}/Source/cmConfigure.h"
)
CONFIGURE_FILE(
"${CMake_SOURCE_DIR}/Source/cmVersionConfig.h.in"
"${CMake_BINARY_DIR}/Source/cmVersionConfig.h"
)
CONFIGURE_FILE(
"${CMake_SOURCE_DIR}/Source/CPack/cmCPackConfigure.h.in"
"${CMake_BINARY_DIR}/Source/CPack/cmCPackConfigure.h"
......
......@@ -80,8 +80,7 @@ void cmCursesLongMessageForm::UpdateStatusBar()
char version[cmCursesMainForm::MAX_WIDTH];
char vertmp[128];
sprintf(vertmp,"CMake Version %d.%d - %s", cmVersion::GetMajorVersion(),
cmVersion::GetMinorVersion(),cmVersion::GetReleaseVersion().c_str());
sprintf(vertmp,"CMake Version %s", cmVersion::GetCMakeVersion());
int sideSpace = (width-strlen(vertmp));
for(int i=0; i<sideSpace; i++) { version[i] = ' '; }
sprintf(version+sideSpace, "%s", vertmp);
......
......@@ -592,8 +592,7 @@ void cmCursesMainForm::UpdateStatusBar(const char* message)
// We want to display this on the right
char version[cmCursesMainForm::MAX_WIDTH];
char vertmp[128];
sprintf(vertmp,"CMake Version %d.%d - %s", cmVersion::GetMajorVersion(),
cmVersion::GetMinorVersion(),cmVersion::GetReleaseVersion().c_str());
sprintf(vertmp,"CMake Version %s", cmVersion::GetCMakeVersion());
int sideSpace = (width-strlen(vertmp));
for(i=0; i<sideSpace; i++) { version[i] = ' '; }
sprintf(version+sideSpace, "%s", vertmp);
......
......@@ -330,9 +330,7 @@ BOOL CMakeSetupDialog::OnInitDialog()
// Set the version number
char tmp[1024];
sprintf(tmp,"CMake %d.%d - %s", cmVersion::GetMajorVersion(),
cmVersion::GetMinorVersion(),
cmVersion::GetReleaseVersion().c_str());
sprintf(tmp,"CMake %s", cmVersion::GetCMakeVersion());
SetDlgItemText(IDC_PROGRESS, "");
this->SetWindowText(tmp);
this->UpdateData(FALSE);
......
......@@ -144,7 +144,7 @@ int main(int argc, char** argv)
CMakeSetupDialog dialog;
QString title = QString("CMake %1");
title = title.arg(cmVersion::GetCMakeVersion().c_str());
title = title.arg(cmVersion::GetCMakeVersion());
dialog.setWindowTitle(title);
dialog.show();
......
......@@ -700,9 +700,7 @@ void CMakeSetupFrm::DoInitFrame(cmCommandLineInfo &cm, const wxString &fn)
m_cmGeneratorChoice->SetStringSelection(generator);
wxString str;
str.Printf("CMake %d.%d - %s", cmVersion::GetMajorVersion(),
cmVersion::GetMinorVersion(),
cmVersion::GetReleaseVersion().c_str());
str.Printf("CMake %s", cmVersion::GetCMakeVersion());
str.Printf("CMakeSetup v%i.%i%s", CMAKEGUI_MAJORVER, CMAKEGUI_MINORVER, CMAKEGUI_ADDVER);
SetTitle(str);
......@@ -1696,7 +1694,6 @@ void CMakeSetupFrm::OnAboutClick( wxCommandEvent& event )
generators.Add(i->c_str());
wxString cmversion, cmsversion;
// cmversion.Printf("v%i.%i %s", cmake::GetMajorVersion(), cmake::GetMinorVersion(), cmake::GetReleaseVersion());
cmsversion.Printf("v%i.%i%s", CMAKEGUI_MAJORVER, CMAKEGUI_MINORVER, CMAKEGUI_ADDVER);
dlg->SetAboutText(cmversion, cmsversion, generators);
......
......@@ -26,6 +26,7 @@
#include "cmDynamicLoader.h"
#include "cmGeneratedFileStream.h"
#include "cmXMLSafe.h"
#include "cmVersionMacros.h"
#include "cmCTestCommand.h"
#include "cmCTestBuildHandler.h"
......@@ -1266,7 +1267,7 @@ void cmCTest::StartXML(std::ostream& ostr, bool append)
<< "<Site BuildName=\"" << this->GetCTestConfiguration("BuildName")
<< "\"\n\tBuildStamp=\"" << this->CurrentTag << "-"
<< this->GetTestModelString() << "\"\n\tName=\""
<< this->GetCTestConfiguration("Site") << "\"\n\tGenerator=\"ctest"
<< this->GetCTestConfiguration("Site") << "\"\n\tGenerator=\"ctest-"
<< cmVersion::GetCMakeVersion() << "\"\n"
<< (append? "\tAppend=\"true\"\n":"")
<< "\tOSName=\"" << info.GetOSName() << "\"\n"
......
......@@ -410,10 +410,9 @@ bool cmCacheManager::SaveCache(const char* path)
this->AddCacheEntry("CMAKE_CACHE_MAJOR_VERSION", temp,
"Major version of cmake used to create the "
"current loaded cache", cmCacheManager::INTERNAL);
this->AddCacheEntry("CMAKE_CACHE_RELEASE_VERSION",
cmVersion::GetReleaseVersion().c_str(),
"Major version of cmake used to create the "
sprintf(temp, "%d", cmVersion::GetPatchVersion());
this->AddCacheEntry("CMAKE_CACHE_PATCH_VERSION", temp,
"Patch version of cmake used to create the "
"current loaded cache", cmCacheManager::INTERNAL);
// Let us store the current working directory so that if somebody
......
......@@ -24,9 +24,4 @@
#cmakedefine CMAKE_STRICT
#define CMAKE_ROOT_DIR "${CMake_SOURCE_DIR}"
#define CMAKE_BUILD_DIR "${CMake_BINARY_DIR}"
#define CMake_VERSION_MAJOR @CMake_VERSION_MAJOR@
#define CMake_VERSION_MINOR @CMake_VERSION_MINOR@
#define CMake_VERSION_PATCH @CMake_VERSION_PATCH@
#cmakedefine CMake_VERSION_RC @CMake_VERSION_RC@
#define CMAKE_DATA_DIR "@CMAKE_DATA_DIR@"
......@@ -110,9 +110,9 @@ void cmDocumentVariables::DefineVariables(cmake* cm)
"Variables that Provide Information");
cm->DefineProperty
("CMAKE_CACHE_RELEASE_VERSION", cmProperty::VARIABLE,
"Release version of CMake used to create the CMakeCache.txt file",
"This is stores the release version of CMake used to "
("CMAKE_CACHE_PATCH_VERSION", cmProperty::VARIABLE,
"Patch version of CMake used to create the CMakeCache.txt file",
"This is stores the patch version of CMake used to "
"write a CMake cache file. It is only different when "
"a different version of CMake is run on a previously "
"created cache file.", false,
......
......@@ -26,6 +26,7 @@
#include "cmMakefile.h"
#include "cmSourceFile.h"
#include "cmTest.h"
#include "cmVersion.h"
#include "cmake.h"
#if defined(CMAKE_BUILD_WITH_CMAKE)
......
......@@ -21,26 +21,11 @@
#ifndef cmStandardIncludes_h
#define cmStandardIncludes_h
#define CMAKE_TO_STRING(x) CMAKE_TO_STRING0(x)
#define CMAKE_TO_STRING0(x) #x
// include configure generated header to define CMAKE_NO_ANSI_STREAM_HEADERS,
// CMAKE_NO_STD_NAMESPACE, and other macros.
#include "cmConfigure.h"
#include <cmsys/Configure.hxx>
#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)
#define CMake_VERSION_ENCODE(major, minor, patch) \
((major)*0x10000u + (minor)*0x100u + (patch))
#ifdef _MSC_VER
#pragma warning ( disable : 4786 )
#pragma warning ( disable : 4503 )
......
......@@ -16,27 +16,13 @@
=========================================================================*/
#include "cmVersion.h"
#include <cmsys/DateStamp.h>
#include "cmVersionMacros.h"
std::string cmVersion::GetReleaseVersion()
{
#if CMake_VERSION_MINOR & 1
return cmsys_DATE_STAMP_STRING_FULL;
#else
# ifdef CMake_VERSION_RC
return "patch " CMAKE_TO_STRING(CMake_VERSION_PATCH) " RC-"
CMAKE_TO_STRING(CMake_VERSION_RC);
# else
return "patch " CMAKE_TO_STRING(CMake_VERSION_PATCH);
# endif
#endif
}
unsigned int cmVersion::GetMajorVersion() { return CMake_VERSION_MAJOR; }
unsigned int cmVersion::GetMinorVersion() { return CMake_VERSION_MINOR; }
unsigned int cmVersion::GetPatchVersion() { return CMake_VERSION_PATCH; }
std::string cmVersion::GetCMakeVersion()
const char* cmVersion::GetCMakeVersion()
{
cmOStringStream str;
str << CMake_VERSION_MAJOR << "." << CMake_VERSION_MINOR
<< "-"
<< cmVersion::GetReleaseVersion();
return str.str();
return CMake_VERSION_FULL CMake_VERSION_RC_SUFFIX;
}
......@@ -30,12 +30,14 @@ public:
/**
* Return major and minor version numbers for cmake.
*/
static unsigned int GetMajorVersion() { return CMake_VERSION_MAJOR; }
static unsigned int GetMinorVersion() { return CMake_VERSION_MINOR; }
static unsigned int GetPatchVersion() { return CMake_VERSION_PATCH; }
static std::string GetReleaseVersion();
static std::string GetCMakeVersion();
static unsigned int GetMajorVersion();
static unsigned int GetMinorVersion();
static unsigned int GetPatchVersion();
static const char* GetCMakeVersion();
};
#define CMake_VERSION_ENCODE(major, minor, patch) \
((major)*0x10000u + (minor)*0x100u + (patch))
#endif
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#define CMake_VERSION_MAJOR @CMake_VERSION_MAJOR@
#define CMake_VERSION_MINOR @CMake_VERSION_MINOR@
#define CMake_VERSION_PATCH @CMake_VERSION_PATCH@
#cmakedefine CMake_VERSION_RC @CMake_VERSION_RC@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmVersionMacros_h
#define cmVersionMacros_h
#include "cmVersionConfig.h"
#define CMAKE_TO_STRING(x) CMAKE_TO_STRING0(x)
#define CMAKE_TO_STRING0(x) #x
#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
......@@ -2355,9 +2355,7 @@ int cmake::DumpDocumentationToFile(std::ostream& f)
const char *terse;
const char *full;
char tmp[1024];
sprintf(tmp,"Version %d.%d (%s)", cmVersion::GetMajorVersion(),
cmVersion::GetMinorVersion(),
cmVersion::GetReleaseVersion().c_str());
sprintf(tmp,"Version %s", cmVersion::GetCMakeVersion());
f << "<html>\n";
f << "<h1>Documentation for commands of CMake " << tmp << "</h1>\n";
f << "<ul>\n";
......
......@@ -15,6 +15,7 @@ AddCMakeTest(Include "")
AddCMakeTest(FindBase "")
AddCMakeTest(Toolchain "")
AddCMakeTest(GetFilenameComponentRealpath "")
AddCMakeTest(Version "")
SET(GetPrerequisites_PreArgs
"-DCTEST_CONFIGURATION_TYPE:STRING=\\\${CTEST_CONFIGURATION_TYPE}"
......
set(min_ver 2.7.20090305)
cmake_minimum_required(VERSION ${min_ver})
if("${CMAKE_VERSION}" VERSION_LESS "${min_ver}")
message(FATAL_ERROR
"CMAKE_VERSION=[${CMAKE_VERSION}] is less than [${min_ver}]")
else()
message("CMAKE_VERSION=[${CMAKE_VERSION}] is not less than [${min_ver}]")
endif()
......@@ -40,10 +40,13 @@ cmake_binary_dir=`pwd`
cmake_bootstrap_dir="${cmake_binary_dir}/Bootstrap.cmk"
cmake_version_major="`cmake_version_component MAJOR`"
cmake_version_minor="`cmake_version_component MINOR`"
cmake_version_patch="`cmake_version_component PATCH`"
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`"
fi
cmake_version="${cmake_version_major}.${cmake_version_minor}"
cmake_version_full="${cmake_version_major}.${cmake_version_minor}.${cmake_version_patch}"
cmake_date_stamp="`cmake_date_stamp_component YEAR``cmake_date_stamp_component MONTH``cmake_date_stamp_component DAY`"
cmake_data_dir="/share/cmake-${cmake_version}"
cmake_doc_dir="/doc/cmake-${cmake_version}"
cmake_man_dir="/man"
......@@ -283,15 +286,7 @@ EOF
# Display CMake bootstrap usage
cmake_version_display()
{
(
# Get CMake version
if echo "${cmake_version_full}" | grep "[0-9]\.[0-9]*[13579]\.[0-9]" > /dev/null 2>&1; then
version="${cmake_version}-${cmake_date_stamp}"
else
version="${cmake_version}-${cmake_version_patch}"
fi
echo "CMake ${version}, Copyright (c) 2007 Kitware, Inc., Insight Consortium"
)
echo "CMake ${cmake_version_full}, Copyright (c) 2000-2009 Kitware, Inc., Insight Consortium"
}
# Display CMake bootstrap error, display the log file and exit
......@@ -594,6 +589,7 @@ done
# Delete all the bootstrap files
rm -f "${cmake_bootstrap_dir}/cmake_bootstrap.log"
rm -f "${cmake_bootstrap_dir}/cmConfigure.h.tmp"
rm -f "${cmake_bootstrap_dir}/cmVersionConfig.h.tmp"
# If exist compiler flags, set them
cmake_c_flags=${CFLAGS}
......@@ -1204,19 +1200,21 @@ else
fi
# Write CMake version
cmake_report cmConfigure.h.tmp "#define CMake_VERSION_MAJOR ${cmake_version_major}"
cmake_report cmConfigure.h.tmp "#define CMake_VERSION_MINOR ${cmake_version_minor}"
cmake_report cmConfigure.h.tmp "#define CMake_VERSION_PATCH ${cmake_version_patch}"
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_PATCH ${cmake_version_patch}"
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_BOOTSTRAP"
# Regenerate real cmConfigure.h
if diff cmConfigure.h cmConfigure.h.tmp > /dev/null 2> /dev/null; then
rm -f cmConfigure.h.tmp
else
mv -f cmConfigure.h.tmp cmConfigure.h
fi
# Regenerate configured headers
for h in Configure VersionConfig; do
if diff cm${h}.h cm${h}.h.tmp > /dev/null 2> /dev/null; then
rm -f cm${h}.h.tmp
else
mv -f cm${h}.h.tmp cm${h}.h
fi
done
# Prepare KWSYS
cmake_kwsys_config_replace_string \
......@@ -1228,14 +1226,6 @@ cmake_kwsys_config_replace_string \
"${cmake_bootstrap_dir}/cmsys/Configure.h" \
"${cmake_compiler_settings_comment}"
cat>"${cmake_bootstrap_dir}/cmsys/DateStamp.h"<<EOF
/* Minimal DateStamp header for CMake bootstrap build. */
#ifndef cmsys_DateStamp_h
#define cmsys_DateStamp_h
#define cmsys_DATE_STAMP_STRING_FULL "${cmake_date_stamp}"
#endif
EOF
for a in ${KWSYS_FILES}; do
cmake_replace_string "${cmake_source_dir}/Source/kwsys/${a}.in" \
"${cmake_bootstrap_dir}/cmsys/${a}" KWSYS_NAMESPACE cmsys
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment