e5f0bb1bed787e149095acd8fd3cacbf46d0000f
[reactos.git] / sdk / include / reactos / version.cmake
1 macro(inttohex INTVALUE OUTPUT_VARIABLE)
2 list(APPEND HEXLIST 0 1 2 3 4 5 6 7 8 9 a b c d e f)
3 list(GET HEXLIST ${INTVALUE} ${OUTPUT_VARIABLE})
4 endmacro()
5
6 macro(converttohex INTVALUE OUTPUT_VARIABLE)
7 set(${OUTPUT_VARIABLE} "")
8 set(REMAINING ${INTVALUE})
9 while(REMAINING)
10 math(EXPR REMAINDER "${REMAINING}%16")
11 inttohex(${REMAINDER} HEXCHAR)
12 math(EXPR REMAINING "${REMAINING}/16")
13 set(${OUTPUT_VARIABLE} "${HEXCHAR}${${OUTPUT_VARIABLE}}")
14 endwhile()
15 endmacro()
16
17 string(TIMESTAMP KERNEL_VERSION_BUILD %Y%m%d UTC)
18
19 set(KERNEL_VERSION_MAJOR "0")
20 set(KERNEL_VERSION_MINOR "5")
21 set(KERNEL_VERSION_PATCH_LEVEL "0")
22 set(COPYRIGHT_YEAR "2017")
23
24 # KERNEL_VERSION_BUILD_TYPE is "SVN" or "" (for the release)
25 set(KERNEL_VERSION_BUILD_TYPE "SVN")
26
27 # KERNEL_VERSION_RELEASE_TYPE is "RC1", "RC2" or "" (for the final one)
28 set(KERNEL_VERSION_RELEASE_TYPE "")
29
30 set(KERNEL_VERSION "${KERNEL_VERSION_MAJOR}.${KERNEL_VERSION_MINOR}")
31 if(KERNEL_VERSION_PATCH_LEVEL)
32 set(KERNEL_VERSION "${KERNEL_VERSION}.${KERNEL_VERSION_PATCH_LEVEL}")
33 endif()
34 if(KERNEL_VERSION_BUILD_TYPE STREQUAL "SVN")
35 set(KERNEL_VERSION "${KERNEL_VERSION}-${KERNEL_VERSION_BUILD_TYPE}")
36 elseif(NOT KERNEL_VERSION_RELEASE_TYPE STREQUAL "")
37 set(KERNEL_VERSION "${KERNEL_VERSION}-${KERNEL_VERSION_RELEASE_TYPE}")
38 endif()
39
40 math(EXPR REACTOS_DLL_VERSION_MAJOR "${KERNEL_VERSION_MAJOR}+42")
41 set(DLL_VERSION_STR "${REACTOS_DLL_VERSION_MAJOR}.${KERNEL_VERSION_MINOR}")
42 if(KERNEL_VERSION_PATCH_LEVEL)
43 set(DLL_VERSION_STR "${DLL_VERSION_STR}.${KERNEL_VERSION_PATCH_LEVEL}")
44 endif()
45 if(KERNEL_VERSION_BUILD_TYPE STREQUAL "SVN")
46 set(DLL_VERSION_STR "${DLL_VERSION_STR}-${KERNEL_VERSION_BUILD_TYPE}")
47 elseif(NOT KERNEL_VERSION_RELEASE_TYPE STREQUAL "")
48 set(DLL_VERSION_STR "${DLL_VERSION_STR}-${KERNEL_VERSION_RELEASE_TYPE}")
49 endif()
50
51 # get svn revision number
52 set(REVISION "rUNKNOWN")
53 set(KERNEL_VERSION_BUILD_HEX "0")
54 if(EXISTS "${REACTOS_SOURCE_DIR}/.svn" OR EXISTS "${REACTOS_SOURCE_DIR}/../.svn")
55 find_package(Subversion)
56 if(Subversion_FOUND)
57 subversion_wc_info(${REACTOS_SOURCE_DIR} SVNINFO)
58 if(SVNINFO_WC_REVISION)
59 set(REVISION "r${SVNINFO_WC_REVISION}")
60 converttohex(${SVNINFO_WC_REVISION} KERNEL_VERSION_BUILD_HEX)
61 endif()
62 endif()
63 endif()
64
65 configure_file(sdk/include/reactos/version.h.cmake ${REACTOS_BINARY_DIR}/sdk/include/reactos/version.h)
66 configure_file(sdk/include/reactos/buildno.h.cmake ${REACTOS_BINARY_DIR}/sdk/include/reactos/buildno.h)
67 configure_file(sdk/include/reactos/builddir.h.cmake ${REACTOS_BINARY_DIR}/sdk/include/reactos/builddir.h)