2014-01-16 15:43:29 +01:00
|
|
|
# Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
|
2006-12-31 02:29:11 +01:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; version 2 of the License.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
2010-08-12 19:19:57 +04:00
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2006-12-31 02:29:11 +01:00
|
|
|
|
2009-12-07 22:01:03 +01:00
|
|
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
|
|
|
# Avoid warnings in higher versions
|
|
|
|
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 2.6)
|
|
|
|
CMAKE_POLICY(VERSION 2.8)
|
|
|
|
endif()
|
|
|
|
|
2014-03-05 13:01:54 +01:00
|
|
|
# We use PROPERTIES LINK_INTERFACE_LIBRARIES. See cmake --help-policy CMP0022
|
|
|
|
IF(CMAKE_VERSION VERSION_EQUAL "2.8.12" OR
|
|
|
|
CMAKE_VERSION VERSION_GREATER "2.8.12")
|
|
|
|
CMAKE_POLICY(SET CMP0022 OLD)
|
|
|
|
ENDIF()
|
|
|
|
|
2014-06-24 09:13:01 +02:00
|
|
|
# We use the LOCATION target property (CMP0026)
|
|
|
|
# and get_target_property() for non-existent targets (CMP0045)
|
2014-10-13 09:52:28 +02:00
|
|
|
# and INSTALL_NAME_DIR (CMP0042)
|
2014-06-24 09:13:01 +02:00
|
|
|
IF(CMAKE_VERSION VERSION_EQUAL "3.0.0" OR
|
|
|
|
CMAKE_VERSION VERSION_GREATER "3.0.0")
|
|
|
|
CMAKE_POLICY(SET CMP0026 OLD)
|
|
|
|
CMAKE_POLICY(SET CMP0045 OLD)
|
2014-10-13 09:52:28 +02:00
|
|
|
CMAKE_POLICY(SET CMP0042 OLD)
|
2014-06-24 09:13:01 +02:00
|
|
|
ENDIF()
|
|
|
|
|
2012-09-07 10:12:32 +02:00
|
|
|
MESSAGE(STATUS "Running cmake version ${CMAKE_VERSION}")
|
2010-01-11 14:42:07 +01:00
|
|
|
|
2014-11-11 10:58:47 +01:00
|
|
|
# Will set GIT_EXECUTABLE and GIT_FOUND
|
|
|
|
FIND_PACKAGE(Git)
|
|
|
|
|
2009-12-17 14:41:50 +01:00
|
|
|
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
|
2007-11-02 15:16:45 -04:00
|
|
|
|
2009-11-09 12:32:48 +01:00
|
|
|
# First, decide about build type (debug or release)
|
|
|
|
# If custom compiler flags are set or cmake is invoked with -DCMAKE_BUILD_TYPE,
|
|
|
|
# respect user wishes and do not (re)define CMAKE_BUILD_TYPE. If WITH_DEBUG{_FULL}
|
|
|
|
# is given, set CMAKE_BUILD_TYPE = Debug. Otherwise, use Relwithdebinfo.
|
2006-01-31 07:52:16 -06:00
|
|
|
|
|
|
|
|
2010-01-19 02:21:48 +00:00
|
|
|
IF(DEFINED CMAKE_BUILD_TYPE)
|
2009-11-09 12:32:48 +01:00
|
|
|
SET(HAVE_CMAKE_BUILD_TYPE TRUE)
|
|
|
|
ENDIF()
|
|
|
|
SET(CUSTOM_C_FLAGS $ENV{CFLAGS})
|
2007-08-04 02:51:58 -04:00
|
|
|
|
2010-03-02 01:53:15 +01:00
|
|
|
OPTION(WITH_DEBUG "Use dbug/safemutex" OFF)
|
2009-11-09 12:32:48 +01:00
|
|
|
|
2010-04-30 13:30:32 +02:00
|
|
|
# Distinguish between community and non-community builds, with the
|
|
|
|
# default being a community build. This does not impact the feature
|
|
|
|
# set that will be compiled in; it's merely provided as a hint to
|
|
|
|
# custom packaging steps.
|
|
|
|
OPTION(COMMUNITY_BUILD "Set to true if this is a community build" ON)
|
|
|
|
|
|
|
|
# Use a default manufacturer if no manufacturer was identified.
|
|
|
|
SET(MANUFACTURER_DOCSTRING
|
|
|
|
"Set the entity that appears as the manufacturer of packages that support a manufacturer field.")
|
|
|
|
IF(NOT DEFINED MANUFACTURER)
|
2010-08-05 18:38:24 +02:00
|
|
|
SET(MANUFACTURER "Built from Source" CACHE STRING ${MANUFACTURER_DOCSTRING})
|
|
|
|
MARK_AS_ADVANCED(MANUFACTURER)
|
2010-04-30 13:30:32 +02:00
|
|
|
ENDIF()
|
2010-01-19 02:21:48 +00:00
|
|
|
|
2010-03-02 01:53:15 +01:00
|
|
|
# We choose to provide WITH_DEBUG as alias to standard CMAKE_BUILD_TYPE=Debug
|
|
|
|
# which turns out to be not trivial, as this involves synchronization
|
|
|
|
# between CMAKE_BUILD_TYPE and WITH_DEBUG. Besides, we have to deal with cases
|
|
|
|
# where WITH_DEBUG is reset from ON to OFF and here we need to reset
|
|
|
|
# CMAKE_BUILD_TYPE to either none or default RelWithDebInfo
|
|
|
|
|
|
|
|
SET(BUILDTYPE_DOCSTRING
|
|
|
|
"Choose the type of build, options are: None(CMAKE_CXX_FLAGS or
|
|
|
|
CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel")
|
2014-10-13 09:52:28 +02:00
|
|
|
|
2010-08-06 09:59:38 -03:00
|
|
|
IF(WITH_DEBUG)
|
2010-03-02 01:53:15 +01:00
|
|
|
SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING ${BUILDTYPE_DOCSTRING} FORCE)
|
2010-10-06 15:15:27 +02:00
|
|
|
IF(UNIX AND NOT APPLE)
|
|
|
|
# Compiling with PIC speeds up embedded build, on PIC sensitive systems
|
|
|
|
# Predefine it to ON, in case user chooses to build embedded.
|
|
|
|
SET(WITH_PIC ON CACHE BOOL "Compile with PIC")
|
|
|
|
ENDIF()
|
2010-03-02 01:53:15 +01:00
|
|
|
SET(OLD_WITH_DEBUG 1 CACHE INTERNAL "" FORCE)
|
|
|
|
ELSEIF(NOT HAVE_CMAKE_BUILD_TYPE OR OLD_WITH_DEBUG)
|
|
|
|
IF(CUSTOM_C_FLAGS)
|
|
|
|
SET(CMAKE_BUILD_TYPE "" CACHE STRING ${BUILDTYPE_DOCSTRING} FORCE)
|
|
|
|
ELSE(CMAKE_BUILD_TYPE MATCHES "Debug" OR NOT HAVE_CMAKE_BUILD_TYPE)
|
|
|
|
SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
|
|
|
|
${BUILDTYPE_DOCSTRING} FORCE)
|
|
|
|
ENDIF()
|
|
|
|
SET(OLD_WITH_DEBUG 0 CACHE INTERNAL "" FORCE)
|
2009-11-09 12:32:48 +01:00
|
|
|
ENDIF()
|
|
|
|
|
2012-01-16 12:39:12 +01:00
|
|
|
# Optionally set project name, e.g.
|
|
|
|
# foo.xcodeproj (mac) or foo.sln (windows)
|
|
|
|
SET(MYSQL_PROJECT_NAME_DOCSTRING "MySQL project name")
|
|
|
|
IF(DEFINED MYSQL_PROJECT_NAME)
|
|
|
|
SET(MYSQL_PROJECT_NAME ${MYSQL_PROJECT_NAME} CACHE STRING
|
|
|
|
${MYSQL_PROJECT_NAME_DOCSTRING} FORCE)
|
|
|
|
ELSE()
|
|
|
|
SET(MYSQL_PROJECT_NAME "MySQL" CACHE STRING
|
|
|
|
${MYSQL_PROJECT_NAME_DOCSTRING} FORCE)
|
|
|
|
MARK_AS_ADVANCED(MYSQL_PROJECT_NAME)
|
|
|
|
ENDIF()
|
|
|
|
PROJECT(${MYSQL_PROJECT_NAME})
|
2010-01-19 02:21:48 +00:00
|
|
|
|
2014-10-13 09:52:28 +02:00
|
|
|
# Maintainer mode is default on only for Linux debug builds using GCC/G++
|
|
|
|
IF(CMAKE_BUILD_TYPE MATCHES "Debug" OR WITH_DEBUG)
|
|
|
|
IF(CMAKE_SYSTEM_NAME MATCHES "Linux" AND
|
|
|
|
CMAKE_COMPILER_IS_GNUCC AND CMAKE_COMPILER_IS_GNUCXX)
|
|
|
|
SET(MYSQL_MAINTAINER_MODE ON CACHE BOOL
|
|
|
|
"MySQL maintainer-specific development environment")
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
2010-11-17 22:06:24 +01:00
|
|
|
IF(BUILD_CONFIG)
|
|
|
|
INCLUDE(
|
|
|
|
${CMAKE_SOURCE_DIR}/cmake/build_configurations/${BUILD_CONFIG}.cmake)
|
|
|
|
ENDIF()
|
2010-01-20 00:52:21 +01:00
|
|
|
|
2010-01-26 13:47:34 +01:00
|
|
|
# Include the platform-specific file. To allow exceptions, this code
|
|
|
|
# looks for files in order of how specific they are. If there is, for
|
|
|
|
# example, a generic Linux.cmake and a version-specific
|
|
|
|
# Linux-2.6.28-11-generic, it will pick Linux-2.6.28-11-generic and
|
|
|
|
# include it. It is then up to the file writer to include the generic
|
|
|
|
# version if necessary.
|
|
|
|
FOREACH(_base
|
|
|
|
${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_VERSION}-${CMAKE_SYSTEM_PROCESSOR}
|
|
|
|
${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_VERSION}
|
|
|
|
${CMAKE_SYSTEM_NAME})
|
|
|
|
SET(_file ${CMAKE_SOURCE_DIR}/cmake/os/${_base}.cmake)
|
|
|
|
IF(EXISTS ${_file})
|
|
|
|
INCLUDE(${_file})
|
|
|
|
BREAK()
|
|
|
|
ENDIF()
|
|
|
|
ENDFOREACH()
|
|
|
|
|
|
|
|
|
2010-01-24 21:03:21 +01:00
|
|
|
# Following autotools tradition, add preprocessor definitions
|
|
|
|
# specified in environment variable CPPFLAGS
|
|
|
|
IF(DEFINED ENV{CPPFLAGS})
|
|
|
|
ADD_DEFINITIONS($ENV{CPPFLAGS})
|
|
|
|
ENDIF()
|
2010-01-20 00:52:21 +01:00
|
|
|
|
2009-11-09 12:32:48 +01:00
|
|
|
# Add macros
|
2009-12-18 23:53:30 +01:00
|
|
|
INCLUDE(character_sets)
|
|
|
|
INCLUDE(zlib)
|
|
|
|
INCLUDE(ssl)
|
|
|
|
INCLUDE(readline)
|
|
|
|
INCLUDE(mysql_version)
|
|
|
|
INCLUDE(libutils)
|
|
|
|
INCLUDE(dtrace)
|
|
|
|
INCLUDE(plugin)
|
|
|
|
INCLUDE(install_macros)
|
2010-01-24 16:23:16 +01:00
|
|
|
INCLUDE(install_layout)
|
2009-12-17 14:41:50 +01:00
|
|
|
INCLUDE(mysql_add_executable)
|
2009-11-09 12:32:48 +01:00
|
|
|
|
|
|
|
# Handle options
|
2009-11-25 05:13:51 +01:00
|
|
|
OPTION(DISABLE_SHARED
|
|
|
|
"Don't build shared libraries, compile code as position-dependent" OFF)
|
|
|
|
IF(DISABLE_SHARED)
|
|
|
|
SET(WITHOUT_DYNAMIC_PLUGINS 1)
|
|
|
|
ENDIF()
|
2009-11-09 12:32:48 +01:00
|
|
|
OPTION(ENABLED_PROFILING "Enable profiling" ON)
|
|
|
|
OPTION(CYBOZU "" OFF)
|
|
|
|
OPTION(BACKUP_TEST "" OFF)
|
|
|
|
OPTION(WITHOUT_SERVER OFF)
|
2010-06-21 13:39:30 +02:00
|
|
|
IF(UNIX)
|
|
|
|
OPTION(WITH_VALGRIND "Valgrind instrumentation" OFF)
|
|
|
|
ENDIF()
|
2010-01-28 14:33:44 +01:00
|
|
|
OPTION (WITH_UNIT_TESTS "Compile MySQL with unit tests" ON)
|
2009-11-25 05:13:51 +01:00
|
|
|
MARK_AS_ADVANCED(CYBOZU BACKUP_TEST WITHOUT_SERVER DISABLE_SHARED)
|
2009-11-09 12:32:48 +01:00
|
|
|
|
2013-09-20 16:10:31 +02:00
|
|
|
|
|
|
|
include(CheckCSourceCompiles)
|
|
|
|
include(CheckCXXSourceCompiles)
|
|
|
|
# We need some extra FAIL_REGEX patterns
|
|
|
|
# Note that CHECK_C_SOURCE_COMPILES is a misnomer, it will also link.
|
|
|
|
MACRO (MY_CHECK_C_COMPILER_FLAG FLAG RESULT)
|
|
|
|
SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
|
|
|
|
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}")
|
|
|
|
CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${RESULT}
|
|
|
|
FAIL_REGEX "argument unused during compilation"
|
|
|
|
FAIL_REGEX "unsupported .*option"
|
|
|
|
FAIL_REGEX "unknown .*option"
|
|
|
|
FAIL_REGEX "unrecognized .*option"
|
|
|
|
FAIL_REGEX "ignoring unknown option"
|
|
|
|
FAIL_REGEX "[Ww]arning: [Oo]ption"
|
|
|
|
)
|
|
|
|
SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}")
|
|
|
|
ENDMACRO()
|
|
|
|
|
|
|
|
MACRO (MY_CHECK_CXX_COMPILER_FLAG FLAG RESULT)
|
|
|
|
SET(SAVE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
|
|
|
|
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${FLAG}")
|
|
|
|
CHECK_CXX_SOURCE_COMPILES("int main(void) { return 0; }" ${RESULT}
|
|
|
|
FAIL_REGEX "argument unused during compilation"
|
|
|
|
FAIL_REGEX "unsupported .*option"
|
|
|
|
FAIL_REGEX "unknown .*option"
|
|
|
|
FAIL_REGEX "unrecognized .*option"
|
|
|
|
FAIL_REGEX "ignoring unknown option"
|
|
|
|
FAIL_REGEX "[Ww]arning: [Oo]ption"
|
|
|
|
)
|
|
|
|
SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}")
|
|
|
|
ENDMACRO()
|
|
|
|
|
|
|
|
OPTION(WITH_ASAN "Enable address sanitizer" OFF)
|
|
|
|
IF (WITH_ASAN)
|
|
|
|
# gcc 4.8.1 and new versions of clang
|
|
|
|
MY_CHECK_C_COMPILER_FLAG("-fsanitize=address" HAVE_C_FSANITIZE)
|
|
|
|
MY_CHECK_CXX_COMPILER_FLAG("-fsanitize=address" HAVE_CXX_FSANITIZE)
|
|
|
|
|
|
|
|
IF(HAVE_C_FSANITIZE AND HAVE_CXX_FSANITIZE)
|
|
|
|
# We switch on basic optimization also for debug builds.
|
|
|
|
# With optimization we may get some warnings, so we switch off -Werror
|
|
|
|
SET(CMAKE_C_FLAGS_DEBUG
|
|
|
|
"${CMAKE_C_FLAGS_DEBUG} -fsanitize=address -O1 -Wno-error -fPIC")
|
|
|
|
SET(CMAKE_C_FLAGS_RELWITHDEBINFO
|
|
|
|
"${CMAKE_C_FLAGS_RELWITHDEBINFO} -fsanitize=address -fPIC")
|
|
|
|
SET(CMAKE_CXX_FLAGS_DEBUG
|
|
|
|
"${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address -O1 -Wno-error -fPIC")
|
|
|
|
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
|
|
|
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fsanitize=address -fPIC")
|
|
|
|
SET(WITH_ASAN_OK 1)
|
|
|
|
ELSE()
|
|
|
|
# older versions of clang
|
|
|
|
MY_CHECK_C_COMPILER_FLAG("-faddress-sanitizer" HAVE_C_FADDRESS)
|
|
|
|
MY_CHECK_CXX_COMPILER_FLAG("-faddress-sanitizer" HAVE_CXX_FFADDRESS)
|
|
|
|
|
|
|
|
IF(HAVE_C_FADDRESS AND HAVE_CXX_FFADDRESS)
|
|
|
|
# We switch on basic optimization also for debug builds.
|
|
|
|
SET(CMAKE_C_FLAGS_DEBUG
|
|
|
|
"${CMAKE_C_FLAGS_DEBUG} -faddress-sanitizer -O1 -fPIC")
|
|
|
|
SET(CMAKE_C_FLAGS_RELWITHDEBINFO
|
|
|
|
"${CMAKE_C_FLAGS_RELWITHDEBINFO} -faddress-sanitizer -fPIC")
|
|
|
|
SET(CMAKE_CXX_FLAGS_DEBUG
|
|
|
|
"${CMAKE_CXX_FLAGS_DEBUG} -faddress-sanitizer -O1 -fPIC")
|
|
|
|
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
|
|
|
"${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -faddress-sanitizer -fPIC")
|
|
|
|
SET(WITH_ASAN_OK 1)
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
IF(NOT WITH_ASAN_OK)
|
|
|
|
MESSAGE(FATAL_ERROR "Do not know how to enable address sanitizer")
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
2009-11-09 12:32:48 +01:00
|
|
|
OPTION(ENABLE_DEBUG_SYNC "Enable debug sync (debug builds only)" ON)
|
|
|
|
IF(ENABLE_DEBUG_SYNC)
|
|
|
|
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DENABLED_DEBUG_SYNC")
|
|
|
|
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DENABLED_DEBUG_SYNC")
|
|
|
|
ENDIF()
|
|
|
|
|
2011-05-12 18:22:14 -04:00
|
|
|
OPTION(ENABLE_GCOV "Enable gcov (debug, Linux builds only)" OFF)
|
|
|
|
IF (ENABLE_GCOV AND NOT WIN32 AND NOT APPLE)
|
|
|
|
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
|
|
|
|
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
|
|
|
|
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage -lgcov")
|
|
|
|
ENDIF()
|
|
|
|
|
2010-06-23 12:56:22 +02:00
|
|
|
OPTION(ENABLED_LOCAL_INFILE
|
2009-11-09 12:32:48 +01:00
|
|
|
"If we should should enable LOAD DATA LOCAL by default" ${IF_WIN})
|
2010-06-23 12:56:22 +02:00
|
|
|
MARK_AS_ADVANCED(ENABLED_LOCAL_INFILE)
|
2009-11-09 12:32:48 +01:00
|
|
|
|
2010-01-13 13:33:32 +01:00
|
|
|
OPTION(WITH_FAST_MUTEXES "Compile with fast mutexes" OFF)
|
|
|
|
MARK_AS_ADVANCED(WITH_FAST_MUTEXES)
|
|
|
|
|
|
|
|
# Set DBUG_OFF and other optional release-only flags for non-debug project types
|
2009-11-09 12:32:48 +01:00
|
|
|
FOREACH(BUILD_TYPE RELEASE RELWITHDEBINFO MINSIZEREL)
|
|
|
|
FOREACH(LANG C CXX)
|
|
|
|
SET(CMAKE_${LANG}_FLAGS_${BUILD_TYPE}
|
|
|
|
"${CMAKE_${LANG}_FLAGS_${BUILD_TYPE}} -DDBUG_OFF")
|
2010-01-13 13:33:32 +01:00
|
|
|
IF(WITH_FAST_MUTEXES)
|
|
|
|
SET(CMAKE_${LANG}_FLAGS_${BUILD_TYPE}
|
|
|
|
"${CMAKE_${LANG}_FLAGS_${BUILD_TYPE}} -DMY_PTHREAD_FASTMUTEX=1")
|
|
|
|
ENDIF()
|
2009-11-09 12:32:48 +01:00
|
|
|
ENDFOREACH()
|
|
|
|
ENDFOREACH()
|
|
|
|
|
|
|
|
IF(NOT CMAKE_BUILD_TYPE
|
|
|
|
AND NOT CMAKE_GENERATOR MATCHES "Visual Studio"
|
|
|
|
AND NOT CMAKE_GENERATOR MATCHES "Xcode")
|
|
|
|
# This is the case of no CMAKE_BUILD_TYPE choosen, typical for VS and Xcode
|
|
|
|
# or if custom C flags are set. In VS and Xcode for non-Debug configurations
|
|
|
|
# DBUG_OFF is already correctly set. Use DBUG_OFF for Makefile based projects
|
|
|
|
# without build type too, unless user specifically requests DBUG.
|
|
|
|
IF(NOT CMAKE_C_FLAGS MATCHES "-DDBUG_ON")
|
|
|
|
ADD_DEFINITIONS(-DDBUG_OFF)
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
Bug#34043: Server loops excessively in _checkchunk() when safemalloc is enabled
Essentially, the problem is that safemalloc is excruciatingly
slow as it checks all allocated blocks for overrun at each
memory management primitive, yielding a almost exponential
slowdown for the memory management functions (malloc, realloc,
free). The overrun check basically consists of verifying some
bytes of a block for certain magic keys, which catches some
simple forms of overrun. Another minor problem is violation
of aliasing rules and that its own internal list of blocks
is prone to corruption.
Another issue with safemalloc is rather the maintenance cost
as the tool has a significant impact on the server code.
Given the magnitude of memory debuggers available nowadays,
especially those that are provided with the platform malloc
implementation, maintenance of a in-house and largely obsolete
memory debugger becomes a burden that is not worth the effort
due to its slowness and lack of support for detecting more
common forms of heap corruption.
Since there are third-party tools that can provide the same
functionality at a lower or comparable performance cost, the
solution is to simply remove safemalloc. Third-party tools
can provide the same functionality at a lower or comparable
performance cost.
The removal of safemalloc also allows a simplification of the
malloc wrappers, removing quite a bit of kludge: redefinition
of my_malloc, my_free and the removal of the unused second
argument of my_free. Since free() always check whether the
supplied pointer is null, redudant checks are also removed.
Also, this patch adds unit testing for my_malloc and moves
my_realloc implementation into the same file as the other
memory allocation primitives.
2010-07-08 18:20:08 -03:00
|
|
|
# Add safemutex for debug configurations, except on Windows
|
|
|
|
# (safemutex has never worked on Windows)
|
2010-08-06 09:59:38 -03:00
|
|
|
IF(WITH_DEBUG AND NOT WIN32)
|
2009-11-09 12:32:48 +01:00
|
|
|
FOREACH(LANG C CXX)
|
2010-08-06 09:59:38 -03:00
|
|
|
SET(CMAKE_${LANG}_FLAGS_DEBUG
|
|
|
|
"${CMAKE_${LANG}_FLAGS_DEBUG} -DSAFE_MUTEX")
|
2009-11-09 12:32:48 +01:00
|
|
|
ENDFOREACH()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
|
|
|
# Set commonly used variables
|
|
|
|
IF(WIN32)
|
2009-12-07 22:01:03 +01:00
|
|
|
SET(DEFAULT_MYSQL_HOME "C:/Program Files/MySQL/MySQL Server ${MYSQL_BASE_VERSION}" )
|
2009-11-09 12:32:48 +01:00
|
|
|
SET(SHAREDIR share)
|
|
|
|
ELSE()
|
2009-11-14 14:29:14 +01:00
|
|
|
SET(DEFAULT_MYSQL_HOME ${CMAKE_INSTALL_PREFIX})
|
2010-01-24 16:23:16 +01:00
|
|
|
SET(SHAREDIR ${DEFAULT_MYSQL_HOME}/${INSTALL_MYSQLSHAREDIR})
|
2009-11-09 12:32:48 +01:00
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
SET(DEFAULT_BASEDIR "${DEFAULT_MYSQL_HOME}")
|
2010-05-12 12:51:23 +01:00
|
|
|
IF(INSTALL_MYSQLDATADIR MATCHES "^/.*")
|
|
|
|
SET(MYSQL_DATADIR ${INSTALL_MYSQLDATADIR} CACHE PATH "default MySQL data directory")
|
|
|
|
ELSE()
|
|
|
|
SET(MYSQL_DATADIR "${DEFAULT_MYSQL_HOME}/${INSTALL_MYSQLDATADIR}" CACHE PATH "default MySQL data directory")
|
|
|
|
ENDIF()
|
2009-11-09 12:32:48 +01:00
|
|
|
SET(DEFAULT_CHARSET_HOME "${DEFAULT_MYSQL_HOME}")
|
2010-01-24 16:23:16 +01:00
|
|
|
SET(PLUGINDIR "${DEFAULT_MYSQL_HOME}/${INSTALL_PLUGINDIR}")
|
|
|
|
IF(SYSCONFDIR)
|
|
|
|
SET(DEFAULT_SYSCONFDIR "${SYSCONFDIR}")
|
|
|
|
ENDIF()
|
2009-11-09 12:32:48 +01:00
|
|
|
|
2014-01-16 18:01:06 +01:00
|
|
|
SET(TMPDIR "P_tmpdir"
|
|
|
|
CACHE PATH
|
|
|
|
"PATH to MySQL TMP dir. Defaults to the P_tmpdir macro in <stdio.h>")
|
|
|
|
IF(TMPDIR STREQUAL "P_tmpdir")
|
|
|
|
# Do not quote it, to refer to the P_tmpdir macro.
|
|
|
|
SET(DEFAULT_TMPDIR "P_tmpdir")
|
|
|
|
ELSE()
|
|
|
|
# Quote it, to make it a const char string.
|
|
|
|
SET(DEFAULT_TMPDIR "\"${TMPDIR}\"")
|
2013-12-18 11:05:18 +01:00
|
|
|
ENDIF()
|
2009-11-09 12:32:48 +01:00
|
|
|
|
|
|
|
# Run platform tests
|
|
|
|
INCLUDE(configure.cmake)
|
|
|
|
|
|
|
|
# Common defines and includes
|
|
|
|
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
|
|
|
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include)
|
|
|
|
|
|
|
|
# Add bundled or system zlib.
|
|
|
|
MYSQL_CHECK_ZLIB_WITH_COMPRESS()
|
|
|
|
# Optionally add bundled yassl/taocrypt or system openssl.
|
|
|
|
MYSQL_CHECK_SSL()
|
|
|
|
# Add readline or libedit.
|
|
|
|
MYSQL_CHECK_READLINE()
|
|
|
|
|
2010-07-12 13:39:00 -03:00
|
|
|
#
|
|
|
|
# Setup maintainer mode options by the end. Platform checks are
|
|
|
|
# not run with the warning options as to not perturb fragile checks
|
|
|
|
# (i.e. do not make warnings into errors).
|
|
|
|
#
|
2014-10-13 09:52:28 +02:00
|
|
|
# Why doesn't these flags affect the entire build?
|
|
|
|
# Because things may already have been included with ADD_SUBDIRECTORY
|
|
|
|
#
|
|
|
|
OPTION(MYSQL_MAINTAINER_MODE
|
|
|
|
"MySQL maintainer-specific development environment" OFF)
|
|
|
|
|
|
|
|
INCLUDE(maintainer)
|
2010-07-12 13:39:00 -03:00
|
|
|
|
2009-11-09 12:32:48 +01:00
|
|
|
IF(NOT WITHOUT_SERVER)
|
2009-12-01 12:00:50 +01:00
|
|
|
SET (MYSQLD_STATIC_PLUGIN_LIBS "" CACHE INTERNAL "")
|
2009-11-09 12:32:48 +01:00
|
|
|
# Add storage engines and plugins.
|
|
|
|
CONFIGURE_PLUGINS()
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
ADD_SUBDIRECTORY(include)
|
2006-03-28 13:49:29 +02:00
|
|
|
ADD_SUBDIRECTORY(dbug)
|
|
|
|
ADD_SUBDIRECTORY(strings)
|
2009-11-09 12:32:48 +01:00
|
|
|
ADD_SUBDIRECTORY(vio)
|
2006-03-28 13:49:29 +02:00
|
|
|
ADD_SUBDIRECTORY(regex)
|
|
|
|
ADD_SUBDIRECTORY(mysys)
|
2007-08-04 02:51:58 -04:00
|
|
|
ADD_SUBDIRECTORY(libmysql)
|
2009-11-09 12:32:48 +01:00
|
|
|
|
|
|
|
IF(WITH_UNIT_TESTS)
|
|
|
|
ENABLE_TESTING()
|
|
|
|
ENDIF()
|
|
|
|
IF(WITH_UNIT_TESTS)
|
|
|
|
ADD_SUBDIRECTORY(unittest/mytap)
|
|
|
|
ADD_SUBDIRECTORY(unittest/mysys)
|
2013-05-23 11:06:34 +05:30
|
|
|
ADD_SUBDIRECTORY(unittest/my_decimal)
|
2009-11-09 12:32:48 +01:00
|
|
|
ENDIF()
|
|
|
|
|
2009-11-25 07:28:45 +01:00
|
|
|
ADD_SUBDIRECTORY(extra)
|
2009-11-09 12:32:48 +01:00
|
|
|
IF(NOT WITHOUT_SERVER)
|
|
|
|
ADD_SUBDIRECTORY(tests)
|
|
|
|
ADD_SUBDIRECTORY(client)
|
|
|
|
ADD_SUBDIRECTORY(sql)
|
|
|
|
ADD_SUBDIRECTORY(sql/share)
|
|
|
|
ADD_SUBDIRECTORY(libservices)
|
|
|
|
OPTION (WITH_EMBEDDED_SERVER "Compile MySQL with embedded server" OFF)
|
|
|
|
IF(WITH_EMBEDDED_SERVER)
|
|
|
|
ADD_SUBDIRECTORY(libmysqld)
|
|
|
|
ADD_SUBDIRECTORY(libmysqld/examples)
|
|
|
|
ENDIF(WITH_EMBEDDED_SERVER)
|
|
|
|
|
|
|
|
ADD_SUBDIRECTORY(mysql-test)
|
|
|
|
ADD_SUBDIRECTORY(mysql-test/lib/My/SafeProcess)
|
|
|
|
ADD_SUBDIRECTORY(support-files)
|
|
|
|
ADD_SUBDIRECTORY(scripts)
|
|
|
|
ADD_SUBDIRECTORY(sql-bench)
|
|
|
|
IF(UNIX)
|
|
|
|
ADD_SUBDIRECTORY(man)
|
|
|
|
ENDIF()
|
2012-07-19 13:01:33 +02:00
|
|
|
IF(EXISTS ${CMAKE_SOURCE_DIR}/internal/CMakeLists.txt)
|
|
|
|
ADD_SUBDIRECTORY(internal)
|
|
|
|
ENDIF()
|
2013-11-25 14:49:29 +01:00
|
|
|
ADD_SUBDIRECTORY(packaging/rpm-oel)
|
2014-11-04 08:44:08 +01:00
|
|
|
ADD_SUBDIRECTORY(packaging/rpm-sles)
|
2009-11-09 12:32:48 +01:00
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
INCLUDE(cmake/abi_check.cmake)
|
2010-05-14 18:42:10 +04:00
|
|
|
INCLUDE(cmake/tags.cmake)
|
2009-11-09 12:32:48 +01:00
|
|
|
|
|
|
|
CONFIGURE_FILE(config.h.cmake ${CMAKE_BINARY_DIR}/include/my_config.h)
|
|
|
|
CONFIGURE_FILE(config.h.cmake ${CMAKE_BINARY_DIR}/include/config.h)
|
|
|
|
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/mysql_version.h.in
|
|
|
|
${CMAKE_BINARY_DIR}/include/mysql_version.h )
|
2009-12-01 12:00:50 +01:00
|
|
|
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc.in
|
|
|
|
${CMAKE_BINARY_DIR}/sql/sql_builtin.cc)
|
Fix bug#42969 Please add a MANIFEST to each build
With this change, there will be new files "INFO_SRC"
and "INFO_BIN", which describe the source and the
binaries.
They will be contained in all packages:
- in "tar.gz" and derived packages, in "docs/",
- in RPMs, in "/usr/share/doc/packages/MySQL-server".
"INFO_SRC" is also part of a source tarball.
It gives the version as exact as possible, preferably
by calling "bzr version-info" on the source tree.
If that is not possible, it just contains the three
level version number.
"INFO_BIN" contains some info when and where the
binaries were built, the options given to the compiler,
and the flags controlling the included features.
The tests (test "mysql" in the main suite) are extended
to verify the existence of both "INFO_SRC" and "INFO_BIN",
as well as some of the expected contents.
2011-02-11 15:55:25 +01:00
|
|
|
CONFIGURE_FILE(
|
2014-11-11 14:14:53 +01:00
|
|
|
${CMAKE_SOURCE_DIR}/cmake/info_macros.cmake.in
|
|
|
|
${CMAKE_BINARY_DIR}/info_macros.cmake @ONLY)
|
Fix bug#42969 Please add a MANIFEST to each build
With this change, there will be new files "INFO_SRC"
and "INFO_BIN", which describe the source and the
binaries.
They will be contained in all packages:
- in "tar.gz" and derived packages, in "docs/",
- in RPMs, in "/usr/share/doc/packages/MySQL-server".
"INFO_SRC" is also part of a source tarball.
It gives the version as exact as possible, preferably
by calling "bzr version-info" on the source tree.
If that is not possible, it just contains the three
level version number.
"INFO_BIN" contains some info when and where the
binaries were built, the options given to the compiler,
and the flags controlling the included features.
The tests (test "mysql" in the main suite) are extended
to verify the existence of both "INFO_SRC" and "INFO_BIN",
as well as some of the expected contents.
2011-02-11 15:55:25 +01:00
|
|
|
|
|
|
|
# Handle the "INFO_*" files.
|
|
|
|
INCLUDE(${CMAKE_BINARY_DIR}/info_macros.cmake)
|
|
|
|
# Source: This can be done during the cmake phase, all information is
|
|
|
|
# available, but should be repeated on each "make" just in case someone
|
2014-12-03 14:50:29 +01:00
|
|
|
# does "cmake ; make ; git pull ; make".
|
Fix bug#42969 Please add a MANIFEST to each build
With this change, there will be new files "INFO_SRC"
and "INFO_BIN", which describe the source and the
binaries.
They will be contained in all packages:
- in "tar.gz" and derived packages, in "docs/",
- in RPMs, in "/usr/share/doc/packages/MySQL-server".
"INFO_SRC" is also part of a source tarball.
It gives the version as exact as possible, preferably
by calling "bzr version-info" on the source tree.
If that is not possible, it just contains the three
level version number.
"INFO_BIN" contains some info when and where the
binaries were built, the options given to the compiler,
and the flags controlling the included features.
The tests (test "mysql" in the main suite) are extended
to verify the existence of both "INFO_SRC" and "INFO_BIN",
as well as some of the expected contents.
2011-02-11 15:55:25 +01:00
|
|
|
CREATE_INFO_SRC(${CMAKE_BINARY_DIR}/Docs)
|
|
|
|
ADD_CUSTOM_TARGET(INFO_SRC ALL
|
|
|
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/cmake/info_src.cmake
|
|
|
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
|
|
|
)
|
|
|
|
# Build flags: This must be postponed to the make phase.
|
|
|
|
ADD_CUSTOM_TARGET(INFO_BIN ALL
|
|
|
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/cmake/info_bin.cmake
|
|
|
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
|
|
|
)
|
2009-11-09 12:32:48 +01:00
|
|
|
|
|
|
|
# Packaging
|
|
|
|
IF(WIN32)
|
|
|
|
SET(CPACK_GENERATOR "ZIP")
|
|
|
|
ELSE()
|
|
|
|
SET(CPACK_GENERATOR "TGZ")
|
|
|
|
ENDIF()
|
2010-02-10 20:23:24 +01:00
|
|
|
ADD_SUBDIRECTORY(packaging/WiX)
|
2013-04-03 18:09:37 +02:00
|
|
|
ADD_SUBDIRECTORY(packaging/solaris)
|
2010-11-13 19:38:39 +01:00
|
|
|
|
|
|
|
# Create a single package with "make package"
|
|
|
|
# (see http://public.kitware.com/Bug/view.php?id=11452)
|
|
|
|
SET(CPACK_MONOLITHIC_INSTALL 1 CACHE INTERNAL "")
|
|
|
|
|
2009-11-09 12:32:48 +01:00
|
|
|
IF(UNIX)
|
2010-11-13 23:16:52 +01:00
|
|
|
INSTALL(FILES Docs/mysql.info DESTINATION ${INSTALL_INFODIR} OPTIONAL COMPONENT Info)
|
2010-05-12 12:51:23 +01:00
|
|
|
ENDIF()
|
|
|
|
#
|
|
|
|
# RPM installs documentation directly from the source tree
|
|
|
|
#
|
|
|
|
IF(NOT INSTALL_LAYOUT MATCHES "RPM")
|
2010-11-24 13:23:44 +03:00
|
|
|
INSTALL(FILES COPYING LICENSE.mysql
|
2010-11-13 23:16:52 +01:00
|
|
|
DESTINATION ${INSTALL_DOCREADMEDIR}
|
|
|
|
COMPONENT Readme
|
|
|
|
OPTIONAL
|
|
|
|
)
|
|
|
|
INSTALL(FILES README DESTINATION ${INSTALL_DOCREADMEDIR} COMPONENT Readme)
|
Fix bug#42969 Please add a MANIFEST to each build
With this change, there will be new files "INFO_SRC"
and "INFO_BIN", which describe the source and the
binaries.
They will be contained in all packages:
- in "tar.gz" and derived packages, in "docs/",
- in RPMs, in "/usr/share/doc/packages/MySQL-server".
"INFO_SRC" is also part of a source tarball.
It gives the version as exact as possible, preferably
by calling "bzr version-info" on the source tree.
If that is not possible, it just contains the three
level version number.
"INFO_BIN" contains some info when and where the
binaries were built, the options given to the compiler,
and the flags controlling the included features.
The tests (test "mysql" in the main suite) are extended
to verify the existence of both "INFO_SRC" and "INFO_BIN",
as well as some of the expected contents.
2011-02-11 15:55:25 +01:00
|
|
|
INSTALL(FILES ${CMAKE_BINARY_DIR}/Docs/INFO_SRC ${CMAKE_BINARY_DIR}/Docs/INFO_BIN DESTINATION ${INSTALL_DOCDIR})
|
2010-05-12 12:51:23 +01:00
|
|
|
IF(UNIX)
|
2010-11-13 23:16:52 +01:00
|
|
|
INSTALL(FILES Docs/INSTALL-BINARY DESTINATION ${INSTALL_DOCREADMEDIR} COMPONENT Readme)
|
2010-05-12 12:51:23 +01:00
|
|
|
ENDIF()
|
|
|
|
# MYSQL_DOCS_LOCATON is used in "make dist", points to the documentation directory
|
|
|
|
SET(MYSQL_DOCS_LOCATION "" CACHE PATH "Location from where documentation is copied")
|
|
|
|
MARK_AS_ADVANCED(MYSQL_DOCS_LOCATION)
|
|
|
|
INSTALL(DIRECTORY Docs/ DESTINATION ${INSTALL_DOCDIR}
|
2010-11-13 23:16:52 +01:00
|
|
|
COMPONENT Documentation
|
2010-05-12 12:51:23 +01:00
|
|
|
PATTERN "INSTALL-BINARY" EXCLUDE
|
|
|
|
PATTERN "Makefile.*" EXCLUDE
|
|
|
|
PATTERN "glibc*" EXCLUDE
|
|
|
|
PATTERN "linuxthreads.txt" EXCLUDE
|
|
|
|
PATTERN "myisam.txt" EXCLUDE
|
|
|
|
PATTERN "mysql.info" EXCLUDE
|
|
|
|
PATTERN "sp-imp-spec.txt" EXCLUDE
|
|
|
|
)
|
2009-11-09 12:32:48 +01:00
|
|
|
ENDIF()
|
2013-10-16 11:05:20 +05:30
|
|
|
|
|
|
|
INCLUDE(CPack)
|
2014-10-13 09:52:28 +02:00
|
|
|
|
|
|
|
# C compiler flags consist of:
|
|
|
|
# CPPFLAGS Taken from environment, see above.
|
|
|
|
# ADD_DEFINITIONS In each individual CMakeLists.txt
|
|
|
|
# CMAKE_C_FLAGS From command line.
|
|
|
|
# We extend these in maintainer.cmake
|
|
|
|
# ENV{CFLAGS} From environment, but environment is ignored if
|
|
|
|
# CMAKE_C_FLAGS is also given on command line
|
|
|
|
# CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}
|
|
|
|
# We extend these in compiler_options.cmake
|
|
|
|
#
|
|
|
|
# Note that CMakeCache.txt contains cmake builtins for these variables,
|
|
|
|
# *not* the values that will actually be used:
|
|
|
|
|
|
|
|
IF(CMAKE_GENERATOR MATCHES "Makefiles")
|
|
|
|
MESSAGE(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
|
|
|
|
ENDIF()
|
|
|
|
GET_PROPERTY(cwd_definitions DIRECTORY PROPERTY COMPILE_DEFINITIONS)
|
|
|
|
MESSAGE(STATUS "COMPILE_DEFINITIONS: ${cwd_definitions}")
|
|
|
|
MESSAGE(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
|
|
|
|
MESSAGE(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
|
|
|
|
IF(CMAKE_BUILD_TYPE AND CMAKE_GENERATOR MATCHES "Makefiles")
|
|
|
|
STRING(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKEBT)
|
|
|
|
MESSAGE(STATUS "CMAKE_C_FLAGS_${CMAKEBT}: ${CMAKE_C_FLAGS_${CMAKEBT}}")
|
|
|
|
MESSAGE(STATUS "CMAKE_CXX_FLAGS_${CMAKEBT}: ${CMAKE_CXX_FLAGS_${CMAKEBT}}")
|
|
|
|
ENDIF()
|
|
|
|
IF(NOT CMAKE_GENERATOR MATCHES "Makefiles")
|
|
|
|
MESSAGE(STATUS "CMAKE_C_FLAGS_DEBUG: ${CMAKE_C_FLAGS_DEBUG}")
|
|
|
|
MESSAGE(STATUS "CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}")
|
|
|
|
MESSAGE(STATUS
|
|
|
|
"CMAKE_C_FLAGS_RELWITHDEBINFO: ${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
|
|
|
MESSAGE(STATUS
|
|
|
|
"CMAKE_CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
|
|
|
ENDIF()
|