1
# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
1
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
23
23
# If further variables are used in this file, add them to this list.
25
25
SET(VERSION "@VERSION@")
26
SET(MAJOR_VERSION "@MAJOR_VERSION@")
27
SET(MINOR_VERSION "@MINOR_VERSION@")
28
SET(PATCH_VERSION "@PATCH_VERSION@")
26
29
SET(CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@")
27
30
SET(CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@")
28
31
SET(CMAKE_GENERATOR "@CMAKE_GENERATOR@")
29
32
SET(CMAKE_SIZEOF_VOID_P "@CMAKE_SIZEOF_VOID_P@")
30
SET(BZR_EXECUTABLE "@BZR_EXECUTABLE@")
33
SET(GIT_EXECUTABLE "@GIT_EXECUTABLE@")
31
34
SET(CMAKE_CROSSCOMPILING "@CMAKE_CROSSCOMPILING@")
32
35
SET(CMAKE_HOST_SYSTEM "@CMAKE_HOST_SYSTEM@")
33
36
SET(CMAKE_HOST_SYSTEM_PROCESSOR "@CMAKE_HOST_SYSTEM_PROCESSOR@")
38
41
# Create an "INFO_SRC" file with information about the source (only).
39
# We use "bzr version-info", if possible, and the "VERSION" contents.
42
# We use "git log", if possible, and the "VERSION" contents.
41
# Outside development (BZR tree), the "INFO_SRC" file will not be modified
44
# Outside development (git tree), the "INFO_SRC" file will not be modified
42
45
# provided it exists (from "make dist" or a source tarball creation).
44
47
MACRO(CREATE_INFO_SRC target_dir)
45
48
SET(INFO_SRC "${target_dir}/INFO_SRC")
47
IF(EXISTS ${CMAKE_SOURCE_DIR}/.bzr)
48
# Sources are in a BZR repository: Always update.
50
COMMAND ${BZR_EXECUTABLE} version-info ${CMAKE_SOURCE_DIR}
51
"use warnings; use POSIX qw(strftime); "
52
"print strftime \"%F %T %z\", localtime;")
54
COMMAND perl -e "${PERLSCRIPT}"
55
RESULT_VARIABLE result
60
MESSAGE(STATUS "Could not determine build-date: <${error}>")
63
IF(GIT_EXECUTABLE AND EXISTS ${CMAKE_SOURCE_DIR}/.git)
64
# Sources are in a GIT repository: Always update.
66
COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
67
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
72
COMMAND ${GIT_EXECUTABLE} log -1
73
--pretty="commit: %H%ndate: %ci%nbuild-date: ${bdate} %nshort: %h%nbranch: ${bname}"
74
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
51
75
OUTPUT_VARIABLE VERSION_INFO
52
RESULT_VARIABLE RESULT
78
## Output from git is quoted with "", remove them.
79
STRING(REPLACE "\"" "" VERSION_INFO "${VERSION_INFO}")
54
80
FILE(WRITE ${INFO_SRC} "${VERSION_INFO}\n")
55
81
# to debug, add: FILE(APPEND ${INFO_SRC} "\nResult ${RESULT}\n")
56
82
# For better readability ...
57
FILE(APPEND ${INFO_SRC} "\nMySQL source ${VERSION}\n")
83
FILE(APPEND ${INFO_SRC}
84
"MySQL source ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}\n")
58
85
ELSEIF(EXISTS ${INFO_SRC})
59
# Outside a BZR tree, there is no need to change an existing "INFO_SRC",
86
# Outside a git tree, there is no need to change an existing "INFO_SRC",
60
87
# it cannot be improved.
61
88
ELSEIF(EXISTS ${CMAKE_SOURCE_DIR}/Docs/INFO_SRC)
62
89
# If we are building from a source distribution, it also contains "INFO_SRC".