1 # CMake version number components.
2 set(CMake_VERSION_MAJOR 3)
3 set(CMake_VERSION_MINOR 31)
4 set(CMake_VERSION_PATCH 20241121)
5 #set(CMake_VERSION_RC 0)
6 set(CMake_VERSION_IS_DIRTY 0)
8 # Start with the full version number used in tags. It has no dev info.
10 "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}")
11 if(DEFINED CMake_VERSION_RC)
12 string(APPEND CMake_VERSION "-rc${CMake_VERSION_RC}")
15 # Releases define a small patch level.
16 if("${CMake_VERSION_PATCH}" VERSION_LESS 20000000)
17 set(CMake_VERSION_IS_RELEASE 1)
19 set(CMake_VERSION_IS_RELEASE 0)
22 if(NOT CMake_VERSION_NO_GIT)
23 # If this source was exported by 'git archive', use its commit info.
24 set(git_info [==[$Format:%h %s$]==])
26 # Otherwise, try to identify the current development source version.
27 if(NOT git_info MATCHES "^([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]?[0-9a-f]?)[0-9a-f]* "
28 AND EXISTS ${CMake_SOURCE_DIR}/.git)
29 find_package(Git QUIET)
33 COMMAND ${GIT_EXECUTABLE} ${ARGN}
34 WORKING_DIRECTORY ${CMake_SOURCE_DIR}
35 RESULT_VARIABLE _git_res
36 OUTPUT_VARIABLE _git_out OUTPUT_STRIP_TRAILING_WHITESPACE
37 ERROR_VARIABLE _git_err ERROR_STRIP_TRAILING_WHITESPACE
42 # Get the commit checked out in this work tree.
43 _git(log -n 1 HEAD "--pretty=format:%h %s" --)
44 set(git_info "${_git_out}")
48 # Extract commit information if available.
49 if(git_info MATCHES "^([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]?[0-9a-f]?)[0-9a-f]* (.*)$")
50 # Have commit information.
51 set(git_hash "${CMAKE_MATCH_1}")
52 set(git_subject "${CMAKE_MATCH_2}")
54 # If this is not the exact commit of a release, add dev info.
55 if(NOT "${git_subject}" MATCHES "^[Cc][Mm]ake ${CMake_VERSION}$")
56 string(APPEND CMake_VERSION "-g${git_hash}")
59 # If this is a work tree, check whether it is dirty.
61 _git(update-index -q --refresh)
62 _git(diff-index --name-only HEAD --)
64 set(CMake_VERSION_IS_DIRTY 1)
68 # No commit information.
69 if(NOT CMake_VERSION_IS_RELEASE)
70 # Generic development version.
71 string(APPEND CMake_VERSION "-git")
76 # Extract the version suffix component.
77 if(CMake_VERSION MATCHES "-(.*)$")
78 set(CMake_VERSION_SUFFIX "${CMAKE_MATCH_1}")
80 set(CMake_VERSION_SUFFIX "")
82 if(CMake_VERSION_IS_DIRTY)
83 string(APPEND CMake_VERSION "-dirty")