Skip to content

Instantly share code, notes, and snippets.

View tigerlei010's full-sized avatar

LeiYuhou tigerlei010

  • Huawei Ltd
  • shenzhen China
View GitHub Profile
@alorence
alorence / CMakeLists.txt
Last active September 6, 2020 16:41
Two CMake macros returning the current date (format yyyy-mm-dd) and the current time (hh:mm:ss). These are completely useless since CMake 3.0 and the introduction of `string(TIMESTAMP)` command.
cmake_minimum_required(VERSION 2.8)
# Return the date (yyyy-mm-dd)
macro(DATE RESULT)
if(WIN32)
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${RESULT})
string(REGEX REPLACE "(..)/(..)/(....).*" "\\3-\\2-\\1" ${RESULT} ${${RESULT}})
elseif(UNIX)
execute_process(COMMAND "date" "+%Y-%m-%d" OUTPUT_VARIABLE ${RESULT})
else()