From d9d599e94f573f0acde193f5acd692cdf72c0ee5 Mon Sep 17 00:00:00 2001 From: kervala Date: Sun, 29 Nov 2015 14:10:42 +0100 Subject: [PATCH] Fixed: Use STRING(TIMESTAMP ...) since CMake 2.8.11 to get build time --- code/CMakeModules/GetRevision.cmake | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/code/CMakeModules/GetRevision.cmake b/code/CMakeModules/GetRevision.cmake index 7e42274cf..f760e0420 100644 --- a/code/CMakeModules/GetRevision.cmake +++ b/code/CMakeModules/GetRevision.cmake @@ -24,17 +24,21 @@ ELSE() ENDIF() MACRO(NOW RESULT) - IF (WIN32) - EXECUTE_PROCESS(COMMAND "wmic" "os" "get" "localdatetime" OUTPUT_VARIABLE DATETIME) - IF(NOT DATETIME MATCHES "ERROR") - STRING(REGEX REPLACE ".*\n([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9]).*" "\\1-\\2-\\3 \\4:\\5:\\6" ${RESULT} "${DATETIME}") - ENDIF() - ELSEIF(UNIX) - EXECUTE_PROCESS(COMMAND "date" "+%Y-%m-%d %H:%M:%S" OUTPUT_VARIABLE DATETIME) - STRING(REGEX REPLACE "([0-9: -]+).*" "\\1" ${RESULT} "${DATETIME}") + IF(CMAKE_VERSION VERSION_GREATER "2.8.10") + STRING(TIMESTAMP ${RESULT} "%Y-%m-%d %H:%M:%S") ELSE() - MESSAGE(SEND_ERROR "date not implemented") - SET(${RESULT} "0000-00-00 00:00:00") + IF(WIN32) + EXECUTE_PROCESS(COMMAND "wmic" "os" "get" "localdatetime" OUTPUT_VARIABLE DATETIME) + IF(NOT DATETIME MATCHES "ERROR") + STRING(REGEX REPLACE ".*\n([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9])([0-9][0-9]).*" "\\1-\\2-\\3 \\4:\\5:\\6" ${RESULT} "${DATETIME}") + ENDIF() + ELSEIF(UNIX) + EXECUTE_PROCESS(COMMAND "date" "+%Y-%m-%d %H:%M:%S" OUTPUT_VARIABLE DATETIME) + STRING(REGEX REPLACE "([0-9: -]+).*" "\\1" ${RESULT} "${DATETIME}") + ELSE() + MESSAGE(SEND_ERROR "date not implemented") + SET(${RESULT} "0000-00-00 00:00:00") + ENDIF() ENDIF() ENDMACRO()