1# Copyright (c) 2009, 2012, Oracle and/or its affiliates.
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; version 2 of the License.
6#
7# This program is distributed in the hope that it will be useful,
8# but WITHOUT ANY WARRANTY; without even the implied warranty of
9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10# GNU General Public License for more details.
11#
12# You should have received a copy of the GNU General Public License
13# along with this program; if not, write to the Free Software
14# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1335  USA
15
16#
17# Global constants, only to be changed between major releases.
18#
19
20SET(SHARED_LIB_MAJOR_VERSION "19")
21SET(PROTOCOL_VERSION "10")
22SET(DOT_FRM_VERSION "6")
23
24# Generate "something" to trigger cmake rerun when VERSION changes
25CONFIGURE_FILE(
26  ${CMAKE_SOURCE_DIR}/VERSION
27  ${CMAKE_BINARY_DIR}/VERSION.dep
28)
29
30# Read value for a variable from VERSION.
31
32MACRO(MYSQL_GET_CONFIG_VALUE keyword var)
33 IF(NOT ${var})
34   FILE (STRINGS ${CMAKE_SOURCE_DIR}/VERSION str REGEX "^[ ]*${keyword}=")
35   IF(str)
36     STRING(REPLACE "${keyword}=" "" str ${str})
37     STRING(REGEX REPLACE  "[ ].*" ""  str "${str}")
38     SET(${var} ${str})
39   ENDIF()
40 ENDIF()
41ENDMACRO()
42
43
44# Read mysql version for configure script
45
46MACRO(GET_MYSQL_VERSION)
47  MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_MAJOR" MAJOR_VERSION)
48  MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_MINOR" MINOR_VERSION)
49  MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_PATCH" PATCH_VERSION)
50  MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_EXTRA" EXTRA_VERSION)
51  MYSQL_GET_CONFIG_VALUE("SERVER_MATURITY" SERVER_MATURITY)
52
53IF(NOT "${MAJOR_VERSION}" MATCHES "[0-9]+" OR
54   NOT "${MINOR_VERSION}" MATCHES "[0-9]+" OR
55   NOT "${PATCH_VERSION}" MATCHES "[0-9]+")
56    MESSAGE(FATAL_ERROR "VERSION file cannot be parsed.")
57  ENDIF()
58
59  SET(VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}${EXTRA_VERSION}")
60  SET(SERVER_VERSION ${VERSION})
61  MESSAGE(STATUS "MariaDB ${VERSION}")
62  SET(MYSQL_BASE_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}" CACHE INTERNAL "MySQL Base version")
63  SET(MYSQL_NO_DASH_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")
64  MATH(EXPR MYSQL_VERSION_ID "10000*${MAJOR_VERSION} + 100*${MINOR_VERSION} + ${PATCH_VERSION}")
65  MARK_AS_ADVANCED(VERSION MYSQL_VERSION_ID MYSQL_BASE_VERSION)
66  SET(CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION})
67  SET(CPACK_PACKAGE_VERSION_MINOR ${MINOR_VERSION})
68  SET(CPACK_PACKAGE_VERSION_PATCH ${PATCH_VERSION}${EXTRA_VERSION})
69ENDMACRO()
70
71# Get mysql version and other interesting variables
72GET_MYSQL_VERSION()
73
74# Maturity level
75string(TOUPPER ${SERVER_MATURITY} SERVER_MATURITY)
76SET(SERVER_MATURITY_LEVEL MariaDB_PLUGIN_MATURITY_${SERVER_MATURITY})
77
78SET(MYSQL_TCP_PORT_DEFAULT 0)
79SET_IF_UNSET(MYSQL_TCP_PORT 3306)
80
81SET_IF_UNSET(COMPILATION_COMMENT "Source distribution")
82
83INCLUDE(package_name)
84IF(NOT CPACK_PACKAGE_FILE_NAME)
85  GET_PACKAGE_FILE_NAME(CPACK_PACKAGE_FILE_NAME)
86ENDIF()
87
88SET_IF_UNSET(CPACK_SOURCE_PACKAGE_FILE_NAME "mariadb-${VERSION}")
89SET_IF_UNSET(CPACK_PACKAGE_CONTACT "MariaDB Developers <maria-developers@lists.launchpad.net>")
90SET_IF_UNSET(CPACK_PACKAGE_VENDOR "MariaDB Foundation")
91SET_IF_UNSET(CPACK_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}
92
93It is GPL v2 licensed, which means you can use the it free of charge under the
94conditions of the GNU General Public License Version 2 (http://www.gnu.org/licenses/).
95
96MariaDB documentation can be found at https://mariadb.com/kb
97MariaDB bug reports should be submitted through https://jira.mariadb.org
98
99")
100SET(CPACK_SOURCE_GENERATOR "TGZ")
101
102# Definitions for windows version resources
103SET(PRODUCTNAME "MariaDB Server")
104SET(COMPANYNAME ${CPACK_PACKAGE_VENDOR})
105
106# Windows 'date' command has unpredictable output, so cannot rely on it to
107# set MYSQL_COPYRIGHT_YEAR - if someone finds a portable way to do so then
108# it might be useful
109#IF (WIN32)
110#  EXECUTE_PROCESS(COMMAND "date" "/T" OUTPUT_VARIABLE TMP_DATE)
111#  STRING(REGEX REPLACE "(..)/(..)/..(..).*" "\\3\\2\\1" MYSQL_COPYRIGHT_YEAR ${TMP_DATE})
112IF(UNIX)
113  EXECUTE_PROCESS(COMMAND "date" "+%Y" OUTPUT_VARIABLE MYSQL_COPYRIGHT_YEAR OUTPUT_STRIP_TRAILING_WHITESPACE)
114ENDIF()
115
116# Add version information to the exe and dll files
117# Refer to http://msdn.microsoft.com/en-us/library/aa381058(VS.85).aspx
118# for more info.
119IF(MSVC)
120    # Tiny version is used to identify the build, it can be set with cmake -DTINY_VERSION=<number>
121    # to bzr revno for example (in the CI builds)
122    IF(NOT TINY_VERSION)
123      SET(TINY_VERSION "0")
124    ENDIF()
125
126    GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
127
128    SET(FILETYPE VFT_APP)
129    CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in
130    ${CMAKE_BINARY_DIR}/versioninfo_exe.rc)
131
132    SET(FILETYPE VFT_DLL)
133    CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in
134      ${CMAKE_BINARY_DIR}/versioninfo_dll.rc)
135
136  FUNCTION(ADD_VERSION_INFO target target_type sources_var)
137    IF("${target_type}" MATCHES "SHARED" OR "${target_type}" MATCHES "MODULE")
138      SET(rcfile ${CMAKE_BINARY_DIR}/versioninfo_dll.rc)
139    ELSEIF("${target_type}" MATCHES "EXE")
140      SET(rcfile ${CMAKE_BINARY_DIR}/versioninfo_exe.rc)
141    ENDIF()
142    SET(${sources_var} ${${sources_var}} ${rcfile} PARENT_SCOPE)
143  ENDFUNCTION()
144ELSE()
145  FUNCTION(ADD_VERSION_INFO)
146  ENDFUNCTION()
147ENDIF()
148