Alpine3D

Alpine3D Svn Source Tree

Root/trunk/tools/cmake/BuildVersion.cmake

1#building version number in variable _versionString
2
3MACRO (GETDATE TODAY)
4IF(CMAKE_VERSION VERSION_GREATER 2.8.11)
5STRING(TIMESTAMP TODAY "%Y%m%d")
6ELSE(CMAKE_VERSION VERSION_GREATER 2.8.11)
7IF (WIN32)
8EXECUTE_PROCESS(COMMAND "cmd" " /C date /T" OUTPUT_VARIABLE ${TODAY})
9STRING(REGEX REPLACE "(..)/(..)/(....) .*\n" "\\3\\2\\1" ${TODAY} ${${TODAY}}) #US format
10STRING(REGEX REPLACE "(..)-(..)-(....) .*\n" "\\3\\2\\1" ${TODAY} ${${TODAY}}) #UK format
11STRING(REGEX REPLACE "(..)\\.(..)\\.(....) .*\n" "\\3\\2\\1" ${TODAY} ${${TODAY}}) #CH format
12ELSEIF(UNIX)
13EXECUTE_PROCESS(COMMAND "date" "+%Y-%m-%d" OUTPUT_VARIABLE ${TODAY})
14string(REGEX REPLACE "(....)-(..)-(..).*" "\\1\\2\\3" ${TODAY} ${${TODAY}})
15ELSE (WIN32)
16MESSAGE(SEND_ERROR "date not implemented")
17SET(${TODAY} 000000)
18ENDIF (WIN32)
19ENDIF(CMAKE_VERSION VERSION_GREATER 2.8.11)
20ENDMACRO (GETDATE)
21
22MACRO(BuildVersion)
23FIND_PACKAGE(Subversion)
24IF(Subversion_FOUND)
25SET(VERSION_FROM_SVN OFF CACHE BOOL "Retrieve software version from Subversion")
26IF(VERSION_FROM_SVN)
27Subversion_WC_INFO(${PROJECT_SOURCE_DIR} project) #HACK: if not an svn tree, it does not work
28GETDATE(TODAY)
29SET(_versionString "${TODAY}.${project_WC_REVISION}")
30ELSE(VERSION_FROM_SVN)
31SET(_versionString "${VERSION_MAJOR}.${VERSION_MINOR}${VERSION_PATCH}")
32ENDIF(VERSION_FROM_SVN)
33ELSE(Subversion_FOUND)
34SET(_versionString "${VERSION_MAJOR}.${VERSION_MINOR}${VERSION_PATCH}")
35ENDIF(Subversion_FOUND)
36ENDMACRO(BuildVersion)

Archive Download this file

Revision: HEAD