myx-cmake-example-features/cmake/myx/lib/CurrentDate.cmake

20 lines
655 B
CMake
Raw Normal View History

2022-10-06 12:22:57 +00:00
include_guard(GLOBAL)
if(NOT MYX_TODAY)
2022-10-20 09:53:06 +00:00
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
2022-10-06 12:22:57 +00:00
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE MYX_TODAY)
else()
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE MYX_TODAY)
endif()
string(REGEX REPLACE "(..)/(..)/(....).*" "\\3-\\2-\\1" MYX_TODAY ${MYX_TODAY})
endif()
if(NOT MYX_YEAR)
2022-10-20 09:53:06 +00:00
if(CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)
2022-10-06 12:22:57 +00:00
execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE MYX_YEAR)
else()
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE MYX_YEAR)
endif()
string(REGEX REPLACE "(..)/(..)/(....).*" "\\3" MYX_YEAR ${MYX_YEAR})
endif()