cmake_minimum_required(VERSION 3.1)

macro(DATE 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" "+%d/%m/%Y" OUTPUT_VARIABLE ${RESULT})
      string(REGEX REPLACE "(..)/(..)/..(..).*" "\\1/\\2/\\3" ${RESULT} ${${RESULT}})
   else(WIN32)
      message(SEND_ERROR "Unable to detect date")
      set(${RESULT} UNKNOWN)
   endif(WIN32)
endmacro(DATE) 

macro(YEAR RESULT)
   if(WIN32)
      execute_process(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${RESULT})
      string(REGEX REPLACE "(..)/(..)/(....).*" "\\3" ${RESULT} ${${RESULT}})
   elseif(UNIX)
      execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE ${RESULT})
      string(REGEX REPLACE "(..)/(..)/(....).*" "\\3" ${RESULT} ${${RESULT}})
   else(WIN32)
      message(SEND_ERROR "Unable to detect date")
      set(${RESULT} UNKNOWN)
   endif(WIN32)
endmacro(YEAR) 
