# Copyright (c) 2006, 2019, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License, version 2.0, # as published by the Free Software Foundation. # # This program is also distributed with certain software (including # but not limited to OpenSSL) that is licensed under separate terms, # as designated in a particular file or component or in included license # documentation. The authors of MySQL hereby grant you an additional # permission to link the program and your derivative works with the # separately licensed software that they have included with MySQL. # # 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, version 2.0, 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 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA MESSAGE(STATUS "Running cmake version ${CMAKE_VERSION}") IF(WIN32) # CMake 3.8.0 is needed for Visual Studio 2017 and x64 toolset. CMAKE_MINIMUM_REQUIRED(VERSION 3.8.0) ELSEIF(APPLE) # Version 3.12.4 is needed because the new build system of Xcode is not # supported by cmake. 3.12.4 will force using the legacy build system. # Version 3.9.2 is needed because INCLUDE_DIRECTORIES(SYSTEM ...) wasn't # handled properly by the cmake Xcode generator. IF(CMAKE_GENERATOR STREQUAL "Xcode") CMAKE_MINIMUM_REQUIRED(VERSION 3.12.4) ELSE() CMAKE_MINIMUM_REQUIRED(VERSION 3.9.2) ENDIF() ELSEIF(UNIX) # This is currently minimum version on all supported platforms. IF(CMAKE_VERSION VERSION_LESS 3.5.1) # Default cmake is 2.8.12.2 on RedHat IF(EXISTS "/etc/redhat-release") MESSAGE(WARNING "Please use cmake3 rather than cmake on this platform") FIND_PROGRAM(MY_CMAKE3 cmake3 /bin /usr/bin /usr/local/bin) IF(MY_CMAKE3) MESSAGE(STATUS "Found ${MY_CMAKE3}") ELSE() MESSAGE(STATUS "Please install cmake3 (yum install cmake3)") ENDIF() ELSE() # On SunOS /opt/csw/bin/cmake is (most likely) too old. FIND_PROGRAM(MY_UNAME uname /bin /usr/bin /usr/local/bin /sbin) IF(MY_UNAME) EXEC_PROGRAM(uname ARGS -s OUTPUT_VARIABLE MY_HOST_SYSTEM_NAME) IF(MY_HOST_SYSTEM_NAME MATCHES "SunOS") FIND_PROGRAM(MY_CMAKE cmake /usr/bin NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH ) IF(MY_CMAKE) MESSAGE(STATUS "Found ${MY_CMAKE}") EXEC_PROGRAM(${MY_CMAKE} ARGS --version) ELSE() MESSAGE(STATUS "Please install /usr/bin/cmake ") ENDIF() ENDIF() ENDIF() ENDIF() ENDIF() ENDIF() # CMake 3.5 is needed for TARGET_SOURCES(... $) CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1) # Explicitly set CMP0018 and CMP0022 = NEW since newer versions of # CMake has OLD as default even if OLD is deprecated. # See cmake --help-policy CMP0018 / CMP0022 CMAKE_POLICY(SET CMP0018 NEW) CMAKE_POLICY(SET CMP0022 NEW) # Include TARGET_OBJECTS expressions. CMAKE_POLICY(SET CMP0051 NEW) # Disallow use of the LOCATION property for build targets. IF(POLICY CMP0026) CMAKE_POLICY(SET CMP0026 NEW) ENDIF() # In CMake 3.12 and above, the # # * ``check_include_file`` macro in the ``CheckIncludeFile`` module, the # * ``check_include_file_cxx`` macro in the # ``CheckIncludeFileCXX`` module, and the # * ``check_include_files`` macro in the ``CheckIncludeFiles`` module # # now prefer to link the check executable to the libraries listed in the # ``CMAKE_REQUIRED_LIBRARIES`` variable. IF(POLICY CMP0075) CMAKE_POLICY(SET CMP0075 OLD) ENDIF() # Will set GIT_EXECUTABLE and GIT_FOUND FIND_PACKAGE(Git) SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) # First, decide about build type (debug or release) # If cmake is invoked with -DCMAKE_BUILD_TYPE, # respect user wishes and do not (re)define CMAKE_BUILD_TYPE. If WITH_DEBUG # is given, set CMAKE_BUILD_TYPE = Debug. Otherwise, use Relwithdebinfo. IF(DEFINED CMAKE_BUILD_TYPE) SET(HAVE_CMAKE_BUILD_TYPE TRUE) ENDIF() OPTION(WITH_DEBUG "Use dbug/safemutex" OFF) OPTION(CHECK_ERRMSG_FORMAT "Check printf format for English error messages" OFF) # 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) SET(MANUFACTURER "Built from Source" CACHE STRING ${MANUFACTURER_DOCSTRING}) MARK_AS_ADVANCED(MANUFACTURER) ENDIF() # MAX_INDEXES - Set the maximum number of indexes per table, default 64U IF (NOT MAX_INDEXES) SET(MAX_INDEXES 64U) ELSEIF(MAX_INDEXES MATCHES "^[0-9]+[Uu]?$") # MAX_INDEXES should be unsigned, so add the U suffix if it's missing. STRING(REGEX REPLACE "^([0-9]+).*$" "\\1U" MAX_INDEXES "${MAX_INDEXES}") MESSAGE(STATUS "Configuring with MAX_INDEXES = ${MAX_INDEXES}") ELSE() MESSAGE(FATAL_ERROR "MAX_INDEXES should be an unsigned integer.") ENDIF(NOT MAX_INDEXES) IF(MAX_INDEXES GREATER 255) MESSAGE(FATAL_ERROR "MAX_INDEXES values greater than 255 is not supported!") ELSEIF(MAX_INDEXES LESS 64) # Per documentation, ignore values less than 64 and use the default instead. MESSAGE(WARNING "MAX_INDEXES option ignored because it is less than 64.") SET(MAX_INDEXES 64U) ENDIF() # 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") IF(WITH_DEBUG) SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING ${BUILDTYPE_DOCSTRING} FORCE) SET(OLD_WITH_DEBUG 1 CACHE INTERNAL "" FORCE) ELSEIF(NOT HAVE_CMAKE_BUILD_TYPE OR OLD_WITH_DEBUG) IF(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) ENDIF() STRING(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_UPPER) IF(CMAKE_GENERATOR MATCHES "Visual Studio [1-9][0-9].*" AND CMAKE_GENERATOR_TOOLSET STREQUAL "") # Switch to 64 bit toolset on Windows (32 bit is default). # This is recommended as the 32 bit linker will run into address space issues # and not exit for long time. SET(CMAKE_GENERATOR_TOOLSET "host=x64") ENDIF() # On Linux el6/el7 the default gcc is too old, see if devtoolset is installed. # Same with SLES 12, look for gcc 7 there. # We need to look for gcc before calling PROJECT below. OPTION(FORCE_UNSUPPORTED_COMPILER "Disable compiler version checks" OFF) MARK_AS_ADVANCED(WITHOUT_SERVER FORCE_UNSUPPORTED_COMPILER) # Use 'uname -r' and 'rpm -qf /' to figure out host system. # For Docker images we cannot trust uname, so use rpm instead. IF(UNIX) FIND_PROGRAM(MY_UNAME uname /bin /usr/bin /usr/local/bin /sbin) IF(MY_UNAME) EXECUTE_PROCESS(COMMAND ${MY_UNAME} -s OUTPUT_VARIABLE MY_HOST_SYSTEM_NAME OUTPUT_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE MY_UNAME_RESULT ) ENDIF() FIND_PROGRAM(MY_RPM rpm /bin /usr/bin) IF(MY_RPM) EXECUTE_PROCESS(COMMAND ${MY_RPM} -qf / OUTPUT_VARIABLE MY_HOST_FILESYSTEM_NAME OUTPUT_STRIP_TRAILING_WHITESPACE RESULT_VARIABLE MY_RPM_RESULT ) ENDIF() ENDIF() IF(CMAKE_HOST_UNIX AND NOT FORCE_UNSUPPORTED_COMPILER AND NOT CMAKE_C_COMPILER AND NOT CMAKE_CXX_COMPILER) # Cannot INCLUDE(CMakeDetermineSystem) prior to PROJECT initialization below. SET (ENV_CC "$ENV{CC}") SET (ENV_CXX "$ENV{CXX}") IF (ENV_CC STREQUAL "" AND ENV_CXX STREQUAL "") IF(MY_UNAME) EXEC_PROGRAM(${MY_UNAME} ARGS -r OUTPUT_VARIABLE MY_HOST_SYSTEM_VERSION) IF(MY_HOST_SYSTEM_NAME MATCHES "Linux" AND (MY_HOST_SYSTEM_VERSION MATCHES "\\.el[67](uek)?\\.") OR (MY_HOST_FILESYSTEM_NAME MATCHES "\\.el[67]\\.")) MESSAGE(STATUS "This is el6 or el7 as found from 'uname -r' or 'rpm -qf /'") MESSAGE(STATUS "We probably need some devtoolset compiler") FIND_PROGRAM(ALTERNATIVE_GCC gcc NO_DEFAULT_PATH PATHS "/opt/rh/devtoolset-8/root/usr/bin") FIND_PROGRAM(ALTERNATIVE_GPP g++ NO_DEFAULT_PATH PATHS "/opt/rh/devtoolset-8/root/usr/bin") FIND_PROGRAM(ALTERNATIVE_ENABLE enable NO_DEFAULT_PATH PATHS "/opt/rh/devtoolset-8/") IF(ALTERNATIVE_GCC AND ALTERNATIVE_GPP) SET(CMAKE_C_COMPILER ${ALTERNATIVE_GCC}) SET(CMAKE_CXX_COMPILER ${ALTERNATIVE_GPP}) MESSAGE(STATUS "Using ${ALTERNATIVE_GCC}") MESSAGE(STATUS "Using ${ALTERNATIVE_GPP}") ELSE() MESSAGE(WARNING "Could not find devtoolset gcc") ENDIF() ELSEIF(MY_HOST_SYSTEM_NAME MATCHES "Linux" AND EXISTS "/etc/os-release") FILE(READ "/etc/os-release" MY_OS_RELEASE) IF (MY_OS_RELEASE MATCHES "SUSE Linux Enterprise Server 12") MESSAGE(STATUS "We need to look for a newer GCC on SLES 12") FIND_PROGRAM(ALTERNATIVE_GCC gcc-7 NO_DEFAULT_PATH PATHS "/usr/bin") FIND_PROGRAM(ALTERNATIVE_GPP g++-7 NO_DEFAULT_PATH PATHS "/usr/bin") IF (ALTERNATIVE_GCC AND ALTERNATIVE_GPP) SET(CMAKE_C_COMPILER ${ALTERNATIVE_GCC}) SET(CMAKE_CXX_COMPILER ${ALTERNATIVE_GPP}) MESSAGE(STATUS "Using ${ALTERNATIVE_GCC}") MESSAGE(STATUS "Using ${ALTERNATIVE_GPP}") # Use the new ABI so that std::string can be used with allocators # that are not default-constructible (e.g. Memroot_allocator) ADD_DEFINITIONS(-D_GLIBCXX_USE_CXX11_ABI=1) ELSE() MESSAGE(WARNING "Could not find newer gcc") ENDIF() ENDIF() ENDIF() ENDIF() ENDIF() ENDIF() # 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() # Remember if WITH_NDBCLUSTER was specified by user IF(DEFINED WITH_NDBCLUSTER) SET(HAVE_WITH_NDBCLUSTER 1) ENDIF() OPTION(WITH_NDBCLUSTER "Build MySQL Cluster" OFF) OPTION(WITH_NDBCLUSTER_STORAGE_ENGINE "Legacy and deprecated alias for WITH_NDBCLUSTER" OFF) OPTION(WITH_PLUGIN_NDBCLUSTER "Legacy and deprecated alias for WITH_NDBCLUSTER" OFF) MARK_AS_ADVANCED(WITH_NDBCLUSTER_STORAGE_ENGINE WITH_PLUGIN_NDBCLUSTER) IF(NOT HAVE_WITH_NDBCLUSTER) # Unless user has used WITH_NDBCLUSTER also look at # some of the legacy variables IF(WITH_PLUGIN_NDBCLUSTER) MESSAGE(WARNING "WITH_PLUGIN_NDBCLUSTER is deprecated and will be " "removed in a future release. Please use WITH_NDBCLUSTER instead.") SET(WITH_NDBCLUSTER ON) ENDIF() IF(WITH_NDBCLUSTER_STORAGE_ENGINE) MESSAGE(WARNING "WITH_NDBCLUSTER_STORAGE_ENGINE is deprecated and " "will be removed in a future release. Please use WITH_NDBCLUSTER " "instead.") SET(WITH_NDBCLUSTER ON) ENDIF() ENDIF() IF(WITH_NDBCLUSTER) MESSAGE(STATUS "Building MySQL Cluster") ENDIF() INCLUDE(mysql_version) IF(POLICY CMP0048) CMAKE_POLICY(SET CMP0048 NEW) PROJECT(${MYSQL_PROJECT_NAME} VERSION ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}) ELSE() PROJECT(${MYSQL_PROJECT_NAME}) ENDIF() GET_FILENAME_COMPONENT(REALPATH_CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR} REALPATH) GET_FILENAME_COMPONENT(REALPATH_CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR} REALPATH) MESSAGE(STATUS "Source directory ${REALPATH_CMAKE_SOURCE_DIR}") MESSAGE(STATUS "Binary directory ${REALPATH_CMAKE_BINARY_DIR}") # IN PB2 we have a few configurations which are built in-source (e.g. doxygen). IF(DEFINED ENV{PB2WORKDIR}) OPTION(FORCE_INSOURCE_BUILD "Allow in-source build" ON) ELSE() OPTION(FORCE_INSOURCE_BUILD "Allow in-source build" OFF) ENDIF() # https://gitlab.kitware.com/cmake/community/wikis/FAQ # cmake-does-not-generate-a-make-distclean-target-why # Why disallow in-source build? # Basically because 'make clean' or 'make distclean' do not work. # So if you do a 'git pull' you may end up with a developer sandbox # that no longer works as expected (CMakeCache.txt and other # generated/configured files may contain data which is no longer valid) IF(${REALPATH_CMAKE_SOURCE_DIR} STREQUAL ${REALPATH_CMAKE_BINARY_DIR}) IF(FORCE_INSOURCE_BUILD) MESSAGE(WARNING "This is an in-source build") ELSE() MESSAGE(FATAL_ERROR "Please do not build in-source. " "Out-of source builds are highly recommended: " "you can have multiple builds for the same source, " "and there is an easy way to do cleanup, " "simply remove the build directory " "(note that 'make clean' or 'make distclean' does *not* work) " "\nYou *can* force in-source build by invoking cmake with -DFORCE_INSOURCE_BUILD=1") ENDIF() ENDIF() MACRO(REPORT_CXX_FLAGS) MESSAGE(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}") FOREACH(BUILD_TYPE "" _DEBUG _RELWITHDEBINFO _RELEASE _MINSIZEREL) SET(flag "CMAKE_CXX_FLAGS${BUILD_TYPE}") MESSAGE(STATUS "${flag}: ${${flag}}") ENDFOREACH() ENDMACRO() # STRING(APPEND ...) from cmake VERSION 3.4 MACRO(STRING_APPEND STRING_VAR INPUT) SET(${STRING_VAR} "${${STRING_VAR}}${INPUT}") ENDMACRO() MACRO(STRING_PREPEND STRING_VAR INPUT) SET(${STRING_VAR} "${INPUT}${${STRING_VAR}}") ENDMACRO() # Write content to file, using CONFIGURE_FILE # The advantage compared to FILE(WRITE) is that timestamp # does not change if file already has the same content SET(MYSQL_CMAKE_SCRIPT_DIR "${CMAKE_SOURCE_DIR}/cmake") MACRO(CONFIGURE_FILE_CONTENT content file) SET(CMAKE_CONFIGURABLE_FILE_CONTENT "${content}\n") CONFIGURE_FILE( ${MYSQL_CMAKE_SCRIPT_DIR}/configurable_file_content.in ${file} @ONLY) ENDMACRO() SET(BUILD_IS_SINGLE_CONFIG TRUE) MESSAGE(STATUS "CMAKE_GENERATOR: ${CMAKE_GENERATOR}") IF(CMAKE_GENERATOR MATCHES "Visual Studio" OR CMAKE_GENERATOR STREQUAL "Xcode") SET(BUILD_IS_SINGLE_CONFIG FALSE) ENDIF() IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") SET(MY_COMPILER_IS_CLANG 1) ELSEIF(CMAKE_CXX_COMPILER_ID MATCHES "GNU") SET(MY_COMPILER_IS_GNU 1) ENDIF() IF(MY_COMPILER_IS_CLANG OR MY_COMPILER_IS_GNU) SET(MY_COMPILER_IS_GNU_OR_CLANG 1) ENDIF() # Maintainer mode is default on only for debug builds using GCC/G++ IF(CMAKE_BUILD_TYPE_UPPER STREQUAL "DEBUG" OR WITH_DEBUG) IF(MY_COMPILER_IS_GNU) SET(MYSQL_MAINTAINER_MODE ON CACHE BOOL "MySQL maintainer-specific development environment") ENDIF() ENDIF() OPTION(WITH_DEFAULT_COMPILER_OPTIONS "Use flags from cmake/build_configurations/compiler_options.cmake" ON) OPTION(WITH_DEFAULT_FEATURE_SET "Use feature set in cmake/build_configurations/feature_set.cmake" ON) IF(BUILD_CONFIG) INCLUDE( ${CMAKE_SOURCE_DIR}/cmake/build_configurations/${BUILD_CONFIG}.cmake) ENDIF() OPTION(INSTALL_STATIC_LIBRARIES "Install static libraries" ON) #cmake on 64bit windows/mac/solaris doesn't set CMAKE_SYSTEM_PROCESSOR correctly SET(MYSQL_MACHINE_TYPE ${CMAKE_SYSTEM_PROCESSOR}) SET(KNOWN_64BIT_ARCHITECTURES aarch64 ppc64 ppc64le s390x x86_64 ) # 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() IF(UNIX) OPTION(WITH_INNODB_MEMCACHED "" OFF) OPTION(ENABLE_MEMCACHED_SASL "Enable SASL on InnoDB Memcached" OFF) OPTION(ENABLE_MEMCACHED_SASL_PWDB "Enable SASL on InnoDB Memcached" OFF) ELSE() OPTION(WITH_INNODB_MEMCACHED "" OFF) ENDIF() # Following autotools tradition, add preprocessor definitions # specified in environment variable CPPFLAGS IF(DEFINED ENV{CPPFLAGS}) ADD_DEFINITIONS($ENV{CPPFLAGS}) ENDIF() INCLUDE(CheckTypeSize) CHECK_TYPE_SIZE("void *" SIZEOF_VOIDP) MESSAGE(STATUS "SIZEOF_VOIDP ${SIZEOF_VOIDP}") # On some platforms, cmake may think that CMAKE_SIZEOF_VOID_P == 4 # even if we have configured for 64bit build.... SET(CMAKE_SIZEOF_VOID_P ${SIZEOF_VOIDP}) IF(WITH_DEFAULT_COMPILER_OPTIONS) INCLUDE(${CMAKE_SOURCE_DIR}/cmake/build_configurations/compiler_options.cmake) ENDIF() IF(WITH_DEFAULT_FEATURE_SET) INCLUDE(${CMAKE_SOURCE_DIR}/cmake/build_configurations/feature_set.cmake) ENDIF() INCLUDE(CMakePushCheckState) # Add macros INCLUDE(pkg-config) INCLUDE(character_sets) INCLUDE(compile_flags) INCLUDE(cpu_info) INCLUDE(fileutils) INCLUDE(zlib) INCLUDE(zstd) INCLUDE(lz4) INCLUDE(icu) INCLUDE(libevent) INCLUDE(ssl) INCLUDE(sasl) INCLUDE(rpc) INCLUDE(readline) INCLUDE(protobuf) INCLUDE(package_name) INCLUDE(libutils) INCLUDE(plugin) INCLUDE(component) INCLUDE(install_macros) INCLUDE(install_layout) INCLUDE(mysql_add_executable) INCLUDE(mysqlgcs) INCLUDE(curl) INCLUDE(rapidjson) OPTION(WITH_JEMALLOC "Use jemalloc rather than builtin malloc/free etc." OFF) IF(WITH_JEMALLOC) FIND_LIBRARY(JEMALLOC_LIBRARY NAMES jemalloc) IF(NOT JEMALLOC_LIBRARY) MESSAGE(FATAL_ERROR "Could not find jemalloc library") ENDIF() STRING_APPEND(CMAKE_EXE_LINKER_FLAGS " -ljemalloc") STRING_APPEND(CMAKE_MODULE_LINKER_FLAGS " -ljemalloc") STRING_APPEND(CMAKE_SHARED_LINKER_FLAGS " -ljemalloc") STRING_APPEND(CMAKE_C_FLAGS " -fno-builtin-malloc -fno-builtin-calloc") STRING_APPEND(CMAKE_C_FLAGS " -fno-builtin-realloc -fno-builtin-free") STRING_APPEND(CMAKE_CXX_FLAGS " -fno-builtin-malloc -fno-builtin-calloc") STRING_APPEND(CMAKE_CXX_FLAGS " -fno-builtin-realloc -fno-builtin-free") ENDIF() OPTION(ENABLED_PROFILING "Enable profiling" ON) OPTION(WITHOUT_SERVER OFF) IF(UNIX) OPTION(WITH_VALGRIND "Valgrind instrumentation" OFF) ENDIF() IF(WIN32) OPTION(WITH_MSCRT_DEBUG "MS Visual Studio Debug CRT instrumentation" OFF) ENDIF() IF(NOT WITHOUT_SERVER) OPTION(WITH_UNIT_TESTS "Compile MySQL with unit tests" ON) OPTION(WITH_ROUTER "Build MySQL Router" ON) ENDIF() OPTION(WITH_AUTHENTICATION_LDAP "Report error if the LDAP authentication plugin cannot be built." OFF) OPTION(WITH_LOCK_ORDER "Build the lock order mutex instrumentation code." OFF) IF(WITH_LOCK_ORDER) EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E make_directory lock_order WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) ENDIF() 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) CMAKE_PUSH_CHECK_STATE() STRING_APPEND(CMAKE_REQUIRED_FLAGS " ${FLAG}") CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${RESULT} FAIL_REGEX "unknown argument ignored" 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" FAIL_REGEX "error: visibility" FAIL_REGEX "warning: visibility" ) CMAKE_POP_CHECK_STATE() ENDMACRO() MACRO (MY_CHECK_CXX_COMPILER_FLAG FLAG RESULT) CMAKE_PUSH_CHECK_STATE() STRING_APPEND(CMAKE_REQUIRED_FLAGS " ${FLAG}") CHECK_CXX_SOURCE_COMPILES("int main(void) { return 0; }" ${RESULT} FAIL_REGEX "unknown argument ignored" 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" FAIL_REGEX "error: visibility" FAIL_REGEX "warning: visibility" ) CMAKE_POP_CHECK_STATE() ENDMACRO() # Check whether a specific warning option is supported. # Intended use is primarily to silence warnings from third-party code. # If *our* code has warnings with gcc[56789] or clang[345678] the # code should be fixed, rather than silencing the compiler warnings. # # Returns the corresponding "-Wno-