myx-cmake/MyxCMake/modules/MyxCMakeCurrentDate.cmake

20 lines
647 B
CMake
Raw Normal View History

2022-05-06 09:49:46 +00:00
include_guard(GLOBAL)
2021-12-12 19:37:50 +00:00
if(NOT MYX_CMAKE_TODAY)
if(WIN32)
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE MYX_CMAKE_TODAY)
else()
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE MYX_CMAKE_TODAY)
endif()
string(REGEX REPLACE "(..)/(..)/(....).*" "\\3-\\2-\\1" MYX_CMAKE_TODAY ${MYX_CMAKE_TODAY})
endif()
if(NOT MYX_CMAKE_YEAR)
if(WIN32)
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE MYX_CMAKE_YEAR)
else()
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE MYX_CMAKE_YEAR)
endif()
string(REGEX REPLACE "(..)/(..)/(....).*" "\\3" MYX_CMAKE_YEAR ${MYX_CMAKE_YEAR})
endif()