mirror of
https://github.com/opentx/opentx.git
synced 2025-07-13 03:19:53 +03:00
38 lines
1.5 KiB
CMake
38 lines
1.5 KiB
CMake
macro(today RESULT)
|
|
if(WIN32)
|
|
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${RESULT})
|
|
string(REGEX REPLACE "(..)/(..)/(....).*" "\\1.\\2.\\3" ${RESULT} ${${RESULT}})
|
|
elseif(UNIX)
|
|
execute_process(COMMAND "date" "+%Y-%m-%d" OUTPUT_VARIABLE ${RESULT})
|
|
string(REGEX REPLACE "(....)-(..)-(..).*" "\\1-\\2-\\3" ${RESULT} ${${RESULT}})
|
|
else(WIN32)
|
|
message(SEND_ERROR "date not implemented")
|
|
set(${RESULT} 00.00.0000)
|
|
endif(WIN32)
|
|
endmacro(today)
|
|
|
|
macro(now RESULT)
|
|
if(WIN32)
|
|
execute_process(COMMAND "cmd" " /C time /T" OUTPUT_VARIABLE ${RESULT})
|
|
string(REGEX REPLACE "(..):(..).*" "\\1:\\2:00" ${RESULT} ${${RESULT}})
|
|
elseif(UNIX)
|
|
execute_process(COMMAND "date" "+%H:%M:%S" OUTPUT_VARIABLE ${RESULT})
|
|
string(REGEX REPLACE "(..):(..):(..).*" "\\1:\\2:\\3" ${RESULT} ${${RESULT}})
|
|
else(WIN32)
|
|
message(SEND_ERROR "time not implemented")
|
|
set(${RESULT} 00:00:00)
|
|
endif(WIN32)
|
|
endmacro(now)
|
|
|
|
macro(git_id RESULT)
|
|
if(WIN32)
|
|
execute_process(COMMAND "cmd" " /C git --git-dir=${PROJECT_SOURCE_DIR}/.git rev-parse HEAD" OUTPUT_VARIABLE ${RESULT})
|
|
string(REGEX REPLACE "(.*)\n" "\\1" ${RESULT} ${${RESULT}})
|
|
elseif(UNIX)
|
|
execute_process(COMMAND "git" "--git-dir=${PROJECT_SOURCE_DIR}/.git" "rev-parse" "HEAD" OUTPUT_VARIABLE ${RESULT})
|
|
string(REGEX REPLACE "(.*)\n" "\\1" ${RESULT} ${${RESULT}})
|
|
else(WIN32)
|
|
message(SEND_ERROR "Git ID implemented")
|
|
set(${RESULT} 0)
|
|
endif(WIN32)
|
|
endmacro(git_id)
|