Hi Daniel, you can use something like the macro in the attached file, adapting
it to fit
your needs. It is not the same as a "cmake -E date" command, but it is useful.
Bye
Droscy
# - Get the current date from the system
# This file defines the macro TODAY that can be used to
# retrive the current date.
#
# This is the definition of the macro
# macro TODAY(result)
#
# After retriving the current date, it set the variable ${result}
# in the format YYYYMMDD. In addition the following variables
# are also set:
# ${result}_YEAR to YYYY
# ${result}_MONTH to MM
# ${result}_DAY to DD
#
# Example:
# include(Today)
# today(CURRENT_DATE)
# message(STATUS
"${CURRENT_DATE_YEAR}-${CURRENT_DATE_MONTH}-${CURRENT_DATE_DAY}")
# will print YYYY-MM-DD.
#
macro(TODAY RESULT)
if(WIN32)
execute_process(COMMAND "cmd" "/C date /T" OUTPUT_VARIABLE ${RESULT})
elseif(UNIX)
execute_process(COMMAND "date" "+%d/%m/%Y" OUTPUT_VARIABLE ${RESULT})
else()
message(WARNING "Cannot get the current date, continue with date equal
to '00000000'")
set(${RESULT} 00000000)
endif()
string(REGEX REPLACE "([0-9][0-9])/([0-9][0-9])/([0-9][0-9][0-9][0-9]).*"
"\\3\\2\\1" ${RESULT} ${${RESULT}})
string(REGEX REPLACE "([0-9][0-9][0-9][0-9])[0-9][0-9][0-9][0-9]" "\\1"
${RESULT}_YEAR ${${RESULT}})
string(REGEX REPLACE "[0-9][0-9][0-9][0-9]([0-9][0-9])[0-9][0-9]" "\\1"
${RESULT}_MONTH ${${RESULT}})
string(REGEX REPLACE "[0-9][0-9][0-9][0-9][0-9][0-9]([0-9][0-9])" "\\1"
${RESULT}_DAY ${${RESULT}})
endmacro(TODAY)
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake