diff options
author | Brad King <brad.king@kitware.com> | 2010-04-23 14:01:49 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2010-04-23 14:01:49 (GMT) |
commit | 0328379411386abc89ba07991f858cdacca926b2 (patch) | |
tree | 72dd2d12ced1daa4f2dc1b182089c934e01fdb34 | |
parent | e49b6eca4f5857bcf7bfc08e34d0797a3400bcf2 (diff) | |
download | CMake-0328379411386abc89ba07991f858cdacca926b2.zip CMake-0328379411386abc89ba07991f858cdacca926b2.tar.gz CMake-0328379411386abc89ba07991f858cdacca926b2.tar.bz2 |
Report commit hash in CMake development versions
For builds from Git repositories, add "-g<commit>" to the end of the
version number. If the source tree is modified, append "-dirty".
For builds from CVS checkouts, add "-cvs-<branch>".
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | Source/CMakeVersionSource.cmake | 37 | ||||
-rw-r--r-- | Source/cmDocumentVariables.cxx | 6 | ||||
-rw-r--r-- | Tests/FindPackageTest/CMakeLists.txt | 3 |
4 files changed, 49 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index f56beb3..352c1c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -344,6 +344,7 @@ SET(CMake_VERSION_PATCH 0) # Releases define a tweak level. IF(DEFINED CMake_VERSION_TWEAK) SET(CMake_VERSION_IS_RELEASE 1) + SET(CMake_VERSION_SOURCE "") ELSE() SET(CMake_VERSION_IS_RELEASE 0) @@ -352,6 +353,8 @@ ELSE() SET(CMake_VERSION_TWEAK "${KWSYS_DATE_STAMP_YEAR}${KWSYS_DATE_STAMP_MONTH}${KWSYS_DATE_STAMP_DAY}" ) + + INCLUDE(${CMake_SOURCE_DIR}/Source/CMakeVersionSource.cmake) ENDIF() # Compute the full version string. @@ -362,6 +365,9 @@ ENDIF() 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}) +ENDIF() # Include the standard Dart testing module ENABLE_TESTING() diff --git a/Source/CMakeVersionSource.cmake b/Source/CMakeVersionSource.cmake new file mode 100644 index 0000000..05e265c --- /dev/null +++ b/Source/CMakeVersionSource.cmake @@ -0,0 +1,37 @@ +# Try to identify the current development source version. +set(CMake_VERSION_SOURCE "") +if(EXISTS ${CMake_SOURCE_DIR}/.git/HEAD) + find_program(GIT_EXECUTABLE NAMES git git.cmd) + mark_as_advanced(GIT_EXECUTABLE) + if(GIT_EXECUTABLE) + execute_process( + COMMAND ${GIT_EXECUTABLE} rev-parse --verify -q --short=4 HEAD + OUTPUT_VARIABLE head + OUTPUT_STRIP_TRAILING_WHITESPACE + WORKING_DIRECTORY ${CMake_SOURCE_DIR} + ) + if(head) + set(CMake_VERSION_SOURCE "g${head}") + execute_process( + COMMAND ${GIT_EXECUTABLE} update-index -q --refresh + WORKING_DIRECTORY ${CMake_SOURCE_DIR} + ) + execute_process( + COMMAND ${GIT_EXECUTABLE} diff-index --name-only HEAD -- + OUTPUT_VARIABLE dirty + OUTPUT_STRIP_TRAILING_WHITESPACE + WORKING_DIRECTORY ${CMake_SOURCE_DIR} + ) + if(dirty) + set(CMake_VERSION_SOURCE "${CMake_VERSION_SOURCE}-dirty") + endif() + endif() + endif() +elseif(EXISTS ${CMake_SOURCE_DIR}/CVS/Repository) + file(READ ${CMake_SOURCE_DIR}/CVS/Repository repo) + set(branch "") + if("${repo}" MATCHES "\\.git/") + string(REGEX REPLACE ".*\\.git/([^\r\n]*).*" "-\\1" branch "${repo}") + endif() + set(CMake_VERSION_SOURCE "cvs${branch}") +endif() diff --git a/Source/cmDocumentVariables.cxx b/Source/cmDocumentVariables.cxx index b583021..883a757 100644 --- a/Source/cmDocumentVariables.cxx +++ b/Source/cmDocumentVariables.cxx @@ -259,12 +259,14 @@ void cmDocumentVariables::DefineVariables(cmake* cm) ,false, "Variables that Provide Information"); cm->DefineProperty ("CMAKE_VERSION", cmProperty::VARIABLE, - "The full version of cmake in major.minor.patch[.tweak] format.", + "The full version of cmake in major.minor.patch[.tweak[-id]] format.", "This specifies the full version of the CMake executable being run. " "This variable is defined by versions 2.6.3 and higher. " "See variables CMAKE_MAJOR_VERSION, CMAKE_MINOR_VERSION, " "CMAKE_PATCH_VERSION, and CMAKE_TWEAK_VERSION " - "for individual version components.", false, + "for individual version components. " + "The [-id] component appears in non-release versions " + "and may be arbitrary text.", false, "Variables that Provide Information"); cm->DefineProperty diff --git a/Tests/FindPackageTest/CMakeLists.txt b/Tests/FindPackageTest/CMakeLists.txt index 31cf0fc..74cc115 100644 --- a/Tests/FindPackageTest/CMakeLists.txt +++ b/Tests/FindPackageTest/CMakeLists.txt @@ -232,4 +232,5 @@ TRY_COMPILE(EXPORTER_COMPILED MESSAGE(STATUS "Searching for export(PACKAGE) test project") SET(CMakeTestExportPackage_DIR "" CACHE FILEPATH "Wipe out find results for testing." FORCE) -FIND_PACKAGE(CMakeTestExportPackage 1.${CMAKE_VERSION} EXACT REQUIRED) +STRING(REGEX REPLACE "-.*$" "" version ${CMAKE_VERSION}) +FIND_PACKAGE(CMakeTestExportPackage 1.${version} EXACT REQUIRED) |