2011-02-25 04:02:58 +00:00
|
|
|
# This is called by cmake as an extermal process from
|
2011-02-24 17:57:35 +00:00
|
|
|
# ./source/creator/CMakeLists.txt to write ./source/creator/buildinfo.h
|
|
|
|
|
2011-02-25 04:02:58 +00:00
|
|
|
# The FindSubversion.cmake module is part of the standard distribution
|
2011-02-24 17:57:35 +00:00
|
|
|
include(FindSubversion)
|
2011-02-25 04:02:58 +00:00
|
|
|
|
|
|
|
# Extract working copy information for SOURCE_DIR into MY_XXX variables
|
|
|
|
# with a default in case anything fails, for examble when using git-svn
|
|
|
|
set(MY_WC_REVISION "unknown")
|
|
|
|
# Guess if this is a SVN working copy and then look up the revision
|
2011-02-25 06:03:01 +00:00
|
|
|
if(EXISTS ${SOURCE_DIR}/.svn/)
|
2011-02-25 04:02:58 +00:00
|
|
|
if(Subversion_FOUND)
|
2011-02-25 06:03:01 +00:00
|
|
|
Subversion_WC_INFO(${SOURCE_DIR} MY)
|
2011-02-25 04:02:58 +00:00
|
|
|
endif()
|
2011-02-24 17:57:35 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# BUILD_PLATFORM and BUILD_PLATFORM are taken from CMake
|
2011-02-25 04:02:58 +00:00
|
|
|
# but BUILD_DATE and BUILD_TIME are plataform dependant
|
2011-02-24 17:57:35 +00:00
|
|
|
if(UNIX)
|
|
|
|
execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BUILD_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2011-02-25 00:02:08 +00:00
|
|
|
execute_process(COMMAND date "+%H:%M:%S" OUTPUT_VARIABLE BUILD_TIME OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2011-02-24 17:57:35 +00:00
|
|
|
endif()
|
|
|
|
if(WIN32)
|
|
|
|
execute_process(COMMAND cmd /c date /t OUTPUT_VARIABLE BUILD_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2011-02-25 00:02:08 +00:00
|
|
|
execute_process(COMMAND cmd /c time /t OUTPUT_VARIABLE BUILD_TIME OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2011-02-24 17:57:35 +00:00
|
|
|
endif()
|
|
|
|
|
2011-02-25 04:02:58 +00:00
|
|
|
# Write a file with the SVNVERSION define
|
2011-02-24 17:57:35 +00:00
|
|
|
file(WRITE buildinfo.h.txt
|
2011-08-22 12:24:14 +00:00
|
|
|
"#define BUILD_REV \"${MY_WC_REVISION}\"\n"
|
|
|
|
"#define BUILD_DATE \"${BUILD_DATE}\"\n"
|
|
|
|
"#define BUILD_TIME \"${BUILD_TIME}\"\n"
|
2011-02-24 17:57:35 +00:00
|
|
|
)
|
|
|
|
|
2011-02-25 04:02:58 +00:00
|
|
|
# Copy the file to the final header only if the version changes
|
|
|
|
# and avoid needless rebuilds
|
2011-02-25 06:03:01 +00:00
|
|
|
# TODO: verify this comment is true, as BUILD_TIME probably changes
|
2011-02-24 17:57:35 +00:00
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
|
|
buildinfo.h.txt buildinfo.h)
|