2323# If further variables are used in this file, add them to this list.
2424
2525SET (VERSION "@VERSION@" )
26+ SET (MAJOR_VERSION "@MAJOR_VERSION@" )
27+ SET (MINOR_VERSION "@MINOR_VERSION@" )
28+ SET (PATCH_VERSION "@PATCH_VERSION@" )
2629SET (CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@" )
2730SET (CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@" )
2831SET (CMAKE_GENERATOR "@CMAKE_GENERATOR@" )
2932SET (CMAKE_SIZEOF_VOID_P "@CMAKE_SIZEOF_VOID_P@" )
30- SET (BZR_EXECUTABLE "@BZR_EXECUTABLE@" )
3133SET (GIT_EXECUTABLE "@GIT_EXECUTABLE@" )
3234SET (CMAKE_CROSSCOMPILING "@CMAKE_CROSSCOMPILING@" )
3335SET (CMAKE_HOST_SYSTEM "@CMAKE_HOST_SYSTEM@" )
@@ -45,41 +47,41 @@ SET(CMAKE_SYSTEM_PROCESSOR "@CMAKE_SYSTEM_PROCESSOR@")
4547MACRO (CREATE_INFO_SRC target_dir )
4648 SET (INFO_SRC "${target_dir} /INFO_SRC" )
4749
50+ SET (PERLSCRIPT
51+ "use warnings; use POSIX qw(strftime); "
52+ "print strftime \" %F %T %z\" , localtime;" )
53+ EXECUTE_PROCESS (
54+ COMMAND perl -e "${PERLSCRIPT} "
55+ RESULT_VARIABLE result
56+ OUTPUT_VARIABLE bdate
57+ ERROR_VARIABLE error
58+ )
59+ IF (error)
60+ MESSAGE (STATUS "Could not determine build-date: <${error} >" )
61+ ENDIF ()
62+
4863 IF (GIT_EXECUTABLE AND EXISTS ${CMAKE_SOURCE_DIR} /.git)
4964 # Sources are in a GIT repository: Always update.
5065 EXECUTE_PROCESS (
51- COMMAND ${GIT_EXECUTABLE} log -1
66+ COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
5267 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
53- OUTPUT_VARIABLE VERSION_INFO
54- RESULT_VARIABLE RESULT
68+ OUTPUT_VARIABLE bname
5569 )
56- FILE ( WRITE ${INFO_SRC} "git log -1: ${VERSION_INFO} \n " )
70+
5771 EXECUTE_PROCESS (
58- COMMAND ${GIT_EXECUTABLE} branch
72+ COMMAND ${GIT_EXECUTABLE} log -1
73+ --pretty= "commit: %H%ndate: %ci%nbuild-date: ${bdate} %nshort: %h%nbranch: ${bname} "
5974 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
6075 OUTPUT_VARIABLE VERSION_INFO
61- RESULT_VARIABLE RESULT
6276 )
63- FILE (APPEND ${INFO_SRC} "${VERSION_INFO} \n " )
64- FILE (APPEND ${INFO_SRC} "\n MySQL source ${VERSION} \n " )
65- ELSEIF (BZR_EXECUTABLE AND EXISTS ${CMAKE_SOURCE_DIR} /.bzr)
66- # Sources are in a BZR repository: Always update.
67- # Add a timeout in case BZR hangs forever ...
68- EXECUTE_PROCESS (
69- COMMAND ${BZR_EXECUTABLE} version -info ${CMAKE_SOURCE_DIR}
70- OUTPUT_VARIABLE VERSION_INFO
71- RESULT_VARIABLE RESULT
72- ERROR_VARIABLE ERROR
73- TIMEOUT 10
74- )
75- IF (NOT RESULT EQUAL 0)
76- MESSAGE (STATUS "Error from ${BZR_EXECUTABLE} : ${ERROR} " )
77- SET (BZR_EXECUTABLE)
78- ENDIF ()
77+
78+ ## Output from git is quoted with "", remove them.
79+ STRING (REPLACE "\" " "" VERSION_INFO "${VERSION_INFO} " )
7980 FILE (WRITE ${INFO_SRC} "${VERSION_INFO} \n " )
8081 # to debug, add: FILE(APPEND ${INFO_SRC} "\nResult ${RESULT}\n")
8182 # For better readability ...
82- FILE (APPEND ${INFO_SRC} "\n MySQL source ${VERSION} \n " )
83+ FILE (APPEND ${INFO_SRC}
84+ "MySQL source ${MAJOR_VERSION} .${MINOR_VERSION} .${PATCH_VERSION} \n " )
8385 ELSEIF (EXISTS ${INFO_SRC} )
8486 # Outside a BZR tree, there is no need to change an existing "INFO_SRC",
8587 # it cannot be improved.
0 commit comments