summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2010-04-23 14:01:49 (GMT)
committerBrad King <brad.king@kitware.com>2010-04-23 14:01:49 (GMT)
commit0328379411386abc89ba07991f858cdacca926b2 (patch)
tree72dd2d12ced1daa4f2dc1b182089c934e01fdb34 /Source
parente49b6eca4f5857bcf7bfc08e34d0797a3400bcf2 (diff)
downloadCMake-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>".
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeVersionSource.cmake37
-rw-r--r--Source/cmDocumentVariables.cxx6
2 files changed, 41 insertions, 2 deletions
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