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