Merge pull request #3404 from opentx/bsongis/horus_icons_cache
[opentx.git] / cmake / Macros.cmake
blob689626b2d0a0bb938dbb10a88a8966638fbbd3b3
1 macro(today RESULT)
2   if(WIN32)
3     execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${RESULT})
4     string(REGEX REPLACE "(..)/(..)/(....).*" "\\1.\\2.\\3" ${RESULT} ${${RESULT}})
5     string(SUBSTRING ${${RESULT}} 0 10 ${RESULT})
6   elseif(UNIX)
7     execute_process(COMMAND "date" "+%Y-%m-%d" OUTPUT_VARIABLE ${RESULT})
8     string(REGEX REPLACE "(....)-(..)-(..).*" "\\1-\\2-\\3" ${RESULT} ${${RESULT}})
9   else(WIN32)
10     message(SEND_ERROR "date not implemented")
11     set(${RESULT} 00.00.0000)
12   endif(WIN32)
13 endmacro(today)
15 macro(now RESULT)
16   if(WIN32)
17     execute_process(COMMAND "cmd" " /C time /T" OUTPUT_VARIABLE ${RESULT})
18     string(REGEX REPLACE "(..):(..).*" "\\1:\\2:00" ${RESULT} ${${RESULT}})
19   elseif(UNIX)
20     execute_process(COMMAND "date" "+%H:%M:%S" OUTPUT_VARIABLE ${RESULT})
21     string(REGEX REPLACE "(..):(..):(..).*" "\\1:\\2:\\3" ${RESULT} ${${RESULT}})
22   else(WIN32)
23     message(SEND_ERROR "time not implemented")
24     set(${RESULT} 00:00:00)
25   endif(WIN32)
26 endmacro(now)
28 macro(git_id RESULT)
29   if(WIN32)
30     execute_process(COMMAND "cmd" " /C git --git-dir=${PROJECT_SOURCE_DIR}/.git rev-parse HEAD" OUTPUT_VARIABLE ${RESULT})
31     string(REGEX REPLACE "(.*)\n" "\\1" ${RESULT} ${${RESULT}})
32   elseif(UNIX)
33     execute_process(COMMAND "git" "--git-dir=${PROJECT_SOURCE_DIR}/.git" "rev-parse" "HEAD" OUTPUT_VARIABLE ${RESULT})
34     string(REGEX REPLACE "(.*)\n" "\\1" ${RESULT} ${${RESULT}})
35   else(WIN32)
36     message(SEND_ERROR "Git ID implemented")
37     set(${RESULT} 0)
38   endif(WIN32)
39 endmacro(git_id)