[REACTOS]
[reactos.git] / reactos / include / reactos / version.cmake
1 macro(today RESULT)
2 if(CMAKE_HOST_WIN32)
3 execute_process(COMMAND wmic os get LocalDateTime OUTPUT_VARIABLE RAWDATE)
4 string(REPLACE "\n" ";" RAWDATE ${RAWDATE})
5 LIST(GET RAWDATE 1 RAWDATE)
6 string(SUBSTRING ${RAWDATE} 0 8 ${RESULT})
7 elseif(CMAKE_HOST_UNIX)
8 execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE ${RESULT})
9 string(STRIP ${${RESULT}} ${RESULT})
10 else()
11 message(SEND_ERROR "date not implemented")
12 set(${RESULT} 00000000)
13 endif()
14 endmacro()
15
16 macro(inttohex INTVALUE OUTPUT_VARIABLE)
17 list(APPEND HEXLIST 0 1 2 3 4 5 6 7 8 9 a b c d e f)
18 list(GET HEXLIST ${INTVALUE} ${OUTPUT_VARIABLE})
19 endmacro()
20
21 macro(converttohex INTVALUE OUTPUT_VARIABLE)
22 set(${OUTPUT_VARIABLE} "")
23 set(REMAINING ${INTVALUE})
24 while(REMAINING)
25 math(EXPR REMAINDER "${REMAINING}%16")
26 inttohex(${REMAINDER} HEXCHAR)
27 math(EXPR REMAINING "${REMAINING}/16")
28 set(${OUTPUT_VARIABLE} "${HEXCHAR}${${OUTPUT_VARIABLE}}")
29 endwhile()
30 endmacro()
31
32 today(KERNEL_VERSION_BUILD)
33
34 set(KERNEL_VERSION_MAJOR "0")
35 set(KERNEL_VERSION_MINOR "4")
36 set(KERNEL_VERSION_PATCH_LEVEL "0")
37 set(COPYRIGHT_YEAR "2014")
38 # KERNEL_VERSION_BUILD_TYPE is "SVN", "RC1", "RC2" or "" (for the release)
39 set(KERNEL_VERSION_BUILD_TYPE "SVN")
40
41
42 set(KERNEL_VERSION "${KERNEL_VERSION_MAJOR}.${KERNEL_VERSION_MINOR}")
43 if(KERNEL_VERSION_PATCH_LEVEL)
44 set(KERNEL_VERSION "${KERNEL_VERSION}.${KERNEL_VERSION_PATCH_LEVEL}-${KERNEL_VERSION_BUILD_TYPE}")
45 else()
46 set(KERNEL_VERSION "${KERNEL_VERSION}-${KERNEL_VERSION_BUILD_TYPE}")
47 endif()
48
49 math(EXPR REACTOS_DLL_VERSION_MAJOR "${KERNEL_VERSION_MAJOR}+42")
50 set(DLL_VERSION_STR "${REACTOS_DLL_VERSION_MAJOR}.${KERNEL_VERSION_MINOR}-${KERNEL_VERSION_BUILD_TYPE}")
51
52 # get svn revision number
53 set(REVISION "-rUNKNOWN")
54 set(KERNEL_VERSION_BUILD_HEX "0")
55 if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.svn")
56 find_package(Subversion)
57 if(Subversion_FOUND)
58 subversion_wc_info(${CMAKE_CURRENT_SOURCE_DIR} SVNINFO)
59 if(SVNINFO_WC_REVISION)
60 set(REVISION "-r${SVNINFO_WC_REVISION}")
61 converttohex(${SVNINFO_WC_REVISION} KERNEL_VERSION_BUILD_HEX)
62 endif()
63 endif()
64 endif()
65
66 configure_file(include/reactos/version.h.cmake ${REACTOS_BINARY_DIR}/include/reactos/version.h)
67 configure_file(include/reactos/buildno.h.cmake ${REACTOS_BINARY_DIR}/include/reactos/buildno.h)
68 configure_file(include/reactos/builddir.h.cmake ${REACTOS_BINARY_DIR}/include/reactos/builddir.h)