2eabee77ba22992c5428347fdfd6295f53e47cf8
[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 "8")
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 WORKING_DIRECTORY ${REACTOS_SOURCE_DIR}
33 OUTPUT_VARIABLE GIT_COMMIT_HASH
34 RESULT_VARIABLE GIT_CALL_RESULT
35 OUTPUT_STRIP_TRAILING_WHITESPACE
36 )
37 if(GIT_CALL_RESULT EQUAL 0)
38 set(COMMIT_HASH "${GIT_COMMIT_HASH}")
39 endif()
40
41 execute_process(
42 COMMAND "${GIT_EXECUTABLE}" describe --abbrev=7
43 WORKING_DIRECTORY ${REACTOS_SOURCE_DIR}
44 OUTPUT_VARIABLE GIT_DESCRIBE_REVISION
45 RESULT_VARIABLE GIT_CALL_RESULT
46 OUTPUT_STRIP_TRAILING_WHITESPACE
47 )
48 if(GIT_CALL_RESULT EQUAL 0)
49 set(REVISION "${GIT_DESCRIBE_REVISION}")
50 endif()
51 endif()
52 endif()
53
54 configure_file(sdk/include/reactos/version.h.cmake ${REACTOS_BINARY_DIR}/sdk/include/reactos/version.h)
55 configure_file(sdk/include/reactos/buildno.h.cmake ${REACTOS_BINARY_DIR}/sdk/include/reactos/buildno.h)
56 configure_file(sdk/include/reactos/builddir.h.cmake ${REACTOS_BINARY_DIR}/sdk/include/reactos/builddir.h)