CMakeVersion.cmake 1.82 KB
Newer Older
Brad King's avatar
Brad King committed
1
# CMake version number components.
Brad King's avatar
Brad King committed
2
set(CMake_VERSION_MAJOR 3)
Brad King's avatar
Brad King committed
3
set(CMake_VERSION_MINOR 15)
Kitware Robot's avatar
Kitware Robot committed
4
set(CMake_VERSION_PATCH 20190726)
5
#set(CMake_VERSION_RC 0)
6
7
8
9
10
11
12

# Releases define a small patch level.
if("${CMake_VERSION_PATCH}" VERSION_LESS 20000000)
  set(CMake_VERSION_IS_DIRTY 0)
  set(CMake_VERSION_IS_RELEASE 1)
  set(CMake_VERSION_SOURCE "")
else()
13
  set(CMake_VERSION_IS_DIRTY 0)
14
  set(CMake_VERSION_IS_RELEASE 0)
15
16
  # Try to identify the current development source version.
  set(CMake_VERSION_SOURCE "")
17
  if(EXISTS ${CMake_SOURCE_DIR}/.git)
18
19
    find_package(Git QUIET)
    if(GIT_FOUND)
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
      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_IS_DIRTY 1)
        endif()
      endif()
    endif()
  endif()
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
endif()

# Compute the full version string.
set(CMake_VERSION ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH})
if(CMake_VERSION_SOURCE)
  set(CMake_VERSION_SUFFIX "${CMake_VERSION_SOURCE}")
elseif(DEFINED CMake_VERSION_RC)
  set(CMake_VERSION_SUFFIX "rc${CMake_VERSION_RC}")
else()
  set(CMake_VERSION_SUFFIX "")
endif()
if(CMake_VERSION_SUFFIX)
  set(CMake_VERSION ${CMake_VERSION}-${CMake_VERSION_SUFFIX})
endif()
if(CMake_VERSION_IS_DIRTY)
  set(CMake_VERSION ${CMake_VERSION}-dirty)
endif()