1# Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. 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, version 2.0, 5# as published by the Free Software Foundation. 6# 7# This program is also distributed with certain software (including 8# but not limited to OpenSSL) that is licensed under separate terms, 9# as designated in a particular file or component or in included license 10# documentation. The authors of MySQL hereby grant you an additional 11# permission to link the program and your derivative works with the 12# separately licensed software that they have included with MySQL. 13# 14# This program is distributed in the hope that it will be useful, 15# but WITHOUT ANY WARRANTY; without even the implied warranty of 16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17# GNU General Public License, version 2.0, for more details. 18# 19# You should have received a copy of the GNU General Public License 20# along with this program; if not, write to the Free Software 21# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 22 23# 24# Global constants, only to be changed between major releases. 25# 26 27SET(SHARED_LIB_MAJOR_VERSION "18") 28SET(SHARED_LIB_MINOR_VERSION "1") 29SET(PROTOCOL_VERSION "10") 30SET(DOT_FRM_VERSION "6") 31 32# Generate "something" to trigger cmake rerun when VERSION changes 33CONFIGURE_FILE( 34 ${CMAKE_SOURCE_DIR}/VERSION 35 ${CMAKE_BINARY_DIR}/VERSION.dep 36) 37 38# Read value for a variable from VERSION. 39 40MACRO(MYSQL_GET_CONFIG_VALUE keyword var) 41 IF(NOT ${var}) 42 FILE (STRINGS ${CMAKE_SOURCE_DIR}/VERSION str REGEX "^[ ]*${keyword}=") 43 IF(str) 44 STRING(REPLACE "${keyword}=" "" str ${str}) 45 STRING(REGEX REPLACE "[ ].*" "" str "${str}") 46 SET(${var} ${str}) 47 ENDIF() 48 ENDIF() 49ENDMACRO() 50 51 52# Read mysql version for configure script 53 54MACRO(GET_MYSQL_VERSION) 55 MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_MAJOR" MAJOR_VERSION) 56 MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_MINOR" MINOR_VERSION) 57 MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_PATCH" PATCH_VERSION) 58 MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_EXTRA" EXTRA_VERSION) 59 60 IF(NOT MAJOR_VERSION OR NOT MINOR_VERSION OR NOT PATCH_VERSION) 61 MESSAGE(FATAL_ERROR "VERSION file cannot be parsed.") 62 ENDIF() 63 64 SET(VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}${EXTRA_VERSION}") 65 MESSAGE(STATUS "MySQL ${VERSION}") 66 SET(MYSQL_BASE_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}" CACHE INTERNAL "MySQL Base version") 67 SET(MYSQL_NO_DASH_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}") 68 # Use NDBVERSION irregardless of whether this is Cluster or not, if not 69 # then the regex will be ignored anyway. 70 STRING(REGEX REPLACE "^.*-ndb-" "" NDBVERSION "${VERSION}") 71 STRING(REPLACE "-" "_" MYSQL_RPM_VERSION "${NDBVERSION}") 72 MATH(EXPR MYSQL_VERSION_ID "10000*${MAJOR_VERSION} + 100*${MINOR_VERSION} + ${PATCH_VERSION}") 73 MARK_AS_ADVANCED(VERSION MYSQL_VERSION_ID MYSQL_BASE_VERSION) 74 SET(CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION}) 75 SET(CPACK_PACKAGE_VERSION_MINOR ${MINOR_VERSION}) 76 SET(CPACK_PACKAGE_VERSION_PATCH ${PATCH_VERSION}) 77ENDMACRO() 78 79# Get mysql version and other interesting variables 80GET_MYSQL_VERSION() 81 82SET(MYSQL_TCP_PORT_DEFAULT "3306") 83 84IF(NOT MYSQL_TCP_PORT) 85 SET(MYSQL_TCP_PORT ${MYSQL_TCP_PORT_DEFAULT}) 86 SET(MYSQL_TCP_PORT_DEFAULT "0") 87ELSEIF(MYSQL_TCP_PORT EQUAL MYSQL_TCP_PORT_DEFAULT) 88 SET(MYSQL_TCP_PORT_DEFAULT "0") 89ENDIF() 90 91 92IF(NOT MYSQL_UNIX_ADDR) 93 SET(MYSQL_UNIX_ADDR "/tmp/mysql.sock") 94ENDIF() 95IF(NOT COMPILATION_COMMENT) 96 SET(COMPILATION_COMMENT "Source distribution") 97ENDIF() 98 99 100INCLUDE(package_name) 101IF(NOT CPACK_PACKAGE_FILE_NAME) 102 GET_PACKAGE_FILE_NAME(CPACK_PACKAGE_FILE_NAME) 103ENDIF() 104 105IF(NOT CPACK_SOURCE_PACKAGE_FILE_NAME) 106 SET(CPACK_SOURCE_PACKAGE_FILE_NAME "percona-server-${VERSION}") 107 IF("${VERSION}" MATCHES "-ndb-") 108 STRING(REGEX REPLACE "^.*-ndb-" "" NDBVERSION "${VERSION}") 109 SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mysql-cluster-gpl-${NDBVERSION}") 110 ENDIF() 111ENDIF() 112SET(CPACK_PACKAGE_CONTACT "Percona Engineering <mysql-dev@percona.com>") 113SET(CPACK_PACKAGE_VENDOR "Percona") 114SET(CPACK_SOURCE_GENERATOR "TGZ") 115INCLUDE(cpack_source_ignore_files) 116 117# Defintions for windows version resources 118SET(PRODUCTNAME "Percona Server") 119SET(COMPANYNAME ${CPACK_PACKAGE_VENDOR}) 120 121# Windows 'date' command has unpredictable output, so cannot rely on it to 122# set MYSQL_COPYRIGHT_YEAR - if someone finds a portable way to do so then 123# it might be useful 124#IF (WIN32) 125# EXECUTE_PROCESS(COMMAND "date" "/T" OUTPUT_VARIABLE TMP_DATE) 126# STRING(REGEX REPLACE "(..)/(..)/..(..).*" "\\3\\2\\1" MYSQL_COPYRIGHT_YEAR ${TMP_DATE}) 127IF(UNIX) 128 EXECUTE_PROCESS(COMMAND "date" "+%Y" OUTPUT_VARIABLE MYSQL_COPYRIGHT_YEAR OUTPUT_STRIP_TRAILING_WHITESPACE) 129ENDIF() 130 131# Add version information to the exe and dll files 132# Refer to http://msdn.microsoft.com/en-us/library/aa381058(VS.85).aspx 133# for more info. 134IF(MSVC) 135 GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) 136 137 SET(FILETYPE VFT_APP) 138 CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in 139 ${CMAKE_BINARY_DIR}/versioninfo_exe.rc) 140 141 SET(FILETYPE VFT_DLL) 142 CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in 143 ${CMAKE_BINARY_DIR}/versioninfo_dll.rc) 144 145 FUNCTION(ADD_VERSION_INFO target target_type sources_var) 146 IF("${target_type}" MATCHES "SHARED" OR "${target_type}" MATCHES "MODULE") 147 SET(rcfile ${CMAKE_BINARY_DIR}/versioninfo_dll.rc) 148 ELSEIF("${target_type}" MATCHES "EXE") 149 SET(rcfile ${CMAKE_BINARY_DIR}/versioninfo_exe.rc) 150 ENDIF() 151 SET(${sources_var} ${${sources_var}} ${rcfile} PARENT_SCOPE) 152 ENDFUNCTION() 153ELSE() 154 FUNCTION(ADD_VERSION_INFO) 155 ENDFUNCTION() 156ENDIF() 157