Make ReactOS report the Git revision as output by "git describe".
[reactos.git] / sdk / include / reactos / version.cmake
1 string(TIMESTAMP KERNEL_VERSION_BUILD %Y%m%d UTC)
2
3 set(KERNEL_VERSION_MAJOR "0")
4 set(KERNEL_VERSION_MINOR "4")
5 set(KERNEL_VERSION_PATCH_LEVEL "7")
6 set(COPYRIGHT_YEAR "2017")
7
8 # KERNEL_VERSION_BUILD_TYPE is "dev" for Git builds
9 # or "RC1", "RC2", "" for releases.
10 set(KERNEL_VERSION_BUILD_TYPE "dev")
11
12 set(KERNEL_VERSION "${KERNEL_VERSION_MAJOR}.${KERNEL_VERSION_MINOR}.${KERNEL_VERSION_PATCH_LEVEL}")
13 if(NOT KERNEL_VERSION_BUILD_TYPE STREQUAL "")
14 set(KERNEL_VERSION "${KERNEL_VERSION}-${KERNEL_VERSION_BUILD_TYPE}")
15 endif()
16
17 math(EXPR REACTOS_DLL_VERSION_MAJOR "${KERNEL_VERSION_MAJOR}+42")
18 set(DLL_VERSION_STR "${REACTOS_DLL_VERSION_MAJOR}.${KERNEL_VERSION_MINOR}.${KERNEL_VERSION_PATCH_LEVEL}")
19 if(NOT KERNEL_VERSION_BUILD_TYPE STREQUAL "")
20 set(DLL_VERSION_STR "${DLL_VERSION_STR}-${KERNEL_VERSION_BUILD_TYPE}")
21 endif()
22
23 # Get Git revision through "git describe"
24 set(COMMIT_HASH "unknown-hash")
25 set(REVISION "unknown-revision")
26
27 if(EXISTS "${REACTOS_SOURCE_DIR}/.git")
28 find_package(Git)
29 if(GIT_FOUND)
30 execute_process(
31 COMMAND "${GIT_EXECUTABLE}" rev-parse HEAD
32 OUTPUT_VARIABLE GIT_COMMIT_HASH
33 RESULT_VARIABLE GIT_CALL_RESULT
34 OUTPUT_STRIP_TRAILING_WHITESPACE
35 )
36 if(GIT_CALL_RESULT EQUAL 0)
37 set(COMMIT_HASH "${GIT_COMMIT_HASH}")
38 endif()
39
40 execute_process(
41 COMMAND "${GIT_EXECUTABLE}" describe
42 OUTPUT_VARIABLE GIT_DESCRIBE_REVISION
43 RESULT_VARIABLE GIT_CALL_RESULT
44 OUTPUT_STRIP_TRAILING_WHITESPACE
45 )
46 if(GIT_CALL_RESULT EQUAL 0)
47 set(REVISION "${GIT_DESCRIBE_REVISION}")
48 endif()
49 endif()
50 endif()
51
52 configure_file(sdk/include/reactos/version.h.cmake ${REACTOS_BINARY_DIR}/sdk/include/reactos/version.h)
53 configure_file(sdk/include/reactos/buildno.h.cmake ${REACTOS_BINARY_DIR}/sdk/include/reactos/buildno.h)
54 configure_file(sdk/include/reactos/builddir.h.cmake ${REACTOS_BINARY_DIR}/sdk/include/reactos/builddir.h)