From 1fe42129d43d659f33ed72e63c26e7c9f8cf64d9 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 13 Feb 2003 21:57:05 -0500 Subject: [PATCH] ENH: Centralized setting of CMake version number to top-level CMake listfile. --- CMakeLists.txt | 7 ++++ Source/CMakeLists.txt | 2 -- Source/WXDialog/CMakeLists.txt | 8 ++--- Source/cmConfigure.cmake.h.in | 5 +-- Source/cmConfigure.h.in | 3 ++ Source/cmMakefile.cxx | 9 +++++ Source/cmMakefile.h | 6 ++-- Source/cmStandardIncludes.h | 8 +++++ configure | 62 +++++++++++++++++++++++----------- configure.in | 12 +++++++ 10 files changed, 92 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f492adce..9ecd73431 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,12 @@ PROJECT(CMake) +# The CMake version number. +SET(CMake_VERSION_MAJOR 1) +SET(CMake_VERSION_MINOR 7) +SET(CMake_VERSION_PATCH 0) +SET(CMake_VERSION_STRING + "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}") + IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 1.4) IF(CMAKE_GENERATOR MATCHES "Visual Studio 7") SET(CMAKE_SKIP_COMPATIBILITY_TESTS 1) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index b69fde533..0c83d5357 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -309,8 +309,6 @@ IF(BUILD_TESTING) ENDIF (APPLE) ENDIF(BUILD_TESTING) - - INCLUDE (${CMAKE_BINARY_DIR}/Source/LocalUserOptions.cmake OPTIONAL) INCLUDE (${CMAKE_SOURCE_DIR}/Source/LocalUserOptions.cmake OPTIONAL) diff --git a/Source/WXDialog/CMakeLists.txt b/Source/WXDialog/CMakeLists.txt index 2438e169d..ada99ded0 100644 --- a/Source/WXDialog/CMakeLists.txt +++ b/Source/WXDialog/CMakeLists.txt @@ -29,12 +29,12 @@ IF ( CMAKE_WX_CAN_COMPILE ) IF(APPLE) SET(APPLE_GUI_EXECUTABLE wxCMakeSetup) - SET(APPLE_GUI_INFO_STRING "CMake version 1.7.0, (c) 2003 Kitware Inc.") + SET(APPLE_GUI_INFO_STRING "CMake version ${CMake_VERSION_MAJOR}, (c) 2003 Kitware Inc.") SET(APPLE_GUI_IDENTIFIER "com.kitware.wxCMakeSetup") - SET(APPLE_GUI_LONG_VERSION_STRING "1.7.0, (c) 2003 Kitware Inc.") + SET(APPLE_GUI_LONG_VERSION_STRING "${CMake_VERSION_MAJOR}, (c) 2003 Kitware Inc.") SET(APPLE_GUI_BUNDLE_NAME "CMake") - SET(APPLE_GUI_SHORT_VERSION_STRING "1.7.0") - SET(APPLE_GUI_BUNDLE_VERSION "1.7.0") + SET(APPLE_GUI_SHORT_VERSION_STRING "${CMake_VERSION_MAJOR}") + SET(APPLE_GUI_BUNDLE_VERSION "${CMake_VERSION_MAJOR}") SET(APPLE_GUI_ICON "CMakeIcon.icns") SET(APPLE_GUI_COPYRIGHT "Copyright 2002 Kitware Inc.") CONFIGURE_FILE(${CMake_SOURCE_DIR}/Templates/AppleInfo.plist diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index ffff9e03c..8f1ec766f 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -6,5 +6,6 @@ #define CMAKE_BUILD_DIR "${CMake_BINARY_DIR}" #define CMAKE_PREFIX "${CMAKE_INSTALL_PREFIX}" - - +#define CMake_VERSION_MAJOR @CMake_VERSION_MAJOR@ +#define CMake_VERSION_MINOR @CMake_VERSION_MINOR@ +#define CMake_VERSION_PATCH @CMake_VERSION_PATCH@ diff --git a/Source/cmConfigure.h.in b/Source/cmConfigure.h.in index bff2d77cc..ba4db57ac 100644 --- a/Source/cmConfigure.h.in +++ b/Source/cmConfigure.h.in @@ -3,3 +3,6 @@ #undef CMAKE_NO_ANSI_STRING_STREAM #undef CMAKE_NO_ANSI_FOR_SCOPE +#undef CMake_VERSION_MAJOR +#undef CMake_VERSION_MINOR +#undef CMake_VERSION_PATCH diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 7143f593f..b386041cc 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -57,6 +57,15 @@ cmMakefile::cmMakefile() this->AddDefaultDefinitions(); } +const char* cmMakefile::GetReleaseVersion() +{ +#if CMake_VERSION_MINOR & 1 + return "development"; +#else + return "patch " CMAKE_TO_STRING(CMake_VERSION_PATCH); +#endif +} + unsigned int cmMakefile::GetCacheMajorVersion() { if(!this->GetCacheManager()->GetCacheValue("CMAKE_CACHE_MAJOR_VERSION")) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index e472781d8..2b7d91f2b 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -46,9 +46,9 @@ public: /** * Return major and minor version numbers for cmake. */ - static unsigned int GetMajorVersion() { return 1;} - static unsigned int GetMinorVersion() { return 7;} - static const char *GetReleaseVersion() { return "development";} + static unsigned int GetMajorVersion() { return CMake_VERSION_MAJOR; } + static unsigned int GetMinorVersion() { return CMake_VERSION_MINOR; } + static const char* GetReleaseVersion(); /** * Return the major and minor version of the cmake that diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h index ceab7fccc..937d9c297 100644 --- a/Source/cmStandardIncludes.h +++ b/Source/cmStandardIncludes.h @@ -21,12 +21,20 @@ #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 and CMAKE_NO_STD_NAMESPACE #if defined(CMAKE_HAS_AUTOCONF) || defined(CMAKE_BUILD_WITH_CMAKE) #include "cmConfigure.h" #endif +#define CMake_VERSION_STRING \ + CMAKE_TO_STRING(CMake_VERSION_MAJOR) "." \ + CMAKE_TO_STRING(CMake_VERSION_MINOR) "." \ + CMAKE_TO_STRING(CMake_VERSION_PATCH) + #ifdef _MSC_VER #pragma warning ( disable : 4786 ) #pragma warning ( disable : 4503 ) diff --git a/configure b/configure index 545b117d3..319226b3e 100755 --- a/configure +++ b/configure @@ -953,13 +953,34 @@ CXXFLAGS=$save_CXXFLAGS +# Parse the cmake version number out of the top-level CMake listfile. + +CMake_VERSION_MAJOR=`cat $fullSrcDir/CMakeLists.txt | sed -n '/SET *( *CMake_VERSION_MAJOR/ {s/.*MAJOR *\([0-9][0-9]*\).*/\1/;p;}'` +CMake_VERSION_MINOR=`cat $fullSrcDir/CMakeLists.txt | sed -n '/SET *( *CMake_VERSION_MINOR/ {s/.*MINOR *\([0-9][0-9]*\).*/\1/;p;}'` +CMake_VERSION_PATCH=`cat $fullSrcDir/CMakeLists.txt | sed -n '/SET *( *CMake_VERSION_PATCH/ {s/.*PATCH *\([0-9][0-9]*\).*/\1/;p;}'` + +cat >> confdefs.h <> confdefs.h <> confdefs.h <&6 -echo "configure:963: checking system version (for dynamic loading)" >&5 +echo "configure:984: checking system version (for dynamic loading)" >&5 if test -f /usr/lib/NextStep/software_version; then system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version` else @@ -998,9 +1019,9 @@ case $system in CFLAGS_ORIG="$FLAGS" CFLAGS="-Aa $CFLAGS" echo $ac_n "checking whether ${CC} accepts -Aa""... $ac_c" 1>&6 -echo "configure:1002: checking whether ${CC} accepts -Aa" >&5 +echo "configure:1023: checking whether ${CC} accepts -Aa" >&5 cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1034: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 @@ -1042,7 +1063,7 @@ rm -f conftest* CXXFLAGS_ORIG="$CXXFLAGS" CXXFLAGS="-std strict_ansi -nopure_cname $CXXFLAGS" echo $ac_n "checking whether ${CXX} accepts -std strict_ansi -nopure_cname""... $ac_c" 1>&6 -echo "configure:1046: checking whether ${CXX} accepts -std strict_ansi -nopure_cname" >&5 +echo "configure:1067: checking whether ${CXX} accepts -std strict_ansi -nopure_cname" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1052,7 +1073,7 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes cross_compiling=$ac_cv_prog_cxx_cross cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1086: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 @@ -1096,7 +1117,7 @@ if test $ac_cv_prog_gxx = no; then CXXFLAGS_ORIG="$CXXFLAGS" CXXFLAGS="$CMAKE_ANSI_CXXFLAGS $CXXFLAGS" echo $ac_n "checking ansi standard C++ stream headers ""... $ac_c" 1>&6 -echo "configure:1100: checking ansi standard C++ stream headers " >&5 +echo "configure:1121: checking ansi standard C++ stream headers " >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1106,7 +1127,7 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes cross_compiling=$ac_cv_prog_cxx_cross cat > conftest.$ac_ext < @@ -1115,7 +1136,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:1119: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1140: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 @@ -1147,7 +1168,7 @@ fi CXXFLAGS_ORIG="$CXXFLAGS" CXXFLAGS="$CMAKE_ANSI_CXXFLAGS $CXXFLAGS" echo $ac_n "checking for ansi standard C++ stringstream""... $ac_c" 1>&6 -echo "configure:1151: checking for ansi standard C++ stringstream" >&5 +echo "configure:1172: checking for ansi standard C++ stringstream" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1157,7 +1178,7 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes cross_compiling=$ac_cv_prog_cxx_cross cat > conftest.$ac_ext < @@ -1166,7 +1187,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:1170: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1191: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 @@ -1198,7 +1219,7 @@ if test $ac_cv_prog_gxx = no; then CXXFLAGS_ORIG="$CXXFLAGS" CXXFLAGS="$CMAKE_ANSI_CXXFLAGS $CXXFLAGS" echo $ac_n "checking whether the std namespace is supported""... $ac_c" 1>&6 -echo "configure:1202: checking whether the std namespace is supported" >&5 +echo "configure:1223: checking whether the std namespace is supported" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1208,7 +1229,7 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes cross_compiling=$ac_cv_prog_cxx_cross cat > conftest.$ac_ext < @@ -1218,7 +1239,7 @@ int main() { ; return 0; } EOF -if { (eval echo configure:1222: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1243: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 @@ -1251,7 +1272,7 @@ if test $ac_cv_prog_gxx = no; then CXXFLAGS_ORIG="$CXXFLAGS" CXXFLAGS="$CMAKE_ANSI_CXXFLAGS $CXXFLAGS" echo $ac_n "checking ansi for scope support""... $ac_c" 1>&6 -echo "configure:1255: checking ansi for scope support" >&5 +echo "configure:1276: checking ansi for scope support" >&5 ac_ext=C # CXXFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. @@ -1261,7 +1282,7 @@ ac_link='${CXX-g++} -o conftest${ac_exeext} $CXXFLAGS $CPPFLAGS $LDFLAGS conftes cross_compiling=$ac_cv_prog_cxx_cross cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:1295: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo "$ac_t""yes" 1>&6 @@ -1435,6 +1456,9 @@ s%@RUNMAKE@%$RUNMAKE%g s%@CC@%$CC%g s%@CXX@%$CXX%g s%@CMAKE_ROOT_DIR@%$CMAKE_ROOT_DIR%g +s%@CMake_VERSION_MAJOR@%$CMake_VERSION_MAJOR%g +s%@CMake_VERSION_MINOR@%$CMake_VERSION_MINOR%g +s%@CMake_VERSION_PATCH@%$CMake_VERSION_PATCH%g s%@CMAKE_CONFIG_DIR@%$CMAKE_CONFIG_DIR%g s%@CMAKE_ANSI_CFLAGS@%$CMAKE_ANSI_CFLAGS%g s%@CMAKE_ANSI_CXXFLAGS@%$CMAKE_ANSI_CXXFLAGS%g diff --git a/configure.in b/configure.in index 8a95c98cc..e5eda4a6b 100644 --- a/configure.in +++ b/configure.in @@ -30,6 +30,18 @@ CXXFLAGS=$save_CXXFLAGS AC_SUBST(CMAKE_ROOT_DIR) +# Parse the cmake version number out of the top-level CMake listfile. +[ +CMake_VERSION_MAJOR=`cat $fullSrcDir/CMakeLists.txt | sed -n '/SET *( *CMake_VERSION_MAJOR/ {s/.*MAJOR *\([0-9][0-9]*\).*/\1/;p;}'` +CMake_VERSION_MINOR=`cat $fullSrcDir/CMakeLists.txt | sed -n '/SET *( *CMake_VERSION_MINOR/ {s/.*MINOR *\([0-9][0-9]*\).*/\1/;p;}'` +CMake_VERSION_PATCH=`cat $fullSrcDir/CMakeLists.txt | sed -n '/SET *( *CMake_VERSION_PATCH/ {s/.*PATCH *\([0-9][0-9]*\).*/\1/;p;}'` +] +AC_DEFINE_UNQUOTED(CMake_VERSION_MAJOR, ${CMake_VERSION_MAJOR}) +AC_DEFINE_UNQUOTED(CMake_VERSION_MINOR, ${CMake_VERSION_MINOR}) +AC_DEFINE_UNQUOTED(CMake_VERSION_PATCH, ${CMake_VERSION_PATCH}) +AC_SUBST(CMake_VERSION_MAJOR) +AC_SUBST(CMake_VERSION_MINOR) +AC_SUBST(CMake_VERSION_PATCH) # Step 1: set the variable "system" to hold the name and version number # for the system. This can usually be done via the "uname" command, but