diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:07:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:07:14 +0000 |
commit | a175314c3e5827eb193872241446f2f8f5c9d33c (patch) | |
tree | cd3d60ca99ae00829c52a6ca79150a5b6e62528b /cmake | |
parent | Initial commit. (diff) | |
download | mariadb-10.5-upstream.tar.xz mariadb-10.5-upstream.zip |
Adding upstream version 1:10.5.12.upstream/1%10.5.12upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
70 files changed, 6533 insertions, 0 deletions
diff --git a/cmake/FindBISON.cmake b/cmake/FindBISON.cmake new file mode 100644 index 00000000..28ae3f8f --- /dev/null +++ b/cmake/FindBISON.cmake @@ -0,0 +1,8 @@ +IF(DEFINED BISON_EXECUTABLE) + SET(bison_quiet QUIET) +ENDIF() + +set(orig_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}) +unset(CMAKE_MODULE_PATH) +find_package(BISON ${BISON_FIND_VERSION} ${bison_quiet} ${BISON_FIND_REQUIRED}) +set(CMAKE_MODULE_PATH ${orig_CMAKE_MODULE_PATH}) diff --git a/cmake/FindGit.cmake b/cmake/FindGit.cmake new file mode 100644 index 00000000..8178b614 --- /dev/null +++ b/cmake/FindGit.cmake @@ -0,0 +1,13 @@ +if(GIT_EXECUTABLE) + set(GIT_FOUND TRUE) + return() +endif() +if(DEFINED GIT_EXECUTABLE) + set(GIT_FOUND FALSE) + return() +endif() + +set(orig_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}) +unset(CMAKE_MODULE_PATH) +include(FindGit) +set(CMAKE_MODULE_PATH ${orig_CMAKE_MODULE_PATH}) diff --git a/cmake/FindJNI.cmake b/cmake/FindJNI.cmake new file mode 100644 index 00000000..b2c6f849 --- /dev/null +++ b/cmake/FindJNI.cmake @@ -0,0 +1,13 @@ +if(JAVA_AWT_LIBRARY AND JAVA_INCLUDE_PATH) + set(JNI_FOUND TRUE) + return() +endif() +if(DEFINED JAVA_AWT_LIBRARY) + set(JNI_FOUND FALSE) + return() +endif() + +set(orig_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}) +unset(CMAKE_MODULE_PATH) +include(FindJNI) +set(CMAKE_MODULE_PATH ${orig_CMAKE_MODULE_PATH}) diff --git a/cmake/FindJava.cmake b/cmake/FindJava.cmake new file mode 100644 index 00000000..714f56b1 --- /dev/null +++ b/cmake/FindJava.cmake @@ -0,0 +1,13 @@ +if(Java_JAVA_EXECUTABLE) + set(JAVA_FOUND TRUE) + return() +endif() +if(DEFINED Java_JAVA_EXECUTABLE) + set(JAVA_FOUND FALSE) + return() +endif() + +set(orig_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}) +unset(CMAKE_MODULE_PATH) +include(FindJava) +set(CMAKE_MODULE_PATH ${orig_CMAKE_MODULE_PATH}) diff --git a/cmake/FindLZ4.cmake b/cmake/FindLZ4.cmake new file mode 100644 index 00000000..46c1fdc1 --- /dev/null +++ b/cmake/FindLZ4.cmake @@ -0,0 +1,9 @@ +find_path(LZ4_INCLUDE_DIR NAMES lz4.h) +find_library(LZ4_LIBRARIES NAMES lz4) + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( + LZ4 DEFAULT_MSG + LZ4_LIBRARIES LZ4_INCLUDE_DIR) + +mark_as_advanced(LZ4_INCLUDE_DIR LZ4_LIBRARIES) diff --git a/cmake/FindZSTD.cmake b/cmake/FindZSTD.cmake new file mode 100644 index 00000000..ede59010 --- /dev/null +++ b/cmake/FindZSTD.cmake @@ -0,0 +1,21 @@ +# - Find zstd +# Find the zstd compression library and includes +# +# ZSTD_INCLUDE_DIR - where to find zstd.h, etc. +# ZSTD_LIBRARIES - List of libraries when using zstd. +# ZSTD_FOUND - True if zstd found. + +find_path(ZSTD_INCLUDE_DIR + NAMES zstd.h + HINTS ${ZSTD_ROOT_DIR}/include) + +find_library(ZSTD_LIBRARIES + NAMES zstd + HINTS ${ZSTD_ROOT_DIR}/lib) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(ZSTD DEFAULT_MSG ZSTD_LIBRARIES ZSTD_INCLUDE_DIR) + +mark_as_advanced( + ZSTD_LIBRARIES + ZSTD_INCLUDE_DIR) diff --git a/cmake/Internal/CPack/CPackRPM.cmake b/cmake/Internal/CPack/CPackRPM.cmake new file mode 100644 index 00000000..174d28b9 --- /dev/null +++ b/cmake/Internal/CPack/CPackRPM.cmake @@ -0,0 +1,93 @@ +# +# Wrapper for CPackRPM.cmake +# + +IF(NOT DEFINED RPM_RECOMMENDS) + EXECUTE_PROCESS(COMMAND rpm --recommends ERROR_QUIET RESULT_VARIABLE RPM_RECOMMENDS) + MESSAGE("CPackRPM:Debug: Testing rpm --recommends: ${RPM_RECOMMENDS}") +ENDIF() + +# +# Support for per-component LICENSE and VENDOR +# +# per component values, if present, are copied into global CPACK_RPM_PACKAGE_xxx +# +macro(set_from_component WHAT) + set(orig_CPACK_RPM_PACKAGE_${WHAT} ${CPACK_RPM_PACKAGE_${WHAT}}) + if(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${WHAT}) + set(CPACK_RPM_PACKAGE_${WHAT} ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_${WHAT}}) + endif() +endmacro() +macro(restore WHAT) + set(CPACK_RPM_PACKAGE_${WHAT} ${orig_CPACK_RPM_PACKAGE_${WHAT}}) +endmacro() + +set_from_component(LICENSE) +set_from_component(VENDOR) +set_from_component(VERSION) + +# +# Support for the %posttrans scriptlet +# +# the scriptlet, if present, is appended (together with the %posttrans tag) +# to the pre-uninstall scriptlet +# +if(CMAKE_VERSION VERSION_LESS 3.18) + set(base_time "PRE") + set(base_type "UNINSTALL") + set(base_var CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_${base_time}_${base_type}_SCRIPT_FILE) + set(acc) + + macro(read_one_file time_ type_ tag_) + set(var CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_${time_}_${type_}_SCRIPT_FILE) + if (${var}) + file(READ ${${var}} content) + set(acc "${tag_}\n${content}\n\n${acc}") + endif() + endmacro() + + read_one_file("POST" "TRANS" "%posttrans") + if (acc) + set(orig_${base_var} ${${base_var}}) + read_one_file(${base_time} ${base_type} "") + set(${base_var} ${CPACK_TOPLEVEL_DIRECTORY}/SPECS/${CPACK_RPM_PACKAGE_COMPONENT}_${base_time}_${base_type}.scriptlet) + file(WRITE ${${base_var}} "${acc}") + endif() +endif(CMAKE_VERSION VERSION_LESS 3.18) + +# +# Support for the Recommends: tag. +# We don't use Suggests: so here he hijack Suggests: variable +# to implement Recommends: +# +IF (CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_RECOMMENDS) + IF (RPM_RECOMMENDS EQUAL 0) # exit code 0 means ok + SET(TMP_RPM_SUGGESTS "Recommends: ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_RECOMMENDS}") + ELSE() # rpm is too old to recommend + SET(CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_REQUIRES + "${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_REQUIRES} ${CPACK_RPM_${CPACK_RPM_PACKAGE_COMPONENT}_PACKAGE_RECOMMENDS}") + ENDIF() +ENDIF() + +# load the original CPackRPM.cmake +set(orig_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}) +unset(CMAKE_MODULE_PATH) +if (CMAKE_VERSION VERSION_GREATER "3.12.99") + include(Internal/CPack/CPackRPM) +else() + include(CPackRPM) +endif() +set(CMAKE_MODULE_PATH ${orig_CMAKE_MODULE_PATH}) + +restore(LICENSE) +restore(VENDOR) +restore(VERSION) +if(${orig_${base_var}}) + set(${base_var} ${orig_${base_var}}) +endif() + +# per-component cleanup +foreach(_RPM_SPEC_HEADER URL REQUIRES SUGGESTS PROVIDES OBSOLETES PREFIX CONFLICTS AUTOPROV AUTOREQ AUTOREQPROV) + unset(TMP_RPM_${_RPM_SPEC_HEADER}) + unset(CPACK_RPM_PACKAGE_${_RPM_SPEC_HEADER}_TMP) +endforeach() diff --git a/cmake/abi_check.cmake b/cmake/abi_check.cmake new file mode 100644 index 00000000..98877be9 --- /dev/null +++ b/cmake/abi_check.cmake @@ -0,0 +1,83 @@ +# Copyright (c) 2009, 2011, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# +# Headers which need to be checked for abi/api compatibility are in +# API_PREPROCESSOR_HEADER. plugin.h is tested implicitly via +# plugin_audit.h and plugin_ftparser.h. +# +# We use gcc specific preprocessing command and sed/diff, so it will +# only be run on Unix and only if gcc is used. On some Unixes, +# (Solaris) sed or diff might act differently from GNU, so we run only +# on systems we can trust. +IF(APPLE OR CMAKE_SYSTEM_NAME MATCHES "Linux") + SET(RUN_ABI_CHECK 1) +ELSE() + SET(RUN_ABI_CHECK 0) +ENDIF() + +IF(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang" AND RUN_ABI_CHECK) + IF(CMAKE_C_COMPILER MATCHES "ccache$") + SET(COMPILER ${CMAKE_C_COMPILER_ARG1}) + STRING(REGEX REPLACE "^ " "" COMPILER ${COMPILER}) + ELSE() + SET(COMPILER ${CMAKE_C_COMPILER}) + ENDIF() + SET(API_PREPROCESSOR_HEADER + ${CMAKE_SOURCE_DIR}/include/mysql/plugin_audit.h + ${CMAKE_SOURCE_DIR}/include/mysql/plugin_ftparser.h + ${CMAKE_SOURCE_DIR}/include/mysql.h + ${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_v1.h + ${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_v2.h + ${CMAKE_SOURCE_DIR}/include/mysql/client_plugin.h + ${CMAKE_SOURCE_DIR}/include/mysql/plugin_auth.h + ${CMAKE_SOURCE_DIR}/include/mysql/plugin_password_validation.h + ${CMAKE_SOURCE_DIR}/include/mysql/plugin_encryption.h + ${CMAKE_SOURCE_DIR}/include/mysql/plugin_data_type.h + ${CMAKE_SOURCE_DIR}/include/mysql/plugin_function.h + ) + + ADD_CUSTOM_TARGET(abi_check ALL + COMMAND ${CMAKE_COMMAND} + -DCOMPILER=${COMPILER} + -DSOURCE_DIR=${CMAKE_SOURCE_DIR} + -DBINARY_DIR=${CMAKE_BINARY_DIR} + "-DABI_HEADERS=${API_PREPROCESSOR_HEADER}" + -P ${CMAKE_SOURCE_DIR}/cmake/do_abi_check.cmake + VERBATIM + ) + + ADD_CUSTOM_TARGET(abi_update + COMMAND ${CMAKE_COMMAND} + -DCOMPILER=${COMPILER} + -DABI_UPDATE=1 + -DSOURCE_DIR=${CMAKE_SOURCE_DIR} + -DBINARY_DIR=${CMAKE_BINARY_DIR} + "-DABI_HEADERS=${API_PREPROCESSOR_HEADER}" + -P ${CMAKE_SOURCE_DIR}/cmake/do_abi_check.cmake + VERBATIM + ) + + ADD_CUSTOM_TARGET(abi_check_all + COMMAND ${CMAKE_COMMAND} + -DCOMPILER=${COMPILER} + -DSOURCE_DIR=${CMAKE_SOURCE_DIR} + -DBINARY_DIR=${CMAKE_BINARY_DIR} + "-DABI_HEADERS=${API_PREPROCESSOR_HEADER}" + -P ${CMAKE_SOURCE_DIR}/cmake/do_abi_check.cmake + VERBATIM + ) +ENDIF() + diff --git a/cmake/aws_sdk.cmake b/cmake/aws_sdk.cmake new file mode 100644 index 00000000..f6f88f2b --- /dev/null +++ b/cmake/aws_sdk.cmake @@ -0,0 +1,98 @@ +MACRO (SKIP_AWS_SDK MSG) + SET(${RETVAL} OFF PARENT_SCOPE) + SET(${REASON} ${MSG} PARENT_SCOPE) + RETURN() +ENDMACRO() + +FUNCTION (CHECK_AWS_SDK RETVAL REASON) + # AWS_SDK_EXTERNAL_PROJECT must be ON + IF(NOT AWS_SDK_EXTERNAL_PROJECT) + SKIP_AWS_SDK("AWS_SDK_EXTERNAL_PROJECT is not ON") + ENDIF() + IF(NOT NOT_FOR_DISTRIBUTION) + SKIP_AWS_SDK("AWS SDK has Apache 2.0 License which is not complatible with GPLv2. Set -DNOT_FOR_DISTRIBUTION=ON if you need it") + ENDIF() + # Check compiler support + IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + EXECUTE_PROCESS(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) + IF (GCC_VERSION VERSION_LESS 4.8) + SKIP_AWS_SDK("GCC VERSION too old (${GCC_VERSION}, required is 4.8 or later") + ENDIF() + ELSEIF (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + IF ((CMAKE_CXX_COMPILER_VERSION AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3) OR + (CLANG_VERSION_STRING AND CLANG_VERSION_STRING VERSION_LESS 3.3)) + SKIP_AWS_SDK("Clang version too old, required is 3.3 or later") + ENDIF() + ELSEIF(MSVC) + IF (MSVC_VERSION LESS 1800) + SKIP_AWS_SDK("MSVC version too old, required is VS2015 or later") + ENDIF() + ELSE() + SKIP_AWS_SDK("Unsupported compiler") + ENDIF() + + # Check OS support + IF (NOT(WIN32 OR APPLE OR (CMAKE_SYSTEM_NAME MATCHES "Linux"))) + SKIP_AWS_SDK("OS unsupported by AWS SDK") + ENDIF() + + # Build from source, using ExternalProject_Add + # AWS C++ SDK requires cmake 2.8.12 + IF(CMAKE_VERSION VERSION_LESS "2.8.12") + SKIP_AWS_SDK("CMake is too old") + ENDIF() + + IF(UNIX) + # Check librairies required for building SDK + FIND_PACKAGE(CURL) + SET_PACKAGE_PROPERTIES(CURL PROPERTIES TYPE REQUIRED) + IF(NOT CURL_FOUND) + SKIP_AWS_SDK("AWS C++ SDK requires libcurl development package") + ENDIF() + FIND_PATH(UUID_INCLUDE_DIR uuid/uuid.h) + IF(NOT UUID_INCLUDE_DIR) + SKIP_AWS_SDK("AWS C++ SDK requires uuid development package") + ENDIF() + IF(NOT APPLE) + FIND_LIBRARY(UUID_LIBRARIES uuid) + SET_PACKAGE_PROPERTIES(UUID_LIBRARIES PROPERTIES TYPE REQUIRED) + IF(NOT UUID_LIBRARIES) + SKIP_AWS_SDK("AWS C++ SDK requires uuid development package") + ENDIF() + FIND_PACKAGE(OpenSSL) + SET_PACKAGE_PROPERTIES(OpenSSL PROPERTIES TYPE REQUIRED) + IF(NOT OPENSSL_FOUND) + SKIP_AWS_SDK("AWS C++ SDK requires openssl development package") + ENDIF() + ENDIF() + ENDIF() + SET(${RETVAL} ON PARENT_SCOPE) +ENDFUNCTION() + + +# USE_AWS_SDK_LIBS(target sdk_component1 ... sdk_component_N) +# Example usage +# USE_AWS_SDK_LIBS(aws_key_management kms s3) +FUNCTION(USE_AWS_SDK_LIBS) + SET(SDK_COMPONENTS ${ARGN}) + LIST(GET SDK_COMPONENTS 0 target) + IF(NOT TARGET ${target}) + MESSAGE(FATAL_ERROR "${target} is not a valid target") + ENDIF() + SET(NON_DISTRIBUTABLE_WARNING "Apache 2.0" CACHE INTERNAL "") + LIST(REMOVE_AT SDK_COMPONENTS 0) + FOREACH(comp ${SDK_COMPONENTS}) + SET_PROPERTY(GLOBAL PROPERTY AWS_SDK_LIBS ${comp} APPEND) + TARGET_LINK_LIBRARIES(${target} aws-cpp-sdk-${comp}) + ENDFOREACH() + TARGET_LINK_LIBRARIES(${target} aws-cpp-sdk-core) + TARGET_INCLUDE_DIRECTORIES(${target} PRIVATE ${PROJECT_BINARY_DIR}/extra/aws_sdk/aws_sdk_cpp/include) + # Link OS libraries that AWS SDK depends on + IF(WIN32) + TARGET_LINK_LIBRARIES(${target} bcrypt winhttp wininet userenv version) + ELSE() + FIND_PACKAGE(CURL REQUIRED) + FIND_PACKAGE(OpenSSL REQUIRED) + TARGET_LINK_LIBRARIES(${target} ${OPENSSL_LIBRARIES} ${CURL_LIBRARIES} ${UUID_LIBRARIES}) + ENDIF() +ENDFUNCTION() diff --git a/cmake/build_configurations/mysql_release.cmake b/cmake/build_configurations/mysql_release.cmake new file mode 100644 index 00000000..fc90529a --- /dev/null +++ b/cmake/build_configurations/mysql_release.cmake @@ -0,0 +1,285 @@ +# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2021, MariaDB Corporation. +# +# 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# This file includes build settings used for MySQL release + +INCLUDE(CheckIncludeFiles) +INCLUDE(CheckLibraryExists) +INCLUDE(CheckTypeSize) + +# XXX package_name.cmake uses this too, move it somewhere global +CHECK_TYPE_SIZE("void *" SIZEOF_VOIDP) +IF(SIZEOF_VOIDP EQUAL 4) + SET(32BIT 1) +ENDIF() +IF(SIZEOF_VOIDP EQUAL 8) + SET(64BIT 1) +ENDIF() + +# include aws_key_management plugin in release builds +OPTION(AWS_SDK_EXTERNAL_PROJECT "Allow download and build AWS C++ SDK" ON) + +SET(FEATURE_SET "community" CACHE STRING +" Selection of features. Options are + - xsmall : + - small: embedded + - classic: embedded + archive + federated + blackhole + - large : embedded + archive + federated + blackhole + innodb + - xlarge: embedded + archive + federated + blackhole + innodb + partition + - community: all features (currently == xlarge) +" +) + +SET(FEATURE_SET_xsmall 1) +SET(FEATURE_SET_small 2) +SET(FEATURE_SET_classic 3) +SET(FEATURE_SET_large 5) +SET(FEATURE_SET_xlarge 6) +SET(FEATURE_SET_community 7) + +IF(FEATURE_SET) + STRING(TOLOWER ${FEATURE_SET} feature_set) + SET(num ${FEATURE_SET_${feature_set}}) + IF(NOT num) + MESSAGE(FATAL_ERROR "Invalid FEATURE_SET option '${feature_set}'. + Should be xsmall, small, classic, large, or community + ") + ENDIF() + SET(PLUGIN_PARTITION "NO") + IF(num EQUAL FEATURE_SET_xsmall) + SET(WITH_NONE ON) + ENDIF() + + IF(num GREATER FEATURE_SET_small) + SET(PLUGIN_ARCHIVE "STATIC") + SET(PLUGIN_BLACKHOLE "STATIC") + SET(PLUGIN_FEDERATEDX "STATIC") + SET(PLUGIN_FEEDBACK "STATIC") + ENDIF() + IF(num GREATER FEATURE_SET_classic) + SET(PLUGIN_INNOBASE "STATIC") + ENDIF() + IF(num GREATER FEATURE_SET_large) + SET(PLUGIN_PARTITION "STATIC") + #SET(PLUGIN_CASSANDRA "STATIC") + ENDIF() + IF(num GREATER FEATURE_SET_xlarge) + # OPTION(WITH_ALL ON) + # better no set this, otherwise server would be linked + # statically with experimental stuff like audit_null + ENDIF() +ENDIF() + +SET(WITH_INNODB_SNAPPY OFF CACHE STRING "") +SET(WITH_NUMA 0 CACHE BOOL "") +SET(CPU_LEVEL1_DCACHE_LINESIZE 0) + +IF(NOT EXISTS ${CMAKE_SOURCE_DIR}/.git) + SET(GIT_EXECUTABLE GIT_EXECUTABLE-NOTFOUND CACHE FILEPATH "") +ENDIF() + +IF(WIN32) + SET(INSTALL_MYSQLTESTDIR "" CACHE STRING "") + SET(INSTALL_SQLBENCHDIR "" CACHE STRING "") + SET(INSTALL_SUPPORTFILESDIR "" CACHE STRING "") +ELSEIF(CMAKE_SYSTEM_NAME MATCHES "AIX") + # AIX freesource is RPM, but different than Linux RPM + SET(WITH_SSL system CACHE STRING "") + SET(WITH_ZLIB system CACHE STRING "") +ELSEIF(RPM) + SET(WITH_SSL system CACHE STRING "") + SET(WITH_ZLIB system CACHE STRING "") + SET(CHECKMODULE /usr/bin/checkmodule CACHE FILEPATH "") + SET(SEMODULE_PACKAGE /usr/bin/semodule_package CACHE FILEPATH "") + SET(PLUGIN_AUTH_SOCKET YES CACHE STRING "") + SET(WITH_EMBEDDED_SERVER ON CACHE BOOL "") + # not yet, SLES 12.3 doesn't provide pcre2 + #SET(WITH_PCRE system CACHE STRING "") +ELSEIF(DEB) + SET(WITH_SSL system CACHE STRING "") + SET(WITH_ZLIB system CACHE STRING "") + SET(WITH_LIBWRAP ON) + SET(HAVE_EMBEDDED_PRIVILEGE_CONTROL ON) + SET(PLUGIN_AUTH_SOCKET YES CACHE STRING "") + SET(WITH_EMBEDDED_SERVER ON CACHE BOOL "") + SET(WITH_PCRE system CACHE STRING "") +ELSE() + SET(WITH_SSL bundled CACHE STRING "") + SET(WITH_PCRE bundled CACHE STRING "") + SET(WITH_ZLIB bundled CACHE STRING "") + SET(WITH_JEMALLOC static CACHE STRING "") + SET(PLUGIN_AUTH_SOCKET STATIC CACHE STRING "") + SET(WITH_STRIPPED_CLIENT ON CACHE BOOL "Strip all client binaries") + SET(WITH_PCRE bundled CACHE STRING "") +ENDIF() + +IF(NOT COMPILATION_COMMENT) + SET(COMPILATION_COMMENT "MariaDB Server") +ENDIF() + +IF(WIN32) + IF(NOT CMAKE_USING_VC_FREE_TOOLS) + # Sign executables with authenticode certificate + SET(SIGNCODE 1 CACHE BOOL "") + ENDIF() +ENDIF() + +IF(UNIX) + SET(WITH_EXTRA_CHARSETS all CACHE STRING "") + SET(PLUGIN_AUTH_PAM YES CACHE BOOL "") + + IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + IF(NOT IGNORE_AIO_CHECK) + # Ensure aio is available on Linux (required by InnoDB) + CHECK_INCLUDE_FILES(libaio.h HAVE_LIBAIO_H) + CHECK_LIBRARY_EXISTS(aio io_queue_init "" HAVE_LIBAIO) + IF(NOT HAVE_LIBAIO_H OR NOT HAVE_LIBAIO) + UNSET(HAVE_LIBAIO_H CACHE) + UNSET(HAVE_LIBAIO CACHE) + MESSAGE(FATAL_ERROR " + aio is required on Linux, you need to install the required library: + + Debian/Ubuntu: apt-get install libaio-dev + RedHat/Fedora/Oracle Linux: yum install libaio-devel + SuSE: zypper install libaio-devel + + If you really do not want it, pass -DIGNORE_AIO_CHECK=ON to cmake. + ") + ENDIF() + + # Unfortunately, linking shared libmysqld with static aio + # does not work, unless we add also dynamic one. This also means + # libmysqld.so will depend on libaio.so + #SET(LIBMYSQLD_SO_EXTRA_LIBS aio) + ENDIF() + ENDIF() + +ENDIF() + +# Compiler options +IF(UNIX) + + # Default GCC flags + IF(CMAKE_COMPILER_IS_GNUCC) + SET(COMMON_C_FLAGS "-g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -Wno-uninitialized") + SET(CMAKE_C_FLAGS_DEBUG "-O ${COMMON_C_FLAGS}") + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_C_FLAGS}") + ENDIF() + IF(CMAKE_COMPILER_IS_GNUCXX) + SET(COMMON_CXX_FLAGS "-g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -Wno-uninitialized") + SET(CMAKE_CXX_FLAGS_DEBUG "-O ${COMMON_CXX_FLAGS}") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_CXX_FLAGS}") + ENDIF() + + # IBM Z flags + IF(CMAKE_SYSTEM_PROCESSOR MATCHES "s390x") + IF(RPM MATCHES "(rhel|centos)6" OR RPM MATCHES "(suse|sles)11") + SET(z_flags "-funroll-loops -march=z9-109 -mtune=z10 ") + ELSEIF(RPM MATCHES "(rhel|centos)7" OR RPM MATCHES "(suse|sles)12") + SET(z_flags "-funroll-loops -march=z196 -mtune=zEC12 ") + ELSE() + SET(z_flags "") + ENDIF() + + IF(CMAKE_COMPILER_IS_GNUCC) + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${z_flags}${CMAKE_C_FLAGS_RELWITHDEBINFO}") + ENDIF() + IF(CMAKE_COMPILER_IS_GNUCXX) + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${z_flags}${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") + ENDIF() + UNSET(z_flags) + ENDIF() + + # HPUX flags + IF(CMAKE_SYSTEM_NAME MATCHES "HP-UX") + IF(CMAKE_C_COMPILER_ID MATCHES "HP") + IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ia64") + SET(COMMON_C_FLAGS "+DSitanium2 -mt -AC99") + SET(COMMON_CXX_FLAGS "+DSitanium2 -mt -Aa") + SET(CMAKE_C_FLAGS_DEBUG "+O0 -g ${COMMON_C_FLAGS}") + SET(CMAKE_CXX_FLAGS_DEBUG "+O0 -g ${COMMON_CXX_FLAGS}") + # We have seen compiler bugs with optimisation and -g, so disabled for now + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "+O2 ${COMMON_C_FLAGS}") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "+O2 ${COMMON_CXX_FLAGS}") + ENDIF() + ENDIF() + SET(WITH_SSL no) + ENDIF() + + # Linux flags + IF(CMAKE_SYSTEM_NAME MATCHES "Linux") + IF(CMAKE_C_COMPILER_ID MATCHES "Intel") + SET(COMMON_C_FLAGS "-static-intel -static-libgcc -g -mp -restrict") + SET(COMMON_CXX_FLAGS "-static-intel -static-libgcc -g -mp -restrict -fno-exceptions") + IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ia64") + SET(COMMON_C_FLAGS "${COMMON_C_FLAGS} -no-ftz -no-prefetch") + SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -no-ftz -no-prefetch") + ENDIF() + SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}") + SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}") + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -unroll2 -ip ${COMMON_C_FLAGS}") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -unroll2 -ip ${COMMON_CXX_FLAGS}") + SET(WITH_SSL no) + ENDIF() + ENDIF() + + # Default Clang flags + IF(CMAKE_C_COMPILER_ID MATCHES "Clang") + SET(COMMON_C_FLAGS "-g -fno-omit-frame-pointer -fno-strict-aliasing -Wno-parentheses-equality -Wno-string-plus-int") + SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}") + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_C_FLAGS}") + ENDIF() + IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + SET(COMMON_CXX_FLAGS "-g -fno-omit-frame-pointer -fno-strict-aliasing -Wno-parentheses-equality -Wno-string-plus-int") + SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_CXX_FLAGS}") + ENDIF() + + # Solaris flags + IF(CMAKE_SYSTEM_NAME MATCHES "SunOS") + IF(CMAKE_SYSTEM_VERSION VERSION_GREATER "5.9") + # Link mysqld with mtmalloc on Solaris 10 and later + SET(WITH_MYSQLD_LDFLAGS "-lmtmalloc" CACHE STRING "") + ENDIF() + IF(CMAKE_C_COMPILER_ID MATCHES "SunPro") + IF(CMAKE_SYSTEM_PROCESSOR MATCHES "i386") + SET(COMMON_C_FLAGS "-g -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -xlibmil -xlibmopt -xtarget=generic") + SET(COMMON_CXX_FLAGS "-g0 -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -features=no%except -xlibmil -xlibmopt -xtarget=generic") + SET(CMAKE_C_FLAGS_DEBUG "-xO1 ${COMMON_C_FLAGS}") + SET(CMAKE_CXX_FLAGS_DEBUG "-xO1 ${COMMON_CXX_FLAGS}") + IF(32BIT) + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-xO2 ${COMMON_C_FLAGS}") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO2 ${COMMON_CXX_FLAGS}") + ELSEIF(64BIT) + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_C_FLAGS}") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_CXX_FLAGS}") + ENDIF() + ELSE() + # Assume !x86 is SPARC + SET(COMMON_C_FLAGS "-g -Xa -xstrconst -mt") + SET(COMMON_CXX_FLAGS "-g0 -noex -mt") + IF(32BIT) + SET(COMMON_C_FLAGS "${COMMON_C_FLAGS} -xarch=sparc") + SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -xarch=sparc") + ENDIF() + SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}") + SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}") + SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_C_FLAGS}") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_CXX_FLAGS}") + ENDIF() + ENDIF() + ENDIF() +ENDIF() diff --git a/cmake/build_depends.cmake b/cmake/build_depends.cmake new file mode 100644 index 00000000..5adaee33 --- /dev/null +++ b/cmake/build_depends.cmake @@ -0,0 +1,46 @@ +IF(RPM) + MACRO(FIND_DEP V) + SET(out ${V}_DEP) + IF (NOT DEFINED ${out}) + IF(EXISTS ${${V}} AND NOT IS_DIRECTORY ${${V}}) + EXECUTE_PROCESS(COMMAND ${ARGN} RESULT_VARIABLE res OUTPUT_VARIABLE O OUTPUT_STRIP_TRAILING_WHITESPACE) + ELSE() + SET(res 1) + ENDIF() + IF (res) + SET(O) + ELSE() + MESSAGE(STATUS "Need ${O} for ${${V}}") + ENDIF() + SET(${out} ${O} CACHE INTERNAL "Package that contains ${${V}}" FORCE) + ENDIF() + ENDMACRO() + + # FindBoost.cmake doesn't leave any trace, do it here + IF (Boost_INCLUDE_DIR) + FIND_FILE(Boost_config_hpp boost/config.hpp PATHS ${Boost_INCLUDE_DIR}) + ENDIF() + + GET_CMAKE_PROPERTY(ALL_VARS CACHE_VARIABLES) + FOREACH (V ${ALL_VARS}) + GET_PROPERTY(H CACHE ${V} PROPERTY HELPSTRING) + IF (H MATCHES "^Have library [^/]" AND ${V}) + STRING(REGEX REPLACE "^Have library " "" L ${H}) + SET(V ${L}_LIBRARY) + FIND_LIBRARY(${V} ${L}) + ENDIF() + GET_PROPERTY(T CACHE ${V} PROPERTY TYPE) + IF ((T STREQUAL FILEPATH OR V MATCHES "^CMAKE_COMMAND$") AND ${V} MATCHES "^/") + IF (RPM) + FIND_DEP(${V} rpm -q --qf "%{NAME}" -f ${${V}}) + ELSE() # must be DEB + MESSAGE(FATAL_ERROR "Not implemented") + ENDIF () + SET(BUILD_DEPS ${BUILD_DEPS} ${${V}_DEP}) + ENDIF() + ENDFOREACH() + IF (BUILD_DEPS) + LIST(REMOVE_DUPLICATES BUILD_DEPS) + STRING(REPLACE ";" " " CPACK_RPM_BUILDREQUIRES "${BUILD_DEPS}") + ENDIF() +ENDIF(RPM) diff --git a/cmake/character_sets.cmake b/cmake/character_sets.cmake new file mode 100644 index 00000000..fc6f1d2d --- /dev/null +++ b/cmake/character_sets.cmake @@ -0,0 +1,61 @@ +# Copyright (c) 2009, 2011, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# Charsets and collations +IF(NOT DEFAULT_CHARSET) + SET(DEFAULT_CHARSET "latin1") +ENDIF() + +IF(NOT DEFAULT_COLLATION) + SET(DEFAULT_COLLATION "latin1_swedish_ci") +ENDIF() + +SET(CHARSETS ${DEFAULT_CHARSET} latin1 utf8mb3 utf8mb4) +SET(CHARSETS_COMPLEX + big5 cp1250 cp932 eucjpms euckr gb2312 gbk latin1 latin2 + sjis tis620 ucs2 ujis utf8mb3 utf8mb4 utf16 utf16le utf32) + +SET(CHARSETS_AVAILABLE +binary armscii8 ascii big5 cp1250 cp1251 cp1256 cp1257 +cp850 cp852 cp866 cp932 dec8 eucjpms euckr gb2312 gbk geostd8 +greek hebrew hp8 keybcs2 koi8r koi8u +latin1 latin2 latin5 latin7 macce macroman +sjis swe7 tis620 ucs2 ujis utf8mb3 utf8mb4 utf16 utf16le utf32) + + +SET (EXTRA_CHARSETS "all") +SET(WITH_EXTRA_CHARSETS ${EXTRA_CHARSETS} CACHE + STRING "Options are: none complex all") + + +IF(WITH_EXTRA_CHARSETS MATCHES "complex") + SET(CHARSETS ${CHARSETS} ${CHARSETS_COMPLEX}) +ELSEIF(WITH_EXTRA_CHARSETS MATCHES "all") + SET(CHARSETS ${CHARSETS} ${CHARSETS_AVAILABLE}) +ENDIF() + +SET(MYSQL_DEFAULT_CHARSET_NAME "${DEFAULT_CHARSET}") +SET(MYSQL_DEFAULT_COLLATION_NAME "${DEFAULT_COLLATION}") + +FOREACH(cs in ${CHARSETS}) + SET(HAVE_CHARSET_${cs} 1) +ENDFOREACH() + +SET(HAVE_UCA_COLLATIONS 1) + +SET(HAVE_UTF8_GENERAL_CS 1) +SET(USE_MB 1) +SET(USE_MB_IDENT 1) + diff --git a/cmake/check_compiler_flag.cmake b/cmake/check_compiler_flag.cmake new file mode 100644 index 00000000..3c05c6ba --- /dev/null +++ b/cmake/check_compiler_flag.cmake @@ -0,0 +1,57 @@ +include(CheckCSourceCompiles) +include(CheckCXXSourceCompiles) +# We need some extra FAIL_REGEX patterns +# Note that CHECK_C_SOURCE_COMPILES is a misnomer, it will also link. +SET(fail_patterns + 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 "warning:.*ignored" + FAIL_REGEX "warning:.*is valid for.*but not for" + FAIL_REGEX "warning:.*redefined" + FAIL_REGEX "[Ww]arning: [Oo]ption" + ) +#The regex patterns above are not localized, thus LANG=C +SET(ENV{LANG} C) +MACRO (MY_CHECK_C_COMPILER_FLAG flag) + STRING(REGEX REPLACE "[-,= +]" "_" result "have_C_${flag}") + 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_patterns}) + SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}") +ENDMACRO() + +MACRO (MY_CHECK_CXX_COMPILER_FLAG flag) + STRING(REGEX REPLACE "[-,= +]" "_" result "have_CXX_${flag}") + 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_patterns}) + SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}") +ENDMACRO() + +FUNCTION(MY_CHECK_AND_SET_COMPILER_FLAG flag_to_set) + # At the moment this is gcc-only. + # Let's avoid expensive compiler tests on Windows: + IF(WIN32) + RETURN() + ENDIF() + STRING(REGEX REPLACE "^-Wno-" "-W" flag_to_check ${flag_to_set}) + MY_CHECK_C_COMPILER_FLAG(${flag_to_check}) + MY_CHECK_CXX_COMPILER_FLAG(${flag_to_check}) + STRING(REGEX REPLACE "[-,= +]" "_" result "${flag_to_check}") + FOREACH(lang C CXX) + IF (have_${lang}_${result}) + IF(ARGN) + FOREACH(type ${ARGN}) + SET(CMAKE_${lang}_FLAGS_${type} "${CMAKE_${lang}_FLAGS_${type}} ${flag_to_set}" PARENT_SCOPE) + ENDFOREACH() + ELSE() + SET(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} ${flag_to_set}" PARENT_SCOPE) + ENDIF() + ENDIF() + ENDFOREACH() +ENDFUNCTION() diff --git a/cmake/check_linker_flag.cmake b/cmake/check_linker_flag.cmake new file mode 100644 index 00000000..1ea1772d --- /dev/null +++ b/cmake/check_linker_flag.cmake @@ -0,0 +1,27 @@ +include(CheckCXXSourceCompiles) + +FUNCTION(MY_CHECK_AND_SET_LINKER_FLAG flag_to_set) + # Let's avoid expensive compiler tests on Windows: + IF(WIN32) + RETURN() + ENDIF() + STRING(REGEX REPLACE "[-,= +]" "_" result "HAVE_LINK_FLAG_${flag_to_set}") + SET(SAVE_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") + STRING(REGEX REPLACE "^-Wno-" "-W" flag_to_check ${flag_to_set}) + SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${flag_to_check}) + CHECK_CXX_SOURCE_COMPILES("int main(void) { return 0; }" ${result}) + SET(CMAKE_REQUIRED_LIBRARIES "${SAVE_CMAKE_REQUIRED_LIBRARIES}") + IF (${result}) + FOREACH(linktype SHARED MODULE EXE) + IF(ARGN) + FOREACH(type ${ARGN}) + SET(CMAKE_${linktype}_LINKER_FLAGS_${type} + "${CMAKE_${linktype}_LINKER_FLAGS_${type}} ${flag_to_set}" PARENT_SCOPE) + ENDFOREACH() + ELSE() + SET(CMAKE_${linktype}_LINKER_FLAGS + "${CMAKE_${linktype}_LINKER_FLAGS} ${flag_to_set}" PARENT_SCOPE) + ENDIF() + ENDFOREACH() + ENDIF() +ENDFUNCTION() diff --git a/cmake/compile_flags.cmake b/cmake/compile_flags.cmake new file mode 100644 index 00000000..a87846e9 --- /dev/null +++ b/cmake/compile_flags.cmake @@ -0,0 +1,44 @@ +# Copyright (c) 2014, 2015, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + + +## ADD_COMPILE_FLAGS(<source files> COMPILE_FLAGS <flags>) +MACRO(ADD_COMPILE_FLAGS) + SET(FILES "") + SET(FLAGS "") + SET(COMPILE_FLAGS_SEEN) + FOREACH(ARG ${ARGV}) + IF(ARG STREQUAL "COMPILE_FLAGS") + SET(COMPILE_FLAGS_SEEN 1) + ELSEIF(COMPILE_FLAGS_SEEN) + LIST(APPEND FLAGS ${ARG}) + ELSE() + LIST(APPEND FILES ${ARG}) + ENDIF() + ENDFOREACH() + FOREACH(FILE ${FILES}) + FOREACH(FLAG ${FLAGS}) + GET_SOURCE_FILE_PROPERTY(PROP ${FILE} COMPILE_FLAGS) + IF(NOT PROP) + SET(PROP ${FLAG}) + ELSE() + SET(PROP "${PROP} ${FLAG}") + ENDIF() + SET_SOURCE_FILES_PROPERTIES( + ${FILE} PROPERTIES COMPILE_FLAGS "${PROP}" + ) + ENDFOREACH() + ENDFOREACH() +ENDMACRO() diff --git a/cmake/configurable_file_content.in b/cmake/configurable_file_content.in new file mode 100644 index 00000000..df2c382e --- /dev/null +++ b/cmake/configurable_file_content.in @@ -0,0 +1 @@ +@CMAKE_CONFIGURABLE_FILE_CONTENT@ diff --git a/cmake/configure.pl b/cmake/configure.pl new file mode 100644 index 00000000..4085110b --- /dev/null +++ b/cmake/configure.pl @@ -0,0 +1,310 @@ +#!/usr/bin/env perl + +# Copyright (c) 2009, 2012, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +use strict; +use Cwd 'abs_path'; +use File::Basename; + +my $cmakeargs = ""; + +# Find source root directory +# Assume this script is in <srcroot>/cmake +my $srcdir = dirname(dirname(abs_path($0))); +my $cmake_install_prefix=""; +my $just_print= 0; + +# Sets installation directory, bindir, libdir, libexecdir etc +# the equivalent CMake variables are given without prefix +# e.g if --prefix is /usr and --bindir is /usr/bin +# then cmake variable (INSTALL_BINDIR) must be just "bin" + +sub set_installdir +{ + my($path, $varname) = @_; + my $prefix_length = length($cmake_install_prefix); + if (($prefix_length > 0) && (index($path,$cmake_install_prefix) == 0)) + { + # path is under the prefix, so remove the prefix and maybe following "/" + $path = substr($path, $prefix_length); + if(length($path) > 0) + { + my $char = substr($path, 0, 1); + if($char eq "/") + { + $path= substr($path, 1); + } + } + if(length($path) > 0) + { + $cmakeargs = $cmakeargs." -D".$varname."=".$path; + } + } +} + +# CMake understands CC and CXX env.variables correctly, if they contain 1 or 2 tokens +# e.g CXX=gcc and CXX="ccache gcc" are ok. However it could have a problem if there +# (recognizing gcc) with more tokens ,e.g CXX="ccache gcc --pipe". +# The problem is simply fixed by splitting compiler and flags, e.g +# CXX="ccache gcc --pipe" => CXX=ccache gcc CXXFLAGS=--pipe + +sub check_compiler +{ + my ($varname, $flagsvarname) = @_; + my @tokens = split(/ /,$ENV{$varname}); + if($#tokens >= 2) + { + $ENV{$varname} = $tokens[0]." ".$tokens[1]; + my $flags; + + for(my $i=2; $i<=$#tokens; $i++) + { + $flags= $flags." ".$tokens[$i]; + } + if(defined $ENV{$flagsvarname}) + { + $flags = $flags." ".$ENV{$flagsvarname}; + } + $ENV{$flagsvarname}=$flags; + print("$varname=$ENV{$varname}\n"); + print("$flagsvarname=$ENV{$flagsvarname}\n"); + } +} + +check_compiler("CC", "CFLAGS"); +check_compiler("CXX", "CXXFLAGS"); + +foreach my $option (@ARGV) +{ + if (substr ($option, 0, 2) eq "--") + { + $option = substr($option, 2); + } + elsif (substr ($option, 0, 2) eq "-D") + { + # Must be cmake config option + $option = substr($option, 1); + } + else + { + # This must be environment variable + my @v = split('=', $option); + my $name = shift(@v); + if(@v) + { + $ENV{$name} = join('=', @v); + } + next; + } + if($option =~ /srcdir/) + { + $srcdir = substr($option,7); + next; + } + if($option =~ /help/) + { + system("cmake ${srcdir} -LH"); + exit(0); + } + if ($option =~ /print/) + { + $just_print=1; + next; + } + if ($option =~ /D.*=/) + { + $cmakeargs = $cmakeargs." -".$option; + next; + } + if($option =~ /with-plugins=/) + { + my @plugins= split(/,/, substr($option,13)); + foreach my $p (@plugins) + { + $p =~ s/-/_/g; + $cmakeargs = $cmakeargs." -DWITH_".uc($p)."=AUTO"; + } + next; + } + if($option =~ /with-extra-charsets=/) + { + my $charsets= substr($option,20); + $cmakeargs = $cmakeargs." -DWITH_EXTRA_CHARSETS=".$charsets; + next; + } + if($option =~ /without-plugin=/ || $option =~ /without-plugin-/) + { + $cmakeargs = $cmakeargs." -DPLUGIN_".uc(substr($option,15))."=NO"; + next; + } + if($option =~ /with-plugin-(.*)=(.*)/) + { + $cmakeargs = $cmakeargs." -DPLUGIN_".uc($1)."=".uc($2); + next; + } + if($option =~ /without-wsrep/) + { + $cmakeargs = $cmakeargs." -DWITH_WSREP=OFF"; + next; + } + if($option =~ /with-zlib-dir=bundled/) + { + $cmakeargs = $cmakeargs." -DWITH_ZLIB=bundled"; + next; + } + if($option =~ /with-zlib-dir=/) + { + $cmakeargs = $cmakeargs." -DWITH_ZLIB=system"; + next; + } + if($option =~ /with-libevent=/) + { + $cmakeargs = $cmakeargs." -DWITH_LIBEVENT=system"; + next; + } + if($option =~ /with-libevent/) + { + $cmakeargs = $cmakeargs." -DWITH_LIBEVENT=bundled"; + next; + } + if($option =~ /with-ssl=yes/) + { + $cmakeargs = $cmakeargs." -DWITH_SSL=yes"; + next; + } + if($option =~ /with-ssl=system/) + { + $cmakeargs = $cmakeargs." -DWITH_SSL=system"; + next; + } + if($option =~ /with-ssl$/) + { + $cmakeargs = $cmakeargs." -DWITH_SSL=bundled"; + next; + } + if($option =~ /with-debug/) + { + $cmakeargs = $cmakeargs." -DCMAKE_BUILD_TYPE=Debug -DSECURITY_HARDENED=OFF"; + next; + } + if($option =~ /with-(.*)=(.*)/) + { + $cmakeargs = $cmakeargs. " -DWITH_" . uc($1) . "=" . uc($2); + next; + } + if($option =~ /without-(.*)=(.*)/) + { + $cmakeargs = $cmakeargs. " -DWITHOUT_" . uc($1) . "=" . uc($2); + next; + } + if($option =~ /prefix=/) + { + $cmake_install_prefix= substr($option, 7); + $cmakeargs = $cmakeargs." -DCMAKE_INSTALL_PREFIX=".$cmake_install_prefix; + next; + } + if($option =~/bindir=/) + { + set_installdir(substr($option,7), "INSTALL_BINDIR"); + next; + } + if($option =~/libdir=/) + { + set_installdir(substr($option,7), "INSTALL_LIBDIR"); + next; + } + if($option =~/libexecdir=/) + { + set_installdir(substr($option,11), "INSTALL_SBINDIR"); + next; + } + if($option =~/includedir=/) + { + set_installdir(substr($option,11), "INSTALL_INCLUDEDIR"); + next; + } + if ($option =~ /extra-charsets=all/) + { + $cmakeargs = $cmakeargs." -DWITH_CHARSETS=all"; + next; + } + if ($option =~ /extra-charsets=complex/) + { + $cmakeargs = $cmakeargs." -DWITH_CHARSETS=complex"; + next; + } + if ($option =~ /localstatedir=/) + { + $cmakeargs = $cmakeargs." -DMYSQL_DATADIR=".substr($option,14); + next; + } + if ($option =~ /mysql-maintainer-mode/) + { + $cmakeargs = $cmakeargs." -DMYSQL_MAINTAINER_MODE=" . + ($option =~ /enable/ ? "1" : "0"); + next; + } + if ($option =~ /with-comment=/) + { + $cmakeargs = $cmakeargs." \"-DWITH_COMMENT=".substr($option,13)."\""; + next; + } + if ($option =~ /with-gcov/) + { + $cmakeargs = $cmakeargs." -DENABLE_GCOV=ON"; + next; + } + if ($option =~ /with-max-indexes=/) + { + $cmakeargs = $cmakeargs." -DMAX_INDEXES=".substr($option, 17); + next; + } + if ($option =~ /verbose/) + { + $cmakeargs = $cmakeargs." -DCMAKE_VERBOSE_MAKEFILE=1"; + next; + } + if ($option =~ /with-client-ldflags/) + { + print("configure.pl : ignoring $option\n"); + next; + } + if ($option =~ /with-mysqld-ldflags=/) + { + print("configure.pl : ignoring $option\n"); + next; + } + if ($option =~ /with-client-ldflags/) + { + print("configure.pl : ignoring $option\n"); + next; + } + if ($option =~ /with-mysqld-ldflags=/) + { + print("configure.pl : ignoring $option\n"); + next; + } + + $option = uc($option); + $option =~ s/-/_/g; + $cmakeargs = $cmakeargs." -D".$option."=1"; +} + +print("configure.pl : calling cmake $srcdir $cmakeargs\n"); +exit(0) if ($just_print); +unlink("CMakeCache.txt"); +my $rc = system("cmake $srcdir $cmakeargs"); +exit($rc); diff --git a/cmake/cpack_deb.cmake b/cmake/cpack_deb.cmake new file mode 100644 index 00000000..b253f8f8 --- /dev/null +++ b/cmake/cpack_deb.cmake @@ -0,0 +1,24 @@ +# +# One day it'll be a complete solution for building deb packages with CPack +# But for now it's only to make INSTALL_DOCUMENTATION function happy +# +IF(DEB) +SET(CPACK_COMPONENT_SERVER_GROUP "server") +SET(CPACK_COMPONENT_README_GROUP "server") +SET(CPACK_COMPONENTS_ALL Server Test SharedLibraries) +SET(PYTHON_SHEBANG "/usr/bin/python3" CACHE STRING "python shebang") + +FUNCTION(SET_PLUGIN_DEB_VERSION plugin ver) + STRING(REPLACE "_" "-" plugin ${plugin}) + STRING(REPLACE "-" "." serverver ${SERVER_VERSION}) + STRING(REPLACE ${SERVER_VERSION} ${serverver} ver ${ver}) + FILE(READ ${CMAKE_SOURCE_DIR}/debian/changelog changelog) + STRING(REPLACE ${serverver} ${ver} changelog "${changelog}") + FILE(WRITE ${CMAKE_SOURCE_DIR}/debian/mariadb-plugin-${plugin}.changelog "${changelog}") +ENDFUNCTION() + +ELSE(DEB) +FUNCTION(SET_PLUGIN_DEB_VERSION plugin ver) +ENDFUNCTION() +ENDIF(DEB) + diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake new file mode 100644 index 00000000..60470779 --- /dev/null +++ b/cmake/cpack_rpm.cmake @@ -0,0 +1,321 @@ +IF(RPM) + +SET(CPACK_GENERATOR "RPM") +SET(CPACK_RPM_PACKAGE_DEBUG 1) +SET(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7) + +SET(CPACK_RPM_COMPONENT_INSTALL ON) + +SET(CPACK_COMPONENT_SERVER_GROUP "server") +SET(CPACK_COMPONENT_MANPAGESSERVER_GROUP "server") +SET(CPACK_COMPONENT_INIFILES_GROUP "server") +SET(CPACK_COMPONENT_SERVER_SCRIPTS_GROUP "server") +SET(CPACK_COMPONENT_SUPPORTFILES_GROUP "server") +SET(CPACK_COMPONENT_DEVELOPMENT_GROUP "devel") +SET(CPACK_COMPONENT_MANPAGESDEVELOPMENT_GROUP "devel") +SET(CPACK_COMPONENT_TEST_GROUP "test") +SET(CPACK_COMPONENT_MANPAGESTEST_GROUP "test") +SET(CPACK_COMPONENT_CLIENT_GROUP "client") +SET(CPACK_COMPONENT_MANPAGESCLIENT_GROUP "client") +SET(CPACK_COMPONENT_README_GROUP "server") +SET(CPACK_COMPONENT_SHAREDLIBRARIES_GROUP "shared") +SET(CPACK_COMPONENT_COMMON_GROUP "common") +SET(CPACK_COMPONENT_CLIENTPLUGINS_GROUP "common") +SET(CPACK_COMPONENT_COMPAT_GROUP "compat") +SET(CPACK_COMPONENT_BACKUP_GROUP "backup") + +SET(CPACK_COMPONENTS_ALL Server ManPagesServer IniFiles Server_Scripts + SupportFiles Development ManPagesDevelopment + ManPagesTest Readme ManPagesClient Test + Common Client SharedLibraries ClientPlugins + backup +) + +SET(CPACK_RPM_PACKAGE_NAME ${CPACK_PACKAGE_NAME}) +SET(CPACK_RPM_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) +IF(CMAKE_VERSION VERSION_LESS "3.6.0") + SET(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}-${RPM}-${CMAKE_SYSTEM_PROCESSOR}") +ELSE() + SET(CPACK_RPM_FILE_NAME "RPM-DEFAULT") + OPTION(CPACK_RPM_DEBUGINFO_PACKAGE "" ON) + MARK_AS_ADVANCED(CPACK_RPM_DEBUGINFO_PACKAGE) + SET(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX "/usr/src/debug/${CPACK_RPM_PACKAGE_NAME}-${CPACK_RPM_PACKAGE_VERSION}") +ENDIF() + +SET(CPACK_RPM_PACKAGE_RELEASE "1%{?dist}") +SET(CPACK_RPM_PACKAGE_LICENSE "GPLv2") +SET(CPACK_RPM_PACKAGE_RELOCATABLE FALSE) +SET(CPACK_PACKAGE_RELOCATABLE FALSE) +SET(CPACK_RPM_PACKAGE_GROUP "Applications/Databases") +SET(CPACK_RPM_PACKAGE_URL ${CPACK_PACKAGE_URL}) +SET(CPACK_RPM_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION}") + +SET(CPACK_RPM_shared_PACKAGE_VENDOR "MariaDB Corporation Ab") +SET(CPACK_RPM_shared_PACKAGE_LICENSE "LGPLv2.1") +SET(CPACK_RPM_shared_PACKAGE_SUMMARY "LGPL MariaDB client library") +SET(CPACK_RPM_shared_PACKAGE_DESCRIPTION " +This is LGPL MariaDB client library that can be used to connect to MySQL +or MariaDB. + +This code is based on the LGPL libmysql client library from MySQL 3.23 +and PHP's mysqlnd extension. + +This product includes PHP software, freely available from +<http://www.php.net/software/> +") + +SET(CPACK_RPM_SPEC_MORE_DEFINE " +%define mysql_vendor ${CPACK_PACKAGE_VENDOR} +%define mysqlversion ${MYSQL_NO_DASH_VERSION} +%define mysqlbasedir ${CMAKE_INSTALL_PREFIX} +%define mysqldatadir ${INSTALL_MYSQLDATADIR} +%define mysqld_user mysql +%define mysqld_group mysql +%define _bindir ${INSTALL_BINDIRABS} +%define _sbindir ${INSTALL_SBINDIRABS} +%define _sysconfdir ${INSTALL_SYSCONFDIR} +%define restart_flag_dir %{_localstatedir}/lib/rpm-state/mariadb +%define restart_flag %{restart_flag_dir}/need-restart + +%{?filter_setup: +%filter_provides_in \\\\.\\\\(test\\\\|result\\\\|h\\\\|cc\\\\|c\\\\|inc\\\\|opt\\\\|ic\\\\|cnf\\\\|rdiff\\\\|cpp\\\\)$ +%filter_requires_in \\\\.\\\\(test\\\\|result\\\\|h\\\\|cc\\\\|c\\\\|inc\\\\|opt\\\\|ic\\\\|cnf\\\\|rdiff\\\\|cpp\\\\)$ +%filter_from_provides /perl(\\\\(mtr\\\\|My::\\\\)/d +%filter_from_requires /\\\\(lib\\\\(ft\\\\|lzma\\\\|tokuportability\\\\)\\\\)\\\\|\\\\(perl(\\\\(.*mtr\\\\|My::\\\\|.*HandlerSocket\\\\|Mysql\\\\)\\\\)/d +%filter_setup +} +") + +# this creative hack is described here: http://www.cmake.org/pipermail/cmake/2012-January/048416.html +# both /etc and /etc/init.d should be ignored as of 2.8.7 +# only /etc/init.d as of 2.8.8 +# and eventually this hack should go away completely +SET(CPACK_RPM_SPEC_MORE_DEFINE "${CPACK_RPM_SPEC_MORE_DEFINE} +%define ignore \# +") + +SET(CPACK_RPM_PACKAGE_REQUIRES "MariaDB-common") + +SET(ignored + "%ignore /etc" + "%ignore /etc/init.d" + "%ignore /etc/logrotate.d" + "%ignore /etc/security" + "%ignore /etc/systemd" + "%ignore /etc/systemd/system" + "%ignore /lib" + "%ignore /lib/security" + "%ignore /lib64" + "%ignore /lib64/security" + "%ignore ${CMAKE_INSTALL_PREFIX}" + "%ignore ${CMAKE_INSTALL_PREFIX}/bin" + "%ignore ${CMAKE_INSTALL_PREFIX}/include" + "%ignore ${CMAKE_INSTALL_PREFIX}/lib" + "%ignore ${CMAKE_INSTALL_PREFIX}/lib/systemd" + "%ignore ${CMAKE_INSTALL_PREFIX}/lib/systemd/system" + "%ignore ${CMAKE_INSTALL_PREFIX}/lib/tmpfiles.d" + "%ignore ${CMAKE_INSTALL_PREFIX}/lib/sysusers.d" + "%ignore ${CMAKE_INSTALL_PREFIX}/lib64" + "%ignore ${CMAKE_INSTALL_PREFIX}/lib64/pkgconfig" + "%ignore ${CMAKE_INSTALL_PREFIX}/sbin" + "%ignore ${CMAKE_INSTALL_PREFIX}/share" + "%ignore ${CMAKE_INSTALL_PREFIX}/share/aclocal" + "%ignore ${CMAKE_INSTALL_PREFIX}/share/doc" + "%ignore ${CMAKE_INSTALL_PREFIX}/share/man" + "%ignore ${CMAKE_INSTALL_PREFIX}/share/man/man1" + "%ignore ${CMAKE_INSTALL_PREFIX}/share/man/man8" + "%ignore ${CMAKE_INSTALL_PREFIX}/share/pkgconfig" + ) + +SET(CPACK_RPM_server_USER_FILELIST + ${ignored} + "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*" + "%config(noreplace) ${INSTALL_SYSCONFDIR}/logrotate.d/mysql" + ) +SET(CPACK_RPM_common_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONFDIR}/my.cnf") +SET(CPACK_RPM_shared_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*") +SET(CPACK_RPM_client_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*") +SET(CPACK_RPM_compat_USER_FILELIST ${ignored}) +SET(CPACK_RPM_devel_USER_FILELIST ${ignored}) +SET(CPACK_RPM_test_USER_FILELIST ${ignored}) +SET(CPACK_RPM_backup_USER_FILELIST ${ignored}) + +# "set/append array" - append a set of strings, separated by a space +MACRO(SETA var) + FOREACH(v ${ARGN}) + SET(${var} "${${var}} ${v}") + ENDFOREACH() +ENDMACRO(SETA) + +SETA(CPACK_RPM_client_PACKAGE_OBSOLETES + "mysql-client" + "MySQL-client") +SETA(CPACK_RPM_client_PACKAGE_PROVIDES + "MySQL-client" + "mysql-client") + +SETA(CPACK_RPM_devel_PACKAGE_OBSOLETES + "MySQL-devel") +SETA(CPACK_RPM_devel_PACKAGE_PROVIDES + "MySQL-devel") + +SETA(CPACK_RPM_server_PACKAGE_OBSOLETES + "MariaDB" + "MySQL" + "mysql-server" + "MySQL-server" + "MariaDB-Galera-server") +SETA(CPACK_RPM_server_PACKAGE_PROVIDES + "MariaDB" + "MySQL" + "MySQL-server" + "msqlormysql" + "mysql-server") + +SETA(CPACK_RPM_test_PACKAGE_OBSOLETES + "MySQL-test") +SETA(CPACK_RPM_test_PACKAGE_PROVIDES + "MySQL-test") + +SETA(CPACK_RPM_server_PACKAGE_REQUIRES + "${CPACK_RPM_PACKAGE_REQUIRES}" + "MariaDB-client") + +IF(WITH_WSREP) + SETA(CPACK_RPM_server_PACKAGE_REQUIRES + "galera-4" "rsync" "lsof" "grep" "gawk" "iproute" + "coreutils" "findutils" "tar") +ENDIF() + +SET(CPACK_RPM_server_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-prein.sh) +SET(CPACK_RPM_server_PRE_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-preun.sh) +SET(CPACK_RPM_server_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-postin.sh) +SET(CPACK_RPM_server_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-postun.sh) +SET(CPACK_RPM_server_POST_TRANS_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-posttrans.sh) +SET(CPACK_RPM_shared_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/shared-post.sh) +SET(CPACK_RPM_shared_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/shared-post.sh) +SET(CPACK_RPM_compat_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/shared-post.sh) +SET(CPACK_RPM_compat_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/shared-post.sh) + +MACRO(ALTERNATIVE_NAME real alt) + IF(${ARGC} GREATER 2) + SET(ver ${ARGV2}) + ELSE() + SET(ver "${epoch}%{version}-%{release}") + ENDIF() + + SET(p "CPACK_RPM_${real}_PACKAGE_PROVIDES") + SET(${p} "${${p}} ${alt} = ${ver} ${alt}%{?_isa} = ${ver} config(${alt}) = ${ver}") + SET(o "CPACK_RPM_${real}_PACKAGE_OBSOLETES") + SET(${o} "${${o}} ${alt}") +ENDMACRO(ALTERNATIVE_NAME) + +ALTERNATIVE_NAME("devel" "mysql-devel") +ALTERNATIVE_NAME("server" "mysql-server") +ALTERNATIVE_NAME("test" "mysql-test") + +# Argh! Different distributions call packages differently, to be a drop-in +# replacement we have to fake distribution-specific dependencies +# NOTE, use ALTERNATIVE_NAME when a package has a different name +# in some distribution, it's not for adding new PROVIDES + +IF(RPM MATCHES "(rhel|centos)6") + ALTERNATIVE_NAME("client" "mysql") +ELSEIF(RPM MATCHES "fedora" OR RPM MATCHES "(rhel|centos)7") + SET(epoch 1:) # this is fedora + ALTERNATIVE_NAME("client" "mariadb") + ALTERNATIVE_NAME("client" "mysql") + ALTERNATIVE_NAME("devel" "mariadb-devel") + ALTERNATIVE_NAME("server" "mariadb-server") + ALTERNATIVE_NAME("server" "mysql-compat-server") + ALTERNATIVE_NAME("test" "mariadb-test") +ELSEIF(RPM MATCHES "(rhel|centos)8") + SET(epoch 3:) + ALTERNATIVE_NAME("backup" "mariadb-backup") + ALTERNATIVE_NAME("client" "mariadb") + ALTERNATIVE_NAME("common" "mariadb-common") + ALTERNATIVE_NAME("common" "mariadb-errmsg") + ALTERNATIVE_NAME("server" "mariadb-server") + ALTERNATIVE_NAME("server" "mariadb-server-utils") + ALTERNATIVE_NAME("shared" "mariadb-connector-c" ${MARIADB_CONNECTOR_C_VERSION}-1) + ALTERNATIVE_NAME("shared" "mariadb-connector-c-config" ${MARIADB_CONNECTOR_C_VERSION}-1) + SETA(CPACK_RPM_client_PACKAGE_PROVIDES "mariadb-galera = 3:%{version}-%{release}") + SETA(CPACK_RPM_common_PACKAGE_PROVIDES "mariadb-galera-common = 3:%{version}-%{release}") + SETA(CPACK_RPM_common_PACKAGE_REQUIRES "MariaDB-shared") +ELSEIF(RPM MATCHES "sles") + ALTERNATIVE_NAME("server" "mariadb") + SETA(CPACK_RPM_server_PACKAGE_PROVIDES + "mysql = %{version}-%{release}" + "mariadb_${MAJOR_VERSION}${MINOR_VERSION} = %{version}-%{release}" + "mariadb-${MAJOR_VERSION}${MINOR_VERSION} = %{version}-%{release}" + "mariadb-server = %{version}-%{release}" + ) +ENDIF() +SET(PYTHON_SHEBANG "/usr/bin/python3" CACHE STRING "python shebang") + +# If we want to build build MariaDB-shared-compat, +# extract compat libraries from MariaDB-shared-5.3 rpm +FILE(GLOB compat53 RELATIVE ${CMAKE_SOURCE_DIR} + "${CMAKE_SOURCE_DIR}/../MariaDB-shared-5.3.*.rpm") +FILE(GLOB compat101 RELATIVE ${CMAKE_SOURCE_DIR} + "${CMAKE_SOURCE_DIR}/../MariaDB-shared-10.1.*.rpm") +IF(compat53 AND compat101) + FOREACH(compat_rpm "${compat53}" "${compat101}") + MESSAGE("Using ${compat_rpm} to build MariaDB-compat") + INSTALL(CODE "EXECUTE_PROCESS( + COMMAND rpm2cpio ${CMAKE_SOURCE_DIR}/${compat_rpm} + COMMAND cpio --extract --make-directories */libmysqlclient*.so.* - + WORKING_DIRECTORY \$ENV{DESTDIR}) + EXECUTE_PROCESS( + COMMAND chmod -R a+rX . + WORKING_DIRECTORY \$ENV{DESTDIR})" + COMPONENT Compat) + ENDFOREACH() + + EXECUTE_PROCESS( + COMMAND rpm -q --provides -p "${CMAKE_SOURCE_DIR}/${compat101}" + ERROR_QUIET + OUTPUT_VARIABLE compat_provides) + EXECUTE_PROCESS( + COMMAND rpm -q --obsoletes -p "${CMAKE_SOURCE_DIR}/${compat101}" + ERROR_QUIET + OUTPUT_VARIABLE compat_obsoletes) + + STRING(REPLACE "\n" " " compat_provides "${compat_provides}") + STRING(REPLACE "\n" " " compat_obsoletes "${compat_obsoletes}") + STRING(REGEX REPLACE "[^ ]+\\([^ ]+ *" "" compat_obsoletes "${compat_obsoletes}") + SETA(CPACK_RPM_compat_PACKAGE_PROVIDES "${compat_provides}") + SETA(CPACK_RPM_compat_PACKAGE_OBSOLETES "${compat_obsoletes}") + + SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} Compat) + + # RHEL6/CentOS6 install Postfix by default, and it requires + # libmysqlclient.so.16 that pulls in mysql-libs-5.1.x + # And the latter conflicts with our rpms. + # Make sure that for these distribuions all our rpms require + # MariaDB-compat, that will replace mysql-libs-5.1 + IF(RPM MATCHES "(rhel|centos)[67]") + SET(CPACK_RPM_common_PACKAGE_REQUIRES "MariaDB-compat") + SET(CPACK_RPM_compat_PACKAGE_CONFLICTS "mariadb-libs < 1:10.1.0") + ENDIF() +ENDIF() + +################ +IF(CMAKE_VERSION VERSION_GREATER "3.9.99") + +SET(CPACK_SOURCE_GENERATOR "RPM") +SETA(CPACK_RPM_SOURCE_PKG_BUILD_PARAMS "-DRPM=${RPM}") + +MACRO(ADDIF var) + IF(DEFINED ${var}) + SETA(CPACK_RPM_SOURCE_PKG_BUILD_PARAMS "-D${var}=${${var}}") + ENDIF() +ENDMACRO() + +ADDIF(CMAKE_BUILD_TYPE) +ADDIF(BUILD_CONFIG) +ADDIF(WITH_SSL) + +ENDIF() +ENDIF(RPM) diff --git a/cmake/cpack_source_ignore_files.cmake b/cmake/cpack_source_ignore_files.cmake new file mode 100644 index 00000000..eb1ec191 --- /dev/null +++ b/cmake/cpack_source_ignore_files.cmake @@ -0,0 +1,56 @@ +# Copyright (c) 2009, 2014, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +SET(CPACK_SOURCE_IGNORE_FILES +\\\\.git/ +\\\\.git$ +\\\\.gitignore$ +\\\\.gitattributes$ +CMakeCache\\\\.txt$ +cmake_dist\\\\.cmake$ +CPackSourceConfig\\\\.cmake$ +CPackConfig.cmake$ +/cmake_install\\\\.cmake$ +/CTestTestfile\\\\.cmake$ +/CMakeFiles/ +/version_resources/ +/_CPack_Packages/ +\\\\.gz$ +\\\\.zip$ +/CMakeFiles/ +/version_resources/ +/_CPack_Packages/ +scripts/make_binary_distribution$ +scripts/msql2mysql$ +scripts/mysql_config$ +scripts/mysql_convert_table_format$ +scripts/mysql_find_rows$ +scripts/mysql_fix_extensions$ +scripts/mysql_install_db$ +scripts/mysql_secure_installation$ +scripts/mysql_setpermission$ +scripts/mysqlaccess$ +scripts/mysqld_multi$ +scripts/mysqld_safe$ +scripts/mysqldumpslow$ +scripts/mysqlhotcopy$ +Makefile$ +include/config\\\\.h$ +include/my_config\\\\.h$ +/autom4te\\\\.cache/ +errmsg\\\\.sys$ +\\\\.rpm$ +# +) diff --git a/cmake/cpu_info.cmake b/cmake/cpu_info.cmake new file mode 100644 index 00000000..2abeb5e1 --- /dev/null +++ b/cmake/cpu_info.cmake @@ -0,0 +1,43 @@ +# Copyright (c) 2009, 2011, 2012 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# Symbols with information about the CPU. + +IF(NOT DEFINED CPU_LEVEL1_DCACHE_LINESIZE) + +IF(CMAKE_SYSTEM_NAME MATCHES "Darwin") + FIND_PROGRAM(SYSCTL sysctl) + MARK_AS_ADVANCED(SYSCTL) + + IF(SYSCTL) + EXECUTE_PROCESS( + COMMAND ${SYSCTL} -n hw.cachelinesize + OUTPUT_VARIABLE CPU_LEVEL1_DCACHE_LINESIZE + ) + ENDIF() + +ELSE() + FIND_PROGRAM(GETCONF getconf) + MARK_AS_ADVANCED(GETCONF) + + IF(GETCONF) + EXECUTE_PROCESS( + COMMAND ${GETCONF} LEVEL1_DCACHE_LINESIZE + OUTPUT_VARIABLE CPU_LEVEL1_DCACHE_LINESIZE + ) + ENDIF() +ENDIF() + +ENDIF() diff --git a/cmake/create_initial_db.cmake b/cmake/create_initial_db.cmake new file mode 100644 index 00000000..c7868159 --- /dev/null +++ b/cmake/create_initial_db.cmake @@ -0,0 +1,69 @@ +# Copyright (c) 2009, 2012, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# This script creates initial database for packaging on Windows +# Force Visual Studio to output to stdout +IF(ENV{VS_UNICODE_OUTPUT}) + SET ($ENV{VS_UNICODE_OUTPUT}) +ENDIF() +IF(CMAKE_CFG_INTDIR AND CONFIG) + #Resolve build configuration variables + STRING(REPLACE "${CMAKE_CFG_INTDIR}" ${CONFIG} MYSQLD_EXECUTABLE + "${MYSQLD_EXECUTABLE}") +ENDIF() + +# Create bootstrapper SQL script +FILE(WRITE bootstrap.sql "use mysql;\n" ) +FOREACH(FILENAME mysql_system_tables.sql mysql_system_tables_data.sql mysql_performance_tables.sql) + FILE(STRINGS ${TOP_SRCDIR}/scripts/${FILENAME} CONTENTS) + FOREACH(STR ${CONTENTS}) + IF(NOT STR MATCHES "@current_hostname") + FILE(APPEND bootstrap.sql "${STR}\n") + ENDIF() + ENDFOREACH() +ENDFOREACH() +FILE(READ ${TOP_SRCDIR}/scripts/fill_help_tables.sql CONTENTS) +FILE(APPEND bootstrap.sql "${CONTENTS}") + + +MAKE_DIRECTORY(mysql) + +SET(BOOTSTRAP_COMMAND + ${MYSQLD_EXECUTABLE} + --no-defaults + --console + --bootstrap + --datadir=. +) + +GET_FILENAME_COMPONENT(CWD . ABSOLUTE) +EXECUTE_PROCESS( + COMMAND "${CMAKE_COMMAND}" -E echo Executing ${BOOTSTRAP_COMMAND} +) +EXECUTE_PROCESS ( + COMMAND "${CMAKE_COMMAND}" -E + echo input file bootstrap.sql, current directory ${CWD} +) +EXECUTE_PROCESS ( + COMMAND ${BOOTSTRAP_COMMAND} + INPUT_FILE bootstrap.sql + OUTPUT_VARIABLE OUT + ERROR_VARIABLE ERR + RESULT_VARIABLE RESULT + ) + +IF(NOT RESULT EQUAL 0) + MESSAGE(FATAL_ERROR "Could not create initial database \n ${OUT} \n ${ERR}") +ENDIF() diff --git a/cmake/ctest.cmake b/cmake/ctest.cmake new file mode 100644 index 00000000..5bc1ce5f --- /dev/null +++ b/cmake/ctest.cmake @@ -0,0 +1,24 @@ + +INCLUDE(CMakeParseArguments) + +MACRO(MY_ADD_TEST name) + ADD_TEST(${name} ${name}-t) +ENDMACRO() + +MACRO(MY_ADD_TESTS) + CMAKE_PARSE_ARGUMENTS(ARG "" "EXT" "LINK_LIBRARIES" ${ARGN}) + + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/unittest/mytap) + + IF (NOT ARG_EXT) + SET(ARG_EXT "c") + ENDIF() + + FOREACH(name ${ARG_UNPARSED_ARGUMENTS}) + ADD_EXECUTABLE(${name}-t "${name}-t.${ARG_EXT}") + TARGET_LINK_LIBRARIES(${name}-t mytap ${ARG_LINK_LIBRARIES}) + MY_ADD_TEST(${name}) + ENDFOREACH() +ENDMACRO() + diff --git a/cmake/do_abi_check.cmake b/cmake/do_abi_check.cmake new file mode 100644 index 00000000..02bf9fbe --- /dev/null +++ b/cmake/do_abi_check.cmake @@ -0,0 +1,89 @@ +# Copyright (c) 2009, 2010, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# +# Rules for checking that the abi/api has not changed. +# +# The following steps are followed in the do_abi_check rule below +# +# 1) Generate preprocessor output for the files that need to +# be tested for abi/api changes. use -nostdinc to prevent +# generation of preprocessor output for system headers. This +# results in messages in stderr saying that these headers +# were not found. Redirect the stderr output to /dev/null +# to prevent seeing these messages. +# 2) sed the output to +# 2.1) remove blank lines and lines that begin with "# " +# 2.2) When gcc -E is run on the Mac OS and solaris sparc platforms it +# introduces a line of output that shows up as a difference between +# the .pp and .out files. Remove these OS specific preprocessor text +# inserted by the preprocessor. +# 3) diff the generated file and the canons (.pp files already in +# the repository). +# 4) delete the .out file that is generated. +# +# If the diff fails, the generated file is not removed. This will +# be useful for analysis of ABI differences (e.g. using a visual +# diff tool). +# +# A ABI change that causes a build to fail will always be accompanied +# by new canons (.out files). The .out files that are not removed will +# be replaced as the new .pp files. +# +# e.g. If include/mysql/plugin.h has an ABI change then this rule would +# leave a <build directory>/abi_check.out file. +# +# A developer with a justified API change will then do a +# mv <build directory>/abi_check.out include/mysql/plugin.pp +# to replace the old canons with the new ones. +# + +SET(abi_check_out ${BINARY_DIR}/abi_check.out) + +FOREACH(file ${ABI_HEADERS}) + GET_FILENAME_COMPONENT(header_basename ${file} NAME) + SET(tmpfile ${BINARY_DIR}/${header_basename}.pp.tmp) + + EXECUTE_PROCESS( + COMMAND ${COMPILER} + -E -nostdinc -DMYSQL_ABI_CHECK -D__cplusplus + -I${SOURCE_DIR}/include + -I${BINARY_DIR}/include -I${SOURCE_DIR}/include/mysql -I${SOURCE_DIR}/sql + ${file} + ERROR_QUIET OUTPUT_FILE ${tmpfile}) + EXECUTE_PROCESS( + COMMAND sed -e "/^# /d" + -e "/^[ ]*$/d" + -e "/^#pragma GCC set_debug_pwd/d" + -e "/^#ident/d" + RESULT_VARIABLE result OUTPUT_FILE ${abi_check_out} INPUT_FILE ${tmpfile}) + IF(NOT ${result} EQUAL 0) + MESSAGE(FATAL_ERROR "sed returned error ${result}") + ENDIF() + FILE(REMOVE ${tmpfile}) + EXECUTE_PROCESS( + COMMAND diff -w ${file}.pp ${abi_check_out} RESULT_VARIABLE result) + IF(result MATCHES "No such file or directory") + MESSAGE("Command 'diff' not found. ABI check for ${file} skipped.") + ELSEIF(NOT result EQUAL 0) + IF(ABI_UPDATE) + EXECUTE_PROCESS(COMMAND mv -v ${abi_check_out} ${file}.pp) + ELSE(ABI_UPDATE) + MESSAGE(FATAL_ERROR + "ABI check found difference between ${file}.pp and ${abi_check_out}") + ENDIF(ABI_UPDATE) + ENDIF() + FILE(REMOVE ${abi_check_out}) +ENDFOREACH() diff --git a/cmake/dtrace.cmake b/cmake/dtrace.cmake new file mode 100644 index 00000000..dae3b56b --- /dev/null +++ b/cmake/dtrace.cmake @@ -0,0 +1,204 @@ +# Copyright (c) 2009, 2014, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +IF(CMAKE_SYSTEM_NAME MATCHES "SunOS" AND CMAKE_COMPILER_IS_GNUCXX + AND CMAKE_SIZEOF_VOID_P EQUAL 4) + IF(NOT DEFINED BUGGY_GCC_NO_DTRACE_MODULES) + EXECUTE_PROCESS( + COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1} --version + OUTPUT_VARIABLE out) + IF(out MATCHES "3.4.6") + # This gcc causes crashes in dlopen() for dtraced shared libs, + # while standard shipped with Solaris10 3.4.3 is ok + SET(BUGGY_GCC_NO_DTRACE_MODULES 1 CACHE INTERNAL "") + ELSE() + SET(BUGGY_GCC_NO_DTRACE_MODULES 0 CACHE INTERNAL "") + ENDIF() + ENDIF() +ENDIF() + +# Check if OS supports DTrace +MACRO(CHECK_DTRACE) + FIND_PROGRAM(DTRACE dtrace) + MARK_AS_ADVANCED(DTRACE) + + IF(CMAKE_C_COMPILER MATCHES "ccache" AND CMAKE_SYSTEM_NAME MATCHES "Linux") + # dtrace fails on fedora if CC='ccache gcc' is used + SET(BUGGY_LINUX_DTRACE 1) + ENDIF() + + # On FreeBSD, dtrace does not handle userland tracing yet + IF(DTRACE AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD" + AND NOT BUGGY_GCC_NO_DTRACE_MODULES + AND NOT BUGGY_LINUX_DTRACE + AND NOT CMAKE_SYSTEM_NAME MATCHES "SunOS" + AND NOT WIN32) + SET(ENABLE_DTRACE ON CACHE BOOL "Enable dtrace") + ENDIF() + # On GNU/Hurd, dtrace is not supported + IF(DTRACE AND CMAKE_SYSTEM_NAME MATCHES "GNU") + SET(ENABLE_DTRACE OFF CACHE BOOL "Disable dtrace") + ENDIF() + SET(HAVE_DTRACE ${ENABLE_DTRACE}) + IF(CMAKE_SYSTEM_NAME MATCHES "SunOS") + IF(CMAKE_SIZEOF_VOID_P EQUAL 4) + SET(DTRACE_FLAGS -32 CACHE INTERNAL "DTrace architecture flags") + ELSE() + SET(DTRACE_FLAGS -64 CACHE INTERNAL "DTrace architecture flags") + ENDIF() + ENDIF() +ENDMACRO() + +CHECK_DTRACE() + +# Produce a header file with +# DTrace macros +MACRO (DTRACE_HEADER provider header header_no_dtrace) + IF(ENABLE_DTRACE) + ADD_CUSTOM_COMMAND( + OUTPUT ${header} ${header_no_dtrace} + COMMAND ${DTRACE} -h -s ${provider} -o ${header} + COMMAND perl ${CMAKE_SOURCE_DIR}/scripts/dheadgen.pl -f ${provider} > ${header_no_dtrace} + DEPENDS ${provider} + ) + ENDIF() +ENDMACRO() + + +# Create provider headers +IF(ENABLE_DTRACE) + CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/probes_mysql.d.base + ${CMAKE_BINARY_DIR}/include/probes_mysql.d COPYONLY) + DTRACE_HEADER( + ${CMAKE_BINARY_DIR}/include/probes_mysql.d + ${CMAKE_BINARY_DIR}/include/probes_mysql_dtrace.h + ${CMAKE_BINARY_DIR}/include/probes_mysql_nodtrace.h + ) + ADD_CUSTOM_TARGET(gen_dtrace_header + DEPENDS + ${CMAKE_BINARY_DIR}/include/probes_mysql.d + ${CMAKE_BINARY_DIR}/include/probes_mysql_dtrace.h + ${CMAKE_BINARY_DIR}/include/probes_mysql_nodtrace.h + ) +ELSE() + CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/probes_mysql_nodtrace.h.in + ${CMAKE_BINARY_DIR}/include/probes_mysql_nodtrace.h COPYONLY) +ENDIF() + +FUNCTION(DTRACE_INSTRUMENT target) + IF(BUGGY_GCC_NO_DTRACE_MODULES) + GET_TARGET_PROPERTY(target_type ${target} TYPE) + IF(target_type MATCHES "MODULE_LIBRARY") + RETURN() + ENDIF() + ENDIF() + IF(ENABLE_DTRACE) + ADD_DEPENDENCIES(${target} gen_dtrace_header) + + # Invoke dtrace to generate object file and link it together with target. + IF(CMAKE_SYSTEM_NAME MATCHES "SunOS") + SET(objdir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${target}.dir) + SET(outfile ${objdir}/${target}_dtrace.o) + GET_TARGET_PROPERTY(target_type ${target} TYPE) + ADD_CUSTOM_COMMAND( + TARGET ${target} PRE_LINK + COMMAND ${CMAKE_COMMAND} + -DDTRACE=${DTRACE} + -DOUTFILE=${outfile} + -DDFILE=${CMAKE_BINARY_DIR}/include/probes_mysql.d + -DDTRACE_FLAGS=${DTRACE_FLAGS} + -DDIRS=. + -DTYPE=${target_type} + -P ${CMAKE_SOURCE_DIR}/cmake/dtrace_prelink.cmake + WORKING_DIRECTORY ${objdir} + ) + ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Linux") + # dtrace on Linux runs gcc and uses flags from environment + SET(CFLAGS_SAVED $ENV{CFLAGS}) + SET(ENV{CFLAGS} ${CMAKE_C_FLAGS}) + SET(outfile "${CMAKE_BINARY_DIR}/probes_mysql.o") + # Systemtap object + EXECUTE_PROCESS( + COMMAND ${DTRACE} -G -s ${CMAKE_SOURCE_DIR}/include/probes_mysql.d.base + -o ${outfile} + ) + SET(ENV{CFLAGS} ${CFLAGS_SAVED}) + ENDIF() + + # Do not try to extend the library if we have not built the .o file + IF(outfile) + # Add full object path to linker flags + GET_TARGET_PROPERTY(target_type ${target} TYPE) + IF(NOT target_type MATCHES "STATIC") + SET_TARGET_PROPERTIES(${target} PROPERTIES LINK_FLAGS "${outfile}") + ELSE() + # For static library flags, add the object to the library. + # Note: DTrace probes in static libraries are unusable currently + # (see explanation for DTRACE_INSTRUMENT_STATIC_LIBS below) + # but maybe one day this will be fixed. + ADD_CUSTOM_COMMAND( + TARGET ${target} POST_BUILD + COMMAND ${CMAKE_AR} r $<TARGET_FILE:${target}> ${outfile} + COMMAND ${CMAKE_RANLIB} $<TARGET_FILE:${target}> + ) + # Used in DTRACE_INSTRUMENT_WITH_STATIC_LIBS + SET(TARGET_OBJECT_DIRECTORY_${target} ${objdir} CACHE INTERNAL "") + ENDIF() + ENDIF() + ENDIF() +ENDFUNCTION() + + +# Ugly workaround for Solaris' DTrace inability to use probes +# from static libraries, discussed e.g in this thread +# (http://opensolaris.org/jive/thread.jspa?messageID=432454) +# We have to collect all object files that may be instrumented +# and go into the mysqld (also those that come from in static libs) +# run them again through dtrace -G to generate an ELF file that links +# to mysqld. +MACRO (DTRACE_INSTRUMENT_STATIC_LIBS target libs) +IF(CMAKE_SYSTEM_NAME MATCHES "SunOS" AND ENABLE_DTRACE) + # Filter out non-static libraries in the list, if any + SET(static_libs) + FOREACH(lib ${libs}) + GET_TARGET_PROPERTY(libtype ${lib} TYPE) + IF(libtype MATCHES STATIC_LIBRARY) + SET(static_libs ${static_libs} ${lib}) + ENDIF() + ENDFOREACH() + + FOREACH(lib ${static_libs}) + SET(dirs ${dirs} ${TARGET_OBJECT_DIRECTORY_${lib}}) + ENDFOREACH() + + SET (obj ${CMAKE_CURRENT_BINARY_DIR}/${target}_dtrace_all.o) + ADD_CUSTOM_COMMAND( + OUTPUT ${obj} + DEPENDS ${static_libs} + COMMAND ${CMAKE_COMMAND} + -DDTRACE=${DTRACE} + -DOUTFILE=${obj} + -DDFILE=${CMAKE_BINARY_DIR}/include/probes_mysql.d + -DDTRACE_FLAGS=${DTRACE_FLAGS} + "-DDIRS=${dirs}" + -DTYPE=MERGE + -P ${CMAKE_SOURCE_DIR}/cmake/dtrace_prelink.cmake + VERBATIM + ) + ADD_CUSTOM_TARGET(${target}_dtrace_all DEPENDS ${obj}) + ADD_DEPENDENCIES(${target} ${target}_dtrace_all) + TARGET_LINK_LIBRARIES(${target} ${obj}) +ENDIF() +ENDMACRO() diff --git a/cmake/dtrace_prelink.cmake b/cmake/dtrace_prelink.cmake new file mode 100644 index 00000000..e09fd558 --- /dev/null +++ b/cmake/dtrace_prelink.cmake @@ -0,0 +1,84 @@ +# Copyright (c) 2009 Sun Microsystems, Inc. +# Use is subject to license terms. +# +# 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# Generates an ELF object file with dtrace entry points. +# This object that must to be linked with together with +# the target. This script needs to run on Solaris only + +# Do not follow symlinks in GLOB_RECURSE +CMAKE_POLICY(SET CMP0009 NEW) +FILE(REMOVE ${OUTFILE}) + +MACRO(CONVERT_TO_RELATIVE_PATHS files rel_paths) + GET_FILENAME_COMPONENT(abs_dir . ABSOLUTE) + SET(${rel_paths}) + FOREACH(file ${files}) + FILE(RELATIVE_PATH rel ${abs_dir} ${file}) + LIST(APPEND ${rel_paths} ${rel}) + ENDFOREACH() +ENDMACRO() + +IF(TYPE STREQUAL "MERGE") + # Rerun dtrace on objects that are already in static libraries. + # Object paths are stored in text files named 'dtrace_objects' + # in the input directories. We have to copy the objects into temp. + # directory, as running dtrace -G on original files will change + # timestamps and cause rebuilds or the libraries / excessive + # relink + FILE(REMOVE_RECURSE dtrace_objects_merge) + MAKE_DIRECTORY(dtrace_objects_merge) + + FOREACH(dir ${DIRS}) + FILE(STRINGS ${dir}/dtrace_objects OBJS) + FOREACH(obj ${OBJS}) + IF(obj) + EXECUTE_PROCESS(COMMAND cp ${obj} dtrace_objects_merge) + ENDIF() + ENDFOREACH() + ENDFOREACH() + FILE(GLOB_RECURSE OBJECTS dtrace_objects_merge/*.o) + CONVERT_TO_RELATIVE_PATHS("${OBJECTS}" REL_OBJECTS) + EXECUTE_PROCESS( + COMMAND ${DTRACE} ${DTRACE_FLAGS} -o ${OUTFILE} -G -s ${DFILE} ${REL_OBJECTS} + ) + RETURN() +ENDIF() + +FOREACH(dir ${DIRS}) + FILE(GLOB_RECURSE OBJECTS ${dir}/*.o) + CONVERT_TO_RELATIVE_PATHS("${OBJECTS}" REL) + LIST(APPEND REL_OBJECTS ${REL}) +ENDFOREACH() + +FILE(WRITE dtrace_timestamp "") +EXECUTE_PROCESS( + COMMAND ${DTRACE} ${DTRACE_FLAGS} -o ${OUTFILE} -G -s ${DFILE} ${REL_OBJECTS} +) + +# Save objects that contain dtrace probes in a file. +# This file is used when script is called with -DTYPE=MERGE +# to dtrace from static libs. +# To find objects with probes, look at the timestamp, it was updated +# by dtrace -G run +IF(TYPE MATCHES "STATIC") + FILE(WRITE dtrace_objects "") + FOREACH(obj ${REL_OBJECTS}) + IF(${obj} IS_NEWER_THAN dtrace_timestamp) + GET_FILENAME_COMPONENT(obj_absolute_path ${obj} ABSOLUTE) + FILE(APPEND dtrace_objects "${obj_absolute_path}\n" ) + ENDIF() + ENDFOREACH() +ENDIF() diff --git a/cmake/for_clients.cmake b/cmake/for_clients.cmake new file mode 100644 index 00000000..39c37da4 --- /dev/null +++ b/cmake/for_clients.cmake @@ -0,0 +1,74 @@ +# +# Generate LIBS and CFLAGS that third-party clients should use +# + +# Use cmake variables to inspect dependencies for +# mysqlclient library (add -l stuff) +SET(CLIENT_LIBS "") +SET(LIBS "") + +# Avoid compatibility warning about lists with empty elements +IF(POLICY CMP0011) + CMAKE_POLICY(SET CMP0011 NEW) +ENDIF() + +# Extract dependencies using CMake's internal ${target}_LIB_DEPENDS variable +# returned string in ${var} is can be passed to linker's command line +MACRO(EXTRACT_LINK_LIBRARIES target var) + IF(${target}_LIB_DEPENDS) + LIST(REMOVE_ITEM ${target}_LIB_DEPENDS "") + LIST(REMOVE_DUPLICATES ${target}_LIB_DEPENDS) + FOREACH(lib ${${target}_LIB_DEPENDS}) + # Filter out "general", it is not a library, just CMake hint + # Also, remove duplicates + IF(NOT lib STREQUAL "general" AND NOT ${var} MATCHES "-l${lib} " AND NOT lib STREQUAL "zlib") + IF (lib MATCHES "^\\-") + SET(${var} "${${var}} ${lib} ") + ELSEIF(lib MATCHES "^/") + IF (lib MATCHES "\\.(a|so([0-9.]*)|lib|dll|dylib)$") + # Full path, convert to just filename, strip "lib" prefix and extension + GET_FILENAME_COMPONENT(lib "${lib}" NAME_WE) + STRING(REGEX REPLACE "^lib" "" lib "${lib}") + SET(${var} "${${var}}-l${lib} " ) + ENDIF() + ELSE() + SET(${var} "${${var}}-l${lib} " ) + ENDIF() + ENDIF() + ENDFOREACH() + ENDIF() + IF(MSVC) + STRING(REPLACE "-l" "" ${var} "${${var}}") + ENDIF() +ENDMACRO() + +EXTRACT_LINK_LIBRARIES(libmariadb LIBS) +EXTRACT_LINK_LIBRARIES(mysqlserver EMB_LIBS) + +SET(LIBS "-lmariadb ${ZLIB_DEPS} ${LIBS} ${openssl_libs}") +SET(EMB_LIBS "-lmysqld ${ZLIB_DEPS} ${EMB_LIBS} ${openssl_libs}") + +MACRO(REPLACE_FOR_CLIENTS VAR) + SET(v " ${${VAR}} ") + FOREACH(del ${ARGN}) + STRING(REGEX REPLACE " -(${del}) " " " v ${v}) + ENDFOREACH(del) + STRING(REGEX REPLACE " +" " " v ${v}) + STRING(STRIP "${v}" ${VAR}_FOR_CLIENTS) +ENDMACRO() + +# Remove some options that a client doesn't have to care about +# FIXME until we have a --cxxflags, we need to remove -Xa +# and -xstrconst to make --cflags usable for Sun Forte C++ +# FIXME until we have a --cxxflags, we need to remove -AC99 +# to make --cflags usable for HP C++ (aCC) +REPLACE_FOR_CLIENTS(CFLAGS "[DU]DBUG_OFF" "[DU]SAFE_MUTEX" "[DU]NDEBUG" + "[DU]FORCE_INIT_OF_VARS" "[DU]EXTRA_DEBUG" "[DU]HAVE_valgrind" + "O" "O[0-9]" "xO[0-9]" "W[-A-Za-z]*" "mtune=[-A-Za-z0-9]*" "g" "fPIC" + "mcpu=[-A-Za-z0-9]*" "unroll2" "ip" "mp" "march=[-A-Za-z0-9]*" "Xa" + "xstrconst" "xc99=none" "AC99" "restrict" "W[-A-Za-z]*=[-A-Za-z0-9]*") + +# Same for --libs +REPLACE_FOR_CLIENTS(LIBS "Wl,[^ ]*" lmtmalloc static-libcxa i-static static-intel) +REPLACE_FOR_CLIENTS(EMB_LIBS lmtmalloc static-libcxa i-static static-intel ltpool) + diff --git a/cmake/info_bin.cmake b/cmake/info_bin.cmake new file mode 100644 index 00000000..d59b512b --- /dev/null +++ b/cmake/info_bin.cmake @@ -0,0 +1,30 @@ +# Copyright (c) 2011, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + + +# The sole purpose of this cmake control file is to create the "INFO_BIN" file. + +# By having a separate cmake file for this, it is ensured this happens +# only in the build (Unix: "make") phase, not when cmake runs. +# This, in turn, avoids creating stuff in the source directory - +# it should get into the binary directory only. + + +# Get the macros which the "INFO_*" files. +INCLUDE(${CMAKE_BINARY_DIR}/info_macros.cmake) + +# Here is where the action is. +CREATE_INFO_BIN() + diff --git a/cmake/info_macros.cmake.in b/cmake/info_macros.cmake.in new file mode 100644 index 00000000..89ca1ec7 --- /dev/null +++ b/cmake/info_macros.cmake.in @@ -0,0 +1,161 @@ +# Copyright (c) 2011, 2014, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + + +# Handle/create the "INFO_*" files describing a MariaDB (server) binary. +# This is part of the fix for bug#42969. + + +# Several of cmake's variables need to be translated from '@' notation +# to '${}', this is done by the "configure" call in top level "CMakeLists.txt". +# If further variables are used in this file, add them to this list. + +SET(VERSION "@VERSION@") +SET(MAJOR_VERSION "@MAJOR_VERSION@") +SET(MINOR_VERSION "@MINOR_VERSION@") +SET(PATCH_VERSION "@PATCH_VERSION@") +SET(CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@") +SET(CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@") +SET(CMAKE_GENERATOR "@CMAKE_GENERATOR@") +SET(CMAKE_SIZEOF_VOID_P "@CMAKE_SIZEOF_VOID_P@") +SET(GIT_EXECUTABLE "@GIT_EXECUTABLE@") +SET(CMAKE_CROSSCOMPILING "@CMAKE_CROSSCOMPILING@") +SET(CMAKE_HOST_SYSTEM "@CMAKE_HOST_SYSTEM@") +SET(CMAKE_HOST_SYSTEM_PROCESSOR "@CMAKE_HOST_SYSTEM_PROCESSOR@") +SET(CMAKE_SYSTEM "@CMAKE_SYSTEM@") +SET(CMAKE_SYSTEM_PROCESSOR "@CMAKE_SYSTEM_PROCESSOR@") + + +# Create an "INFO_SRC" file with information about the source (only). +# We use "git log", if possible, and the "VERSION" contents. +# +# Outside development (git tree), the "INFO_SRC" file will not be modified +# provided it exists (from "make dist" or a source tarball creation). + +MACRO(CREATE_INFO_SRC target_dir) + SET(INFO_SRC "${target_dir}/INFO_SRC") + + SET(PERLSCRIPT + "use warnings; use POSIX qw(strftime); " + "print strftime \"%F %T %z\", localtime;") + EXECUTE_PROCESS( + COMMAND perl -e "${PERLSCRIPT}" + RESULT_VARIABLE result + OUTPUT_VARIABLE bdate + ERROR_VARIABLE error + ) + IF(error) + MESSAGE(STATUS "Could not determine build-date: <${error}>") + ENDIF() + + IF(GIT_EXECUTABLE AND EXISTS ${CMAKE_SOURCE_DIR}/.git) + # Sources are in a GIT repository: Always update. + EXECUTE_PROCESS( + COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE bname + ) + + EXECUTE_PROCESS( + COMMAND ${GIT_EXECUTABLE} log -1 + --pretty="commit: %H%ndate: %ci%nbuild-date: ${bdate} %nshort: %h%nbranch: ${bname}" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE VERSION_INFO + ) + + ## Output from git is quoted with "", remove them. + STRING(REPLACE "\"" "" VERSION_INFO "${VERSION_INFO}") + FILE(WRITE ${INFO_SRC} "${VERSION_INFO}\n") + # to debug, add: FILE(APPEND ${INFO_SRC} "\nResult ${RESULT}\n") + # For better readability ... + FILE(APPEND ${INFO_SRC} + "MariaDB source ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}\n") + ELSEIF(EXISTS ${INFO_SRC}) + # Outside a git tree, there is no need to change an existing "INFO_SRC", + # it cannot be improved. + ELSEIF(EXISTS ${CMAKE_SOURCE_DIR}/Docs/INFO_SRC) + # If we are building from a source distribution, it also contains "INFO_SRC". + # Similar, the export used for a release build already has the file. + FILE(READ ${CMAKE_SOURCE_DIR}/Docs/INFO_SRC SOURCE_INFO) + FILE(WRITE ${INFO_SRC} "${SOURCE_INFO}\n") + ELSEIF(EXISTS ${CMAKE_SOURCE_DIR}/INFO_SRC) + # This is not the proper location, but who knows ... + FILE(READ ${CMAKE_SOURCE_DIR}/INFO_SRC SOURCE_INFO) + FILE(WRITE ${INFO_SRC} "${SOURCE_INFO}\n") + ELSE() + # This is a fall-back. + FILE(WRITE ${INFO_SRC} "\nMariaDB source ${VERSION}\n") + ENDIF() +ENDMACRO(CREATE_INFO_SRC) + + +# This is for the "real" build, must be run again with each cmake run +# to make sure we report the current flags (not those of some previous run). + +MACRO(CREATE_INFO_BIN) + SET(INFO_BIN "Docs/INFO_BIN") + + FILE(WRITE ${INFO_BIN} "===== Information about the build process: =====\n") + IF (WIN32) + EXECUTE_PROCESS(COMMAND cmd /c date /T + OUTPUT_VARIABLE TMP_DATE OUTPUT_STRIP_TRAILING_WHITESPACE) + ELSEIF(UNIX) + EXECUTE_PROCESS(COMMAND date "+%Y-%m-%d %H:%M:%S" + OUTPUT_VARIABLE TMP_DATE OUTPUT_STRIP_TRAILING_WHITESPACE) + ELSE() + SET(TMP_DATE "(no date command known for this platform)") + ENDIF() + SITE_NAME(HOSTNAME) + FILE(APPEND ${INFO_BIN} "Build was run at ${TMP_DATE} on host '${HOSTNAME}'\n\n") + + # According to the cmake docs, these variables should always be set. + # However, they are empty in my tests, using cmake 2.6.4 on Linux, various Unix, and Windows. + # Still, include this code, so we will profit if a build environment does provide that info. + IF(CMAKE_HOST_SYSTEM) + FILE(APPEND ${INFO_BIN} "Build was done on ${CMAKE_HOST_SYSTEM} using ${CMAKE_HOST_SYSTEM_PROCESSOR}\n") + ENDIF() + IF(CMAKE_CROSSCOMPILING) + FILE(APPEND ${INFO_BIN} "Build was done for ${CMAKE_SYSTEM} using ${CMAKE_SYSTEM_PROCESSOR}\n") + ENDIF() + + # ${CMAKE_VERSION} doesn't work in 2.6.0, use the separate components. + FILE(APPEND ${INFO_BIN} "Build was done using cmake ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} \n\n") + + IF (WIN32) + FILE(APPEND ${INFO_BIN} "===== Compiler / generator used: =====\n") + FILE(APPEND ${INFO_BIN} ${CMAKE_GENERATOR} "\n\n") + ELSEIF(UNIX) + FILE(APPEND ${INFO_BIN} "===== Compiler flags used (from the 'sql/' subdirectory): =====\n") + IF(EXISTS sql/CMakeFiles/sql.dir/flags.make) + EXECUTE_PROCESS(COMMAND egrep "^# compile|^C_|^CXX_" sql/CMakeFiles/sql.dir/flags.make OUTPUT_VARIABLE COMPILE_FLAGS) + FILE(APPEND ${INFO_BIN} ${COMPILE_FLAGS} "\n") + ELSE() + FILE(APPEND ${INFO_BIN} "File 'sql/CMakeFiles/sql.dir/flags.make' is not yet found.\n\n") + ENDIF() + ENDIF() + FILE(APPEND ${INFO_BIN} "Pointer size: ${CMAKE_SIZEOF_VOID_P}\n\n") + + FILE(APPEND ${INFO_BIN} "===== Feature flags used: =====\n") + IF(EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt) + # Attention: "-N" prevents cmake from entering a recursion, and it must be a separate flag from "-L". + EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -N -L ${CMAKE_BINARY_DIR} OUTPUT_VARIABLE FEATURE_FLAGS) + FILE(APPEND ${INFO_BIN} ${FEATURE_FLAGS} "\n") + ELSE() + FILE(APPEND ${INFO_BIN} "File 'CMakeCache.txt' is not yet found.\n\n") + ENDIF() + + FILE(APPEND ${INFO_BIN} "===== EOF =====\n") +ENDMACRO(CREATE_INFO_BIN) + diff --git a/cmake/info_src.cmake b/cmake/info_src.cmake new file mode 100644 index 00000000..df6249f1 --- /dev/null +++ b/cmake/info_src.cmake @@ -0,0 +1,31 @@ +# Copyright (c) 2011, 2014, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + + +# The sole purpose of this cmake control file is to create the "INFO_SRC" file. + +# As long as and "git pull" (or "git commit") is followed by a "cmake", +# the call in top level "CMakeLists.txt" is sufficient. +# This file is to provide a separate target for the "make" phase, +# to ensure the git commit hash is correct even after a sequence +# cmake ; make ; git pull ; make + + +# Get the macros which handle the "INFO_*" files. +INCLUDE(${CMAKE_BINARY_DIR}/info_macros.cmake) + +# Here is where the action is. +CREATE_INFO_SRC(${CMAKE_BINARY_DIR}/Docs) + diff --git a/cmake/install_layout.cmake b/cmake/install_layout.cmake new file mode 100644 index 00000000..bbffc80e --- /dev/null +++ b/cmake/install_layout.cmake @@ -0,0 +1,261 @@ +# Copyright (c) 2010, 2012, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# The purpose of this file is to set the default installation layout. +# +# The current choices of installation layout are: +# +# STANDALONE +# Build with prefix=/usr/local/mysql, create tarball with install prefix="." +# and relative links. Windows zip uses the same tarball layout but without +# the build prefix. +# +# RPM +# Build as per default RPM layout, with prefix=/usr +# +# DEB +# Build as per STANDALONE, prefix=/opt/mysql/server-$major.$minor +# +# SVR4 +# Solaris package layout suitable for pkg* tools, prefix=/opt/mysql/mysql +# +# To force a directory layout, use -DINSTALL_LAYOUT=<layout>. +# +# The default is STANDALONE. +# +# There is the possibility to further fine-tune installation directories. +# Several variables can be overwritten: +# +# - INSTALL_BINDIR (directory with client executables and scripts) +# - INSTALL_SBINDIR (directory with mysqld) +# - INSTALL_SCRIPTDIR (several scripts, rarely used) +# - INSTALL_SYSCONFDIR (my.cnf config file. Usually /etc or nothing) +# - INSTALL_SYSCONF2DIR (additional config files, e.g. /etc/mysql/conf.d) +# +# - INSTALL_LIBDIR (directory with client end embedded libraries) +# - INSTALL_PLUGINDIR (directory for plugins) +# +# - INSTALL_INCLUDEDIR (directory for MySQL headers) +# +# - INSTALL_DOCDIR (documentation) +# - INSTALL_DOCREADMEDIR (readme and similar) +# - INSTALL_MANDIR (man pages) +# - INSTALL_INFODIR (info pages) +# +# - INSTALL_SHAREDIR (location of aclocal/mysql.m4) +# - INSTALL_MYSQLSHAREDIR (MySQL character sets and localized error messages) +# - INSTALL_MYSQLTESTDIR (mysql-test) +# - INSTALL_SQLBENCHDIR (sql-bench) +# - INSTALL_SUPPORTFILESDIR (various extra support files) +# +# - INSTALL_MYSQLDATADIR (data directory) +# +# - INSTALL_UNIX_ADDRDIR (path to mysql.sock) +# +# When changing this page, _please_ do not forget to update public Wiki +# http://forge.mysql.com/wiki/CMake#Fine-tuning_installation_paths + +IF(NOT INSTALL_LAYOUT) + IF(DEB) + SET(INSTALL_LAYOUT "DEB") + ELSEIF(RPM) + SET(INSTALL_LAYOUT "RPM") + ELSE() + SET(INSTALL_LAYOUT "STANDALONE") + ENDIF() +ENDIF() + +SET(INSTALL_LAYOUT "${INSTALL_LAYOUT}" +CACHE STRING "Installation directory layout. Options are: STANDALONE (as in zip or tar.gz installer) RPM DEB SVR4") + +IF(UNIX) + IF(INSTALL_LAYOUT MATCHES "RPM") + SET(default_prefix "/usr") + ELSEIF(INSTALL_LAYOUT MATCHES "DEB") + SET(default_prefix "/usr") + ELSEIF(INSTALL_LAYOUT MATCHES "SVR4") + SET(default_prefix "/opt/mysql/mysql") + ELSE() + SET(default_prefix "/usr/local/mysql") + ENDIF() + IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + SET(CMAKE_INSTALL_PREFIX ${default_prefix} + CACHE PATH "install prefix" FORCE) + ENDIF() + SET(VALID_INSTALL_LAYOUTS "RPM" "STANDALONE" "DEB" "SVR4") + LIST(FIND VALID_INSTALL_LAYOUTS "${INSTALL_LAYOUT}" ind) + IF(ind EQUAL -1) + MESSAGE(FATAL_ERROR "Invalid INSTALL_LAYOUT parameter:${INSTALL_LAYOUT}." + " Choose between ${VALID_INSTALL_LAYOUTS}" ) + ENDIF() +ENDIF() + +# +# STANDALONE layout +# +SET(INSTALL_BINDIR_STANDALONE "bin") +SET(INSTALL_SBINDIR_STANDALONE "bin") +SET(INSTALL_SCRIPTDIR_STANDALONE "scripts") +# +SET(INSTALL_LIBDIR_STANDALONE "lib") +SET(INSTALL_PLUGINDIR_STANDALONE "lib/plugin") +# +SET(INSTALL_INCLUDEDIR_STANDALONE "include/mysql") +# +SET(INSTALL_DOCDIR_STANDALONE "docs") +SET(INSTALL_DOCREADMEDIR_STANDALONE ".") +SET(INSTALL_MANDIR_STANDALONE "man") +SET(INSTALL_INFODIR_STANDALONE "docs") +# +SET(INSTALL_SHAREDIR_STANDALONE "share") +SET(INSTALL_MYSQLSHAREDIR_STANDALONE "share") +SET(INSTALL_MYSQLTESTDIR_STANDALONE "mysql-test") +SET(INSTALL_SQLBENCHDIR_STANDALONE ".") +SET(INSTALL_SUPPORTFILESDIR_STANDALONE "support-files") +# +SET(INSTALL_MYSQLDATADIR_STANDALONE "data") + +SET(INSTALL_UNIX_ADDRDIR_STANDALONE "/tmp/mysql.sock") +SET(INSTALL_PAMDIR_STANDALONE "share") +SET(INSTALL_PAMDATADIR_STANDALONE "share") +# +# RPM layout +# +SET(INSTALL_BINDIR_RPM "bin") +SET(INSTALL_SBINDIR_RPM "sbin") +SET(INSTALL_SCRIPTDIR_RPM "bin") +SET(INSTALL_SYSCONFDIR_RPM "/etc") +SET(INSTALL_SYSCONF2DIR_RPM "/etc/my.cnf.d") +# +IF(CMAKE_SIZEOF_VOID_P EQUAL 8) + SET(INSTALL_LIBDIR_RPM "lib64") +ELSE() + SET(INSTALL_LIBDIR_RPM "lib") +ENDIF() +SET(INSTALL_PLUGINDIR_RPM "${INSTALL_LIBDIR_RPM}/mysql/plugin") +# +SET(INSTALL_INCLUDEDIR_RPM "include/mysql") +# +SET(INSTALL_DOCDIR_RPM "share/doc") +SET(INSTALL_DOCREADMEDIR_RPM "share/doc") +SET(INSTALL_INFODIR_RPM "share/info") +SET(INSTALL_MANDIR_RPM "share/man") +# +SET(INSTALL_SHAREDIR_RPM "share") +SET(INSTALL_MYSQLSHAREDIR_RPM "share/mysql") +SET(INSTALL_MYSQLTESTDIR_RPM "share/mysql-test") +SET(INSTALL_SQLBENCHDIR_RPM "") +SET(INSTALL_SUPPORTFILESDIR_RPM "share/mysql") +# +SET(INSTALL_MYSQLDATADIR_RPM "/var/lib/mysql") + +SET(INSTALL_UNIX_ADDRDIR_RPM "${INSTALL_MYSQLDATADIR_RPM}/mysql.sock") +SET(INSTALL_SYSTEMD_UNITDIR_RPM "/usr/lib/systemd/system") +SET(INSTALL_SYSTEMD_SYSUSERSDIR_RPM "/usr/lib/sysusers.d") +SET(INSTALL_SYSTEMD_TMPFILESDIR_RPM "/usr/lib/tmpfiles.d") +SET(INSTALL_PAMDIR_RPM "/${INSTALL_LIBDIR_RPM}/security") +SET(INSTALL_PAMDATADIR_RPM "/etc/security") + +# +# DEB layout +# +SET(INSTALL_BINDIR_DEB "bin") +SET(INSTALL_SBINDIR_DEB "sbin") +SET(INSTALL_SCRIPTDIR_DEB "bin") +SET(INSTALL_SYSCONFDIR_DEB "/etc") +SET(INSTALL_SYSCONF2DIR_DEB "/etc/mysql/mariadb.conf.d") +# +SET(INSTALL_LIBDIR_DEB "lib/${CMAKE_CXX_LIBRARY_ARCHITECTURE}") +SET(INSTALL_PLUGINDIR_DEB "lib/mysql/plugin") +# +SET(INSTALL_INCLUDEDIR_DEB "include/mariadb") +# +SET(INSTALL_DOCDIR_DEB "share/doc") +SET(INSTALL_DOCREADMEDIR_DEB "share/doc") +SET(INSTALL_MANDIR_DEB "share/man") +SET(INSTALL_INFODIR_DEB "share/info") +# +SET(INSTALL_SHAREDIR_DEB "share") +SET(INSTALL_MYSQLSHAREDIR_DEB "share/mysql") +SET(INSTALL_MYSQLTESTDIR_DEB "share/mysql/mysql-test") +SET(INSTALL_SQLBENCHDIR_DEB ".") +SET(INSTALL_SUPPORTFILESDIR_DEB "share/mysql") +# +SET(INSTALL_MYSQLDATADIR_DEB "/var/lib/mysql") + +SET(INSTALL_UNIX_ADDRDIR_DEB "/run/mysqld/mysqld.sock") +SET(INSTALL_SYSTEMD_UNITDIR_DEB "/lib/systemd/system") +SET(INSTALL_SYSTEMD_SYSUSERSDIR_DEB "/usr/lib/sysusers.d") +SET(INSTALL_SYSTEMD_TMPFILESDIR_DEB "/usr/lib/tmpfiles.d") +SET(INSTALL_PAMDIR_DEB "/lib/${CMAKE_CXX_LIBRARY_ARCHITECTURE}/security") +SET(INSTALL_PAMDATADIR_DEB "/etc/security") + +# +# SVR4 layout +# +SET(INSTALL_BINDIR_SVR4 "bin") +SET(INSTALL_SBINDIR_SVR4 "bin") +SET(INSTALL_SCRIPTDIR_SVR4 "scripts") +# +SET(INSTALL_LIBDIR_SVR4 "lib") +SET(INSTALL_PLUGINDIR_SVR4 "lib/plugin") +# +SET(INSTALL_INCLUDEDIR_SVR4 "include/mysql") +# +SET(INSTALL_DOCDIR_SVR4 "docs") +SET(INSTALL_DOCREADMEDIR_SVR4 ".") +SET(INSTALL_MANDIR_SVR4 "man") +SET(INSTALL_INFODIR_SVR4 "docs") +# +SET(INSTALL_SHAREDIR_SVR4 "share") +SET(INSTALL_MYSQLSHAREDIR_SVR4 "share") +SET(INSTALL_MYSQLTESTDIR_SVR4 "mysql-test") +SET(INSTALL_SQLBENCHDIR_SVR4 ".") +SET(INSTALL_SUPPORTFILESDIR_SVR4 "support-files") +# +SET(INSTALL_MYSQLDATADIR_SVR4 "/var/lib/mysql") + +SET(INSTALL_UNIX_ADDRDIR_SVR "/tmp/mysql.sock") + +# Clear cached variables if install layout was changed +IF(OLD_INSTALL_LAYOUT) + IF(NOT OLD_INSTALL_LAYOUT STREQUAL INSTALL_LAYOUT) + SET(FORCE FORCE) + ENDIF() +ENDIF() +SET(OLD_INSTALL_LAYOUT ${INSTALL_LAYOUT} CACHE INTERNAL "") + +# Set INSTALL_FOODIR variables for chosen layout (for example, INSTALL_BINDIR +# will be defined as ${INSTALL_BINDIR_STANDALONE} by default if STANDALONE +# layout is chosen) +GET_CMAKE_PROPERTY(ALL_VARS VARIABLES) +FOREACH (V ${ALL_VARS}) + IF (V MATCHES "^(INSTALL_([A-Z_0-9]+)DIR)_${INSTALL_LAYOUT}$") + SET(var ${CMAKE_MATCH_1}) + SET(${var} "${${V}}" CACHE STRING "${CMAKE_MATCH_2} installation directory" ${FORCE}) + MARK_AS_ADVANCED(${var}) + + IF(IS_ABSOLUTE "${${var}}") + SET(${var}ABS "${${var}}") + ELSE() + SET(${var}ABS "${CMAKE_INSTALL_PREFIX}/${${var}}") + ENDIF() + ENDIF() +ENDFOREACH() + +IF(NOT MYSQL_UNIX_ADDR) + SET(MYSQL_UNIX_ADDR ${INSTALL_UNIX_ADDRDIR}) +ENDIF() + diff --git a/cmake/install_macros.cmake b/cmake/install_macros.cmake new file mode 100644 index 00000000..aef438fe --- /dev/null +++ b/cmake/install_macros.cmake @@ -0,0 +1,287 @@ +# Copyright (c) 2009, 2011, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +INCLUDE(CMakeParseArguments) + +FUNCTION (INSTALL_DEBUG_SYMBOLS) + IF(MSVC) + CMAKE_PARSE_ARGUMENTS(ARG + "" + "COMPONENT;INSTALL_LOCATION" + "" + ${ARGN} + ) + + IF(NOT ARG_COMPONENT) + SET(ARG_COMPONENT DebugBinaries) + ENDIF() + IF(NOT ARG_INSTALL_LOCATION) + SET(ARG_INSTALL_LOCATION lib) + ENDIF() + SET(targets ${ARG_UNPARSED_ARGUMENTS}) + FOREACH(target ${targets}) + GET_TARGET_PROPERTY(target_type ${target} TYPE) + IF(target_type MATCHES "STATIC") + RETURN() + ENDIF() + set(comp "") + + IF(target STREQUAL "server" + OR target STREQUAL "mariadbd") + SET(comp Server) + ENDIF() + + INSTALL(FILES $<TARGET_PDB_FILE:${target}> DESTINATION symbols COMPONENT Debuginfo) + IF(comp) + INSTALL(FILES $<TARGET_PDB_FILE:${target}> DESTINATION ${ARG_INSTALL_LOCATION} COMPONENT ${comp}) + ENDIF() + ENDFOREACH() + ENDIF() +ENDFUNCTION() + +# Installs manpage for given file (either script or executable) +# +FUNCTION(INSTALL_MANPAGE file) + IF(NOT UNIX) + RETURN() + ENDIF() + GET_FILENAME_COMPONENT(file_name "${file}" NAME) + SET(GLOB_EXPR + ${CMAKE_SOURCE_DIR}/man/*${file}man.1* + ${CMAKE_SOURCE_DIR}/man/*${file}man.8* + ${CMAKE_BINARY_DIR}/man/*${file}man.1* + ${CMAKE_BINARY_DIR}/man/*${file}man.8* + ) + IF(MYSQL_DOC_DIR) + SET(GLOB_EXPR + ${MYSQL_DOC_DIR}/man/*${file}man.1* + ${MYSQL_DOC_DIR}/man/*${file}man.8* + ${MYSQL_DOC_DIR}/man/*${file}.1* + ${MYSQL_DOC_DIR}/man/*${file}.8* + ${GLOB_EXPR} + ) + ENDIF() + + FILE(GLOB_RECURSE MANPAGES ${GLOB_EXPR}) + + IF(MANPAGES) + LIST(GET MANPAGES 0 MANPAGE) + STRING(REPLACE "${file}man.1" "${file}.1" MANPAGE "${MANPAGE}") + STRING(REPLACE "${file}man.8" "${file}.8" MANPAGE "${MANPAGE}") + IF(MANPAGE MATCHES "${file}.1") + SET(SECTION man1) + ELSE() + SET(SECTION man8) + ENDIF() + INSTALL(FILES "${MANPAGE}" DESTINATION "${INSTALL_MANDIR}/${SECTION}" + COMPONENT ManPages) + ENDIF() +ENDFUNCTION() + +FUNCTION(INSTALL_SCRIPT) + CMAKE_PARSE_ARGUMENTS(ARG + "" + "DESTINATION;COMPONENT" + "" + ${ARGN} + ) + + SET(script ${ARG_UNPARSED_ARGUMENTS}) + IF(NOT ARG_DESTINATION) + SET(ARG_DESTINATION ${INSTALL_BINDIR}) + ENDIF() + SET(COMP ${ARG_COMPONENT}) + + IF (COMP MATCHES ${SKIP_COMPONENTS}) + RETURN() + ENDIF() + + INSTALL(PROGRAMS ${script} DESTINATION ${ARG_DESTINATION} COMPONENT ${COMP}) + get_filename_component(dest "${script}" NAME) + INSTALL_MANPAGE(${dest}) +ENDFUNCTION() + + +FUNCTION(INSTALL_DOCUMENTATION) + CMAKE_PARSE_ARGUMENTS(ARG "" "COMPONENT" "" ${ARGN}) + SET(files ${ARG_UNPARSED_ARGUMENTS}) + IF(NOT ARG_COMPONENT) + SET(ARG_COMPONENT Server) + ENDIF() + IF (ARG_COMPONENT MATCHES "Readme") + SET(destination ${INSTALL_DOCREADMEDIR}) + ELSE() + SET(destination ${INSTALL_DOCDIR}) + ENDIF() + + IF (ARG_COMPONENT MATCHES ${SKIP_COMPONENTS}) + RETURN() + ENDIF() + + STRING(TOUPPER ${ARG_COMPONENT} COMPUP) + IF(CPACK_COMPONENT_${COMPUP}_GROUP) + SET(group ${CPACK_COMPONENT_${COMPUP}_GROUP}) + ELSE() + SET(group ${ARG_COMPONENT}) + ENDIF() + + IF(RPM) + SET(destination "${destination}/MariaDB-${group}-${VERSION}") + ELSEIF(DEB) + SET(destination "${destination}/mariadb-${group}-${MAJOR_VERSION}.${MINOR_VERSION}") + ENDIF() + + INSTALL(FILES ${files} DESTINATION ${destination} COMPONENT ${ARG_COMPONENT}) +ENDFUNCTION() + + +# Install symbolic link to CMake target. +# the link is created in the current build directory +# and extension will be the same as for target file. +MACRO(INSTALL_SYMLINK linkname target destination component) +IF(UNIX) + SET(output ${CMAKE_CURRENT_BINARY_DIR}/${linkname}) + ADD_CUSTOM_COMMAND( + OUTPUT ${output} + COMMAND ${CMAKE_COMMAND} ARGS -E remove -f ${linkname} + COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink + $<TARGET_FILE_NAME:${target}> + ${linkname} + DEPENDS ${target} + ) + + ADD_CUSTOM_TARGET(symlink_${linkname} + ALL + DEPENDS ${output}) + SET_TARGET_PROPERTIES(symlink_${linkname} PROPERTIES CLEAN_DIRECT_OUTPUT 1) + IF(CMAKE_GENERATOR MATCHES "Xcode") + # For Xcode, replace project config with install config + STRING(REPLACE "${CMAKE_CFG_INTDIR}" + "\${CMAKE_INSTALL_CONFIG_NAME}" output ${output}) + ENDIF() + INSTALL(FILES ${output} DESTINATION ${destination} COMPONENT ${component}) +ENDIF() +ENDMACRO() + +IF(WIN32) + OPTION(SIGNCODE "Sign executables and dlls with digital certificate" OFF) + MARK_AS_ADVANCED(SIGNCODE) + IF(SIGNCODE) + SET(SIGNTOOL_PARAMETERS + /a /t http://timestamp.globalsign.com/?signature=sha2 + CACHE STRING "parameters for signtool (list)") + FIND_PROGRAM(SIGNTOOL_EXECUTABLE signtool + PATHS "$ENV{ProgramFiles}/Microsoft SDKs/Windows/v7.0A/bin" + "$ENV{ProgramFiles}/Windows Kits/8.0/bin/x86" + "$ENV{ProgramFiles}/Windows Kits/8.1/bin/x86" + ) + IF(NOT SIGNTOOL_EXECUTABLE) + MESSAGE(FATAL_ERROR + "signtool is not found. Signing executables not possible") + ENDIF() + MARK_AS_ADVANCED(SIGNTOOL_EXECUTABLE SIGNTOOL_PARAMETERS) + ENDIF() +ENDIF() + + +FUNCTION(SIGN_TARGET target) + IF(NOT SIGNCODE) + RETURN() + ENDIF() + GET_TARGET_PROPERTY(target_type ${target} TYPE) + IF((NOT target_type) OR (target_type MATCHES "STATIC")) + RETURN() + ENDIF() + # Mark executable for signing by creating empty *.signme file + # The actual signing happens in preinstall step + # (which traverses + ADD_CUSTOM_COMMAND(TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E touch "$<TARGET_FILE:${target}>.signme" + ) +ENDFUNCTION() + +# Installs targets, also installs pdbs on Windows. +# +# + +FUNCTION(MYSQL_INSTALL_TARGETS) + CMAKE_PARSE_ARGUMENTS(ARG + "" + "DESTINATION;COMPONENT" + "" + ${ARGN} + ) + IF(ARG_COMPONENT) + SET(COMP COMPONENT ${ARG_COMPONENT}) + ELSE() + MESSAGE(FATAL_ERROR "COMPONENT argument required") + ENDIF() + + SET(TARGETS ${ARG_UNPARSED_ARGUMENTS}) + IF(NOT TARGETS) + MESSAGE(FATAL_ERROR "Need target list for MYSQL_INSTALL_TARGETS") + ENDIF() + IF(NOT ARG_DESTINATION) + MESSAGE(FATAL_ERROR "Need DESTINATION parameter for MYSQL_INSTALL_TARGETS") + ENDIF() + + FOREACH(target ${TARGETS}) + # If signing is required, sign executables before installing + IF(SIGNCODE) + SIGN_TARGET(${target} ${COMP}) + ENDIF() + # Install man pages on Unix + IF(UNIX) + INSTALL_MANPAGE($<TARGET_FILE:${target}>) + ENDIF() + ENDFOREACH() + + INSTALL(TARGETS ${TARGETS} DESTINATION ${ARG_DESTINATION} ${COMP}) + INSTALL_DEBUG_SYMBOLS(${TARGETS} ${COMP} INSTALL_LOCATION ${ARG_DESTINATION}) + +ENDFUNCTION() + +# Optionally install mysqld/client/embedded from debug build run. outside of the current build dir +# (unless multi-config generator is used like Visual Studio or Xcode). +# For Makefile generators we default Debug build directory to ${buildroot}/../debug. +GET_FILENAME_COMPONENT(BINARY_PARENTDIR ${CMAKE_BINARY_DIR} PATH) +SET(DEBUGBUILDDIR "${BINARY_PARENTDIR}/debug" CACHE INTERNAL "Directory of debug build") + +FUNCTION(INSTALL_MYSQL_TEST from to) + IF(INSTALL_MYSQLTESTDIR) + INSTALL( + DIRECTORY ${from} + DESTINATION "${INSTALL_MYSQLTESTDIR}/${to}" + USE_SOURCE_PERMISSIONS + COMPONENT Test + PATTERN "var" EXCLUDE + PATTERN "lib/My/SafeProcess" EXCLUDE + PATTERN "lib/t*" EXCLUDE + PATTERN "CPack" EXCLUDE + PATTERN "CMake*" EXCLUDE + PATTERN "cmake_install.cmake" EXCLUDE + PATTERN "mtr.out*" EXCLUDE + PATTERN ".cvsignore" EXCLUDE + PATTERN "*.am" EXCLUDE + PATTERN "*.in" EXCLUDE + PATTERN "Makefile" EXCLUDE + PATTERN "*.vcxproj" EXCLUDE + PATTERN "*.vcxproj.filters" EXCLUDE + PATTERN "*.vcxproj.user" EXCLUDE + PATTERN "CTest*" EXCLUDE + PATTERN "*~" EXCLUDE + ) + ENDIF() +ENDFUNCTION() diff --git a/cmake/jemalloc.cmake b/cmake/jemalloc.cmake new file mode 100644 index 00000000..55369157 --- /dev/null +++ b/cmake/jemalloc.cmake @@ -0,0 +1,42 @@ +INCLUDE (CheckLibraryExists) + +SET(WITH_JEMALLOC auto CACHE STRING + "Build with jemalloc. Possible values are 'yes', 'no', 'static', 'auto'") + +MACRO (CHECK_JEMALLOC) + # compatibility with old WITH_JEMALLOC values + IF(WITH_JEMALLOC STREQUAL "bundled") + MESSAGE(FATAL_ERROR "MariaDB no longer bundles jemalloc") + ENDIF() + IF(WITH_JEMALLOC STREQUAL "system") + SET(WITH_JEMALLOC "yes") + ENDIF() + + IF(WITH_JEMALLOC STREQUAL "yes" OR WITH_JEMALLOC STREQUAL "auto" OR + WITH_JEMALLOC STREQUAL "static") + + IF(WITH_JEMALLOC STREQUAL "static") + SET(libname jemalloc_pic) + SET(CMAKE_REQUIRED_LIBRARIES pthread ${CMAKE_DL_LIBS} m) + SET(what bundled) + ELSE() + SET(libname jemalloc c) + SET(what system) + ENDIF() + + FOREACH(lib ${libname}) + CHECK_LIBRARY_EXISTS(${lib} malloc_stats_print "" HAVE_JEMALLOC_IN_${lib}) + IF (HAVE_JEMALLOC_IN_${lib}) + SET(LIBJEMALLOC ${lib}) + SET(MALLOC_LIBRARY "${what} jemalloc") + BREAK() + ENDIF() + ENDFOREACH() + SET(CMAKE_REQUIRED_LIBRARIES) + + IF (NOT LIBJEMALLOC AND NOT WITH_JEMALLOC STREQUAL "auto") + MESSAGE(FATAL_ERROR "jemalloc is not found") + ENDIF() + ADD_FEATURE_INFO(JEMALLOC LIBJEMALLOC "Use the JeMalloc memory allocator") + ENDIF() +ENDMACRO() diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake new file mode 100644 index 00000000..4c840197 --- /dev/null +++ b/cmake/libutils.cmake @@ -0,0 +1,374 @@ +# Copyright (c) 2009, 2010, Oracle and/or its affiliates. +# +# 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + + +# This file exports macros that emulate some functionality found in GNU libtool +# on Unix systems. One such feature is convenience libraries. In this context, +# convenience library is a static library that can be linked to shared library +# On systems that force position-independent code, linking into shared library +# normally requires compilation with a special flag (often -fPIC). To enable +# linking static libraries to shared, we compile source files that come into +# static library with the PIC flag (${CMAKE_SHARED_LIBRARY_C_FLAGS} in CMake) +# Some systems, like Windows or OSX do not need special compilation (Windows +# never uses PIC and OSX always uses it). +# +# The intention behind convenience libraries is simplify the build and to reduce +# excessive recompiles. + +# Except for convenience libraries, this file provides macros to merge static +# libraries (we need it for mysqlclient) and to create shared library out of +# convenience libraries(again, for mysqlclient) + +# Following macros are exported +# - ADD_CONVENIENCE_LIBRARY(target source1...sourceN) +# This macro creates convenience library. The functionality is similar to +# ADD_LIBRARY(target STATIC source1...sourceN), the difference is that resulting +# library can always be linked to shared library +# +# - MERGE_LIBRARIES(target [STATIC|SHARED|MODULE] [linklib1 .... linklibN] +# [EXPORTS exported_func1 .... exported_func_N] +# [OUTPUT_NAME output_name] +# This macro merges several static libraries into a single one or creates a shared +# library from several convenience libraries + +# Important global flags +# - WITH_PIC : If set, it is assumed that everything is compiled as position +# independent code (that is CFLAGS/CMAKE_C_FLAGS contain -fPIC or equivalent) +# If defined, ADD_CONVENIENCE_LIBRARY does not add PIC flag to compile flags +# +# - DISABLE_SHARED: If set, it is assumed that shared libraries are not produced +# during the build. ADD_CONVENIENCE_LIBRARY does not add anything to compile flags + + +GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +IF(WIN32 OR CYGWIN OR APPLE OR WITH_PIC OR DISABLE_SHARED OR NOT CMAKE_SHARED_LIBRARY_C_FLAGS) + SET(_SKIP_PIC 1) +ENDIF() + +INCLUDE(CMakeParseArguments) +# CREATE_EXPORTS_FILE (VAR target api_functions) +# Internal macro, used to create source file for shared libraries that +# otherwise consists entirely of "convenience" libraries. On Windows, +# also exports API functions as dllexport. On unix, creates a dummy file +# that references all exports and this prevents linker from creating an +# empty library(there are unportable alternatives, --whole-archive) +MACRO(CREATE_EXPORTS_FILE VAR TARGET API_FUNCTIONS) + IF(WIN32) + SET(DUMMY ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_dummy.c) + SET(EXPORTS ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_exports.def) + CONFIGURE_FILE_CONTENT("" ${DUMMY}) + SET(CONTENT "EXPORTS\n") + FOREACH(FUNC ${API_FUNCTIONS}) + SET(CONTENT "${CONTENT} ${FUNC}\n") + ENDFOREACH() + CONFIGURE_FILE_CONTENT(${CONTENT} ${EXPORTS}) + SET(${VAR} ${DUMMY} ${EXPORTS}) + ELSE() + SET(EXPORTS ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_exports_file.cc) + SET(CONTENT) + FOREACH(FUNC ${API_FUNCTIONS}) + SET(CONTENT "${CONTENT} extern void* ${FUNC}\;\n") + ENDFOREACH() + SET(CONTENT "${CONTENT} void *${TARGET}_api_funcs[] = {\n") + FOREACH(FUNC ${API_FUNCTIONS}) + SET(CONTENT "${CONTENT} &${FUNC},\n") + ENDFOREACH() + SET(CONTENT "${CONTENT} (void *)0\n}\;") + CONFIGURE_FILE_CONTENT(${CONTENT} ${EXPORTS}) + # Avoid "function redeclared as variable" error + # when using gcc/clang option -flto(link time optimization) + IF(" ${CMAKE_C_FLAGS} ${CMAKE_CXX_FLAGS} " MATCHES " -flto") + SET_SOURCE_FILES_PROPERTIES(${EXPORTS} PROPERTIES COMPILE_FLAGS "-fno-lto") + ENDIF() + SET(${VAR} ${EXPORTS}) + ENDIF() +ENDMACRO() + + +# MYSQL_ADD_CONVENIENCE_LIBRARY(name source1...sourceN) +# Create static library that can be linked to shared library. +# On systems that force position-independent code, adds -fPIC or +# equivalent flag to compile flags. +MACRO(ADD_CONVENIENCE_LIBRARY) + SET(TARGET ${ARGV0}) + SET(SOURCES ${ARGN}) + LIST(REMOVE_AT SOURCES 0) + ADD_LIBRARY(${TARGET} STATIC ${SOURCES}) + IF(NOT _SKIP_PIC) + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES COMPILE_FLAGS + "${CMAKE_SHARED_LIBRARY_C_FLAGS}") + ENDIF() +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 +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() + +# Merge static libraries into a big static lib. The resulting library +# should not not have dependencies on other static libraries. +# We use it in MariaDB to merge mysys,dbug,vio etc into the embedded server +# mariadbd. + +MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) + # To produce a library we need at least one source file. + # It is created by ADD_CUSTOM_COMMAND below and will helps + # also help to track dependencies. + SET(SOURCE_FILE ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_depends.c) + ADD_LIBRARY(${TARGET} STATIC ${SOURCE_FILE}) + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES OUTPUT_NAME ${OUTPUT_NAME}) + IF(NOT _SKIP_PIC) + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES COMPILE_FLAGS + "${CMAKE_SHARED_LIBRARY_C_FLAGS}") + ENDIF() + + SET(OSLIBS) + FOREACH(LIB ${LIBS_TO_MERGE}) + IF(NOT TARGET ${LIB}) + # 3rd party library like libz.so. Make sure that everything + # that links to our library links to this one as well. + LIST(APPEND OSLIBS ${LIB}) + ELSE() + GET_TARGET_PROPERTY(LIB_TYPE ${LIB} TYPE) + # This is a target in current project + # (can be a static or shared lib) + IF(LIB_TYPE STREQUAL "STATIC_LIBRARY") + SET(STATIC_TGTS ${STATIC_TGTS} ${LIB}) + SET(STATIC_LIBS ${STATIC_LIBS} $<TARGET_FILE:${LIB}>) + ADD_DEPENDENCIES(${TARGET} ${LIB}) + # Extract dependent OS libraries + GET_DEPENDEND_OS_LIBS(${LIB} LIB_OSLIBS) + LIST(APPEND OSLIBS ${LIB_OSLIBS}) + ELSE() + # This is a shared library our static lib depends on. + LIST(APPEND OSLIBS ${LIB}) + ENDIF() + ENDIF() + ENDFOREACH() + # With static libraries the order matter to some linkers. + # REMOVE_DUPLICATES will keep the first entry and because + # the linker requirement we want to keep the last. + IF(STATIC_LIBS) + LIST(REVERSE STATIC_LIBS) + LIST(REMOVE_DUPLICATES STATIC_LIBS) + LIST(REVERSE STATIC_LIBS) + ENDIF() + IF(OSLIBS) + LIST(REVERSE OSLIBS) + LIST(REMOVE_DUPLICATES OSLIBS) + LIST(REVERSE OSLIBS) + TARGET_LINK_LIBRARIES(${TARGET} LINK_PRIVATE ${OSLIBS}) + ENDIF() + + # Make the generated dummy source file depended on all static input + # libs. If input lib changes,the source file is touched + # which causes the desired effect (relink). + ADD_CUSTOM_COMMAND( + OUTPUT ${SOURCE_FILE} + COMMAND ${CMAKE_COMMAND} -E touch ${SOURCE_FILE} + DEPENDS ${STATIC_TGTS}) + + IF(MSVC) + # To merge libs, just pass them to lib.exe command line. + SET(LINKER_EXTRA_FLAGS "") + FOREACH(LIB ${STATIC_LIBS}) + SET(LINKER_EXTRA_FLAGS "${LINKER_EXTRA_FLAGS} ${LIB}") + ENDFOREACH() + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES STATIC_LIBRARY_FLAGS + "${LINKER_EXTRA_FLAGS}") + ELSE() + IF(APPLE) + # Use OSX's libtool to merge archives (ihandles universal + # binaries properly) + ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD + COMMAND rm $<TARGET_FILE:${TARGET}> + COMMAND libtool -static -o $<TARGET_FILE:${TARGET}> + ${STATIC_LIBS} + ) + ELSE() + # Generic Unix, Cygwin or MinGW. In post-build step, call + # script, that uses a MRI script to append static archives. + IF(CMAKE_VERSION VERSION_LESS "3.0") + SET(MRI_SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}.mri") + ELSE() + SET(MRI_SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}-$<CONFIG>.mri") + ENDIF() + SET(MRI_SCRIPT_TPL "${MRI_SCRIPT}.tpl") + + SET(SCRIPT_CONTENTS "CREATE $<TARGET_FILE:${TARGET}>\n") + FOREACH(LIB ${STATIC_LIBS}) + SET(SCRIPT_CONTENTS "${SCRIPT_CONTENTS}ADDLIB ${LIB}\n") + ENDFOREACH() + FILE(WRITE ${MRI_SCRIPT_TPL} "${SCRIPT_CONTENTS}\nSAVE\nEND\n") + FILE(GENERATE OUTPUT ${MRI_SCRIPT} INPUT ${MRI_SCRIPT_TPL}) + + ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD + DEPENDS ${MRI_SCRIPT} + COMMAND ${CMAKE_COMMAND} + ARGS + -DTARGET_SCRIPT="${MRI_SCRIPT}" + -DTOP_DIR="${CMAKE_BINARY_DIR}" + -DCMAKE_AR="${CMAKE_AR}" + -P "${MYSQL_CMAKE_SCRIPT_DIR}/merge_archives_unix.cmake" + COMMAND ${CMAKE_RANLIB} + ARGS $<TARGET_FILE:${TARGET}> + ) + SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${MRI_SCRIPT_TPL}) + SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${MRI_SCRIPT}.mri) + ENDIF() + ENDIF() +ENDMACRO() + +# Create libs from libs. +# Merges static libraries, creates shared libraries out of convenience libraries. +# MERGE_LIBRARIES(target [STATIC|SHARED|MODULE] +# [linklib1 .... linklibN] +# [EXPORTS exported_func1 .... exportedFuncN] +# [OUTPUT_NAME output_name] +#) +MACRO(MERGE_LIBRARIES) + CMAKE_PARSE_ARGUMENTS(ARG + "STATIC;SHARED;MODULE;NOINSTALL" + "OUTPUT_NAME;COMPONENT;VERSION;SOVERSION" + "EXPORTS" + ${ARGN} + ) + LIST(GET ARG_UNPARSED_ARGUMENTS 0 TARGET) + SET(LIBS ${ARG_UNPARSED_ARGUMENTS}) + LIST(REMOVE_AT LIBS 0) + IF(ARG_STATIC) + IF (NOT ARG_OUTPUT_NAME) + SET(ARG_OUTPUT_NAME ${TARGET}) + ENDIF() + MERGE_STATIC_LIBS(${TARGET} ${ARG_OUTPUT_NAME} "${LIBS}") + ELSEIF(ARG_SHARED OR ARG_MODULE) + IF(ARG_SHARED) + SET(LIBTYPE SHARED) + ELSE() + SET(LIBTYPE MODULE) + ENDIF() + # check for non-PIC libraries + IF(NOT _SKIP_PIC) + FOREACH(LIB ${LIBS}) + GET_TARGET_PROPERTY(LTYPE ${LIB} TYPE) + IF(LTYPE STREQUAL "STATIC_LIBRARY") + GET_TARGET_PROPERTY(LIB_COMPILE_FLAGS ${LIB} COMPILE_FLAGS) + STRING(REPLACE "${CMAKE_SHARED_LIBRARY_C_FLAGS}" + "<PIC_FLAG>" LIB_COMPILE_FLAGS "${LIB_COMPILE_FLAGS}") + IF(NOT LIB_COMPILE_FLAGS MATCHES "<PIC_FLAG>") + MESSAGE(FATAL_ERROR + "Attempted to link non-PIC static library ${LIB} to shared library ${TARGET}\n" + "Please use ADD_CONVENIENCE_LIBRARY, instead of ADD_LIBRARY for ${LIB}" + ) + ENDIF() + ENDIF() + ENDFOREACH() + ENDIF() + CREATE_EXPORTS_FILE(SRC ${TARGET} "${ARG_EXPORTS}") + IF(NOT ARG_NOINSTALL) + ADD_VERSION_INFO(${TARGET} SHARED SRC) + ENDIF() + IF(ARG_VERSION) + SET(VERS VERSION ${ARG_VERSION}) + ENDIF() + ADD_LIBRARY(${TARGET} ${LIBTYPE} ${SRC}) + IF (ARG_VERSION) + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES VERSION ${ARG_VERSION}) + ENDIF() + IF (ARG_SOVERSION) + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES SOVERSION ${ARG_VERSION}) + ENDIF() + TARGET_LINK_LIBRARIES(${TARGET} LINK_PRIVATE ${LIBS}) + IF(ARG_OUTPUT_NAME) + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES OUTPUT_NAME "${ARG_OUTPUT_NAME}") + ENDIF() + ELSE() + MESSAGE(FATAL_ERROR "Unknown library type") + ENDIF() + IF(NOT ARG_NOINSTALL) + IF(ARG_COMPONENT) + SET(COMP COMPONENT ${ARG_COMPONENT}) + ENDIF() + MYSQL_INSTALL_TARGETS(${TARGET} DESTINATION "${INSTALL_LIBDIR}" ${COMP}) + ENDIF() + IF(ARG_SHARED AND LINK_FLAG_NO_UNDEFINED) + # Do not allow undefined symbols in shared libraries + GET_TARGET_PROPERTY(TARGET_LINK_FLAGS ${TARGET} LINK_FLAGS) + IF(NOT TARGET_LINK_FLAGS) + SET(TARGET_LINK_FLAGS) + ENDIF() + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES LINK_FLAGS + "${TARGET_LINK_FLAGS} ${LINK_FLAG_NO_UNDEFINED}") + ENDIF() +ENDMACRO() + +FUNCTION(GET_DEPENDEND_OS_LIBS target result) + GET_TARGET_PROPERTY(DEPS ${target} LINK_LIBRARIES) + IF(DEPS) + FOREACH(lib ${DEPS}) + IF(NOT TARGET ${lib}) + SET(ret ${ret} ${lib}) + ENDIF() + ENDFOREACH() + ENDIF() + SET(${result} ${ret} PARENT_SCOPE) +ENDFUNCTION() + +INCLUDE(CheckCCompilerFlag) + +SET(VISIBILITY_HIDDEN_FLAG) + +IF(CMAKE_C_COMPILER_ID MATCHES "SunPro") + SET(VISIBILITY_HIDDEN_FLAG "-xldscope=hidden") +ELSEIF(UNIX) + CHECK_C_COMPILER_FLAG("-fvisibility=hidden" HAVE_VISIBILITY_HIDDEN) + IF(HAVE_VISIBILITY_HIDDEN) + SET(VISIBILITY_HIDDEN_FLAG "-fvisibility=hidden") + ENDIF() +ENDIF() + +# We try to hide the symbols in bundled libraries to avoid name clashes with +# other libraries like openssl. +FUNCTION(RESTRICT_SYMBOL_EXPORTS target) + IF(VISIBILITY_HIDDEN_FLAG) + GET_TARGET_PROPERTY(COMPILE_FLAGS ${target} COMPILE_FLAGS) + IF(NOT COMPILE_FLAGS) + # Avoid COMPILE_FLAGS-NOTFOUND + SET(COMPILE_FLAGS) + ENDIF() + SET_TARGET_PROPERTIES(${target} PROPERTIES + COMPILE_FLAGS "${COMPILE_FLAGS} ${VISIBILITY_HIDDEN_FLAG}") + ENDIF() +ENDFUNCTION() + +# The MSVC /GL flag, used for link-time code generation +# creates objects files with a format not readable by tools +# i.e exporting all symbols is not possible with IPO +# To workaround this, we disable INTERPROCEDURAL_OPTIMIZATION +# for some static libraries. + +FUNCTION (MAYBE_DISABLE_IPO target) + IF(MSVC AND NOT CLANG_CL) + SET_TARGET_PROPERTIES(${target} PROPERTIES INTERPROCEDURAL_OPTIMIZATION OFF) + ENDIF() +ENDFUNCTION() diff --git a/cmake/maintainer.cmake b/cmake/maintainer.cmake new file mode 100644 index 00000000..b2b2eef9 --- /dev/null +++ b/cmake/maintainer.cmake @@ -0,0 +1,65 @@ +# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2021, MariaDB +# +# 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +IF(MSVC OR MYSQL_MAINTAINER_MODE STREQUAL "NO") + # Windows support is in cmake/os/Windows.cmake, not here + RETURN() +ENDIF() + +# Common warning flags for GCC, G++, Clang and Clang++ +SET(MY_WARNING_FLAGS + -Wall + -Wdeclaration-after-statement + -Wextra + -Wformat-security + -Wno-format-truncation + -Wno-init-self + -Wno-nonnull-compare + -Wno-null-conversion + -Wno-unused-parameter + -Wno-unused-private-field + -Woverloaded-virtual + -Wnon-virtual-dtor + -Wvla + -Wwrite-strings + ) + +FOREACH(F ${MY_WARNING_FLAGS}) + MY_CHECK_AND_SET_COMPILER_FLAG(${F} DEBUG RELWITHDEBINFO) +ENDFOREACH() + +SET(MY_ERROR_FLAGS -Werror) + +IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION VERSION_LESS "6.0.0") + SET(MY_ERROR_FLAGS ${MY_ERROR_FLAGS} -Wno-error=maybe-uninitialized) +ENDIF() + +IF(MYSQL_MAINTAINER_MODE MATCHES "OFF|WARN") + RETURN() +ELSEIF(MYSQL_MAINTAINER_MODE MATCHES "AUTO") + SET(WHERE DEBUG) +ENDIF() + +FOREACH(F ${MY_ERROR_FLAGS}) + MY_CHECK_AND_SET_COMPILER_FLAG(${F} ${WHERE}) +ENDFOREACH() + +IF(CMAKE_C_COMPILER_ID MATCHES "GNU") + STRING(REPLACE " -E " " -E -dDI " CMAKE_C_CREATE_PREPROCESSED_SOURCE ${CMAKE_C_CREATE_PREPROCESSED_SOURCE}) +ENDIF() +IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + STRING(REPLACE " -E " " -E -dDI " CMAKE_CXX_CREATE_PREPROCESSED_SOURCE ${CMAKE_CXX_CREATE_PREPROCESSED_SOURCE}) +ENDIF() diff --git a/cmake/make_dist.cmake.in b/cmake/make_dist.cmake.in new file mode 100644 index 00000000..4f6988cf --- /dev/null +++ b/cmake/make_dist.cmake.in @@ -0,0 +1,195 @@ +# Copyright (c) 2009, 2015, Oracle and/or its affiliates. +# +# 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# Make source distribution +# If bzr is present, run bzr export. +# Otherwise, just run cpack with source configuration. + +SET(CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@") +SET(CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@") +SET(CPACK_SOURCE_PACKAGE_FILE_NAME "@CPACK_SOURCE_PACKAGE_FILE_NAME@") +SET(CMAKE_CPACK_COMMAND "@CMAKE_CPACK_COMMAND@") +SET(CMAKE_COMMAND "@CMAKE_COMMAND@") +SET(GIT_EXECUTABLE "@GIT_EXECUTABLE@") +SET(GTAR_EXECUTABLE "@GTAR_EXECUTABLE@") +SET(TAR_EXECUTABLE "@TAR_EXECUTABLE@") +SET(CMAKE_GENERATOR "@CMAKE_GENERATOR@") +SET(CMAKE_MAKE_PROGRAM "@CMAKE_MAKE_PROGRAM@") +SET(CMAKE_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@") + +SET(VERSION "@VERSION@") + +SET(MYSQL_DOCS_LOCATION "@MYSQL_DOCS_LOCATION@") + + +SET(PACKAGE_DIR ${CMAKE_BINARY_DIR}/${CPACK_SOURCE_PACKAGE_FILE_NAME}) + +FILE(REMOVE_RECURSE ${PACKAGE_DIR}) +FILE(REMOVE ${PACKAGE_DIR}.tar.gz ) + +IF(GIT_EXECUTABLE) + MESSAGE(STATUS "Running git checkout-index") + EXECUTE_PROCESS( + COMMAND "${GIT_EXECUTABLE}" checkout-index --all --prefix=${PACKAGE_DIR}/ + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + RESULT_VARIABLE RESULT + ) + IF(NOT RESULT EQUAL 0) + SET(GIT_EXECUTABLE) + ENDIF() + EXECUTE_PROCESS( + COMMAND "${GIT_EXECUTABLE}" submodule foreach "${GIT_EXECUTABLE} checkout-index --all --prefix=${PACKAGE_DIR}/$path/" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + RESULT_VARIABLE RESULT + ) + IF(NOT RESULT EQUAL 0) + SET(GIT_EXECUTABLE) + ENDIF() + EXECUTE_PROCESS( + COMMAND "${GIT_EXECUTABLE}" submodule foreach "${GIT_EXECUTABLE} checkout-index --all --prefix=${PACKAGE_DIR}/wsrep-lib/$path/" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/wsrep-lib + RESULT_VARIABLE RESULT + ) + IF(NOT RESULT EQUAL 0) + SET(GIT_EXECUTABLE) + ENDIF() + EXECUTE_PROCESS( + COMMAND "${GIT_EXECUTABLE}" submodule foreach "${GIT_EXECUTABLE} checkout-index --all --prefix=${PACKAGE_DIR}/storage/columnstore/columnstore/$path/" + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/storage/columnstore/columnstore + RESULT_VARIABLE RESULT + ) + IF(NOT RESULT EQUAL 0) + SET(GIT_EXECUTABLE) + ENDIF() +ENDIF() + +CONFIGURE_FILE(${CMAKE_BINARY_DIR}/include/source_revision.h + ${PACKAGE_DIR}/include/source_revision.h COPYONLY) + +CONFIGURE_FILE(${CMAKE_BINARY_DIR}/storage/rocksdb/rdb_source_revision.h + ${PACKAGE_DIR}/storage/rocksdb/rdb_source_revision.h COPYONLY) + +IF(NOT GIT_EXECUTABLE) + MESSAGE(STATUS "git not found or source dir is not a repo, use CPack") + + IF(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR) + # In-source build is the worst option, we have to cleanup source tree. + + # Save bison output first. + CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.cc + ${CMAKE_BINARY_DIR}/sql_yacc.cc COPYONLY) + CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.hh + ${CMAKE_BINARY_DIR}/sql_yacc.hh COPYONLY) + + IF(CMAKE_GENERATOR MATCHES "Makefiles") + # make clean + EXECUTE_PROCESS( + COMMAND ${CMAKE_MAKE_PROGRAM} clean + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + ENDIF() + + # Restore bison output + CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql_yacc.cc + ${CMAKE_BINARY_DIR}/sql/sql_yacc.cc COPYONLY) + CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql_yacc.hh + ${CMAKE_BINARY_DIR}/sql/sql_yacc.h COPYONLY) + FILE(REMOVE ${CMAKE_BINARY_DIR}/sql_yacc.cc) + FILE(REMOVE ${CMAKE_BINARY_DIR}/sql_yacc.hh) + ENDIF() + + EXECUTE_PROCESS( + COMMAND ${CMAKE_CPACK_COMMAND} -G TGZ --config ./CPackSourceConfig.cmake + ${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake + + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) + EXECUTE_PROCESS( + COMMAND ${CMAKE_COMMAND} -E tar xzf + ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz + ${PACK_SOURCE_PACKAGE_FILE_NAME} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + ) +ENDIF() + +# Copy bison output +CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/yy_mariadb.hh + ${PACKAGE_DIR}/sql/yy_mariadb.hh COPYONLY) +CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/yy_mariadb.cc + ${PACKAGE_DIR}/sql/yy_mariadb.cc COPYONLY) +# Copy bison output +CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/yy_oracle.hh + ${PACKAGE_DIR}/sql/yy_oracle.hh COPYONLY) +CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/yy_oracle.cc + ${PACKAGE_DIR}/sql/yy_oracle.cc COPYONLY) + +# Add documentation, if user has specified where to find them +IF(MYSQL_DOCS_LOCATION) + MESSAGE("Copying documentation files from " ${MYSQL_DOCS_LOCATION}) + EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_directory "${MYSQL_DOCS_LOCATION}" "${PACKAGE_DIR}") +ENDIF() + +# Ensure there is an "INFO_SRC" file. +INCLUDE(${CMAKE_BINARY_DIR}/info_macros.cmake) +IF(NOT EXISTS ${PACKAGE_DIR}/Docs/INFO_SRC) + CREATE_INFO_SRC(${PACKAGE_DIR}/Docs) +ENDIF() + +# In case we used CPack, it could have copied some +# extra files that are not usable on different machines. +FILE(REMOVE ${PACKAGE_DIR}/CMakeCache.txt) + +# When packing source, prefer gnu tar to "cmake -P tar" +# cmake does not preserve timestamps.gnuwin32 tar is broken, cygwin is ok + +IF(CMAKE_SYSTEM_NAME MATCHES "Windows") + IF (EXISTS C:/cygwin/bin/tar.exe) + SET(TAR_EXECUTABLE C:/cygwin/bin/tar.exe) + ENDIF() +ENDIF() + +IF(GTAR_EXECUTABLE) + SET(GNUTAR ${GTAR_EXECUTABLE}) +ELSEIF(TAR_EXECUTABLE) + EXECUTE_PROCESS( + COMMAND "${TAR_EXECUTABLE}" --version + RESULT_VARIABLE RESULT OUTPUT_VARIABLE OUT ERROR_VARIABLE ERR + ) + IF(RESULT EQUAL 0 AND OUT MATCHES "GNU") + SET(GNUTAR ${TAR_EXECUTABLE}) + ENDIF() +ENDIF() + +SET($ENV{GZIP} "--best") + +IF(GNUTAR) + SET(PACK_COMMAND + ${GNUTAR} cfz + ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz + ${CPACK_SOURCE_PACKAGE_FILE_NAME} + ) +ELSE() + SET(PACK_COMMAND ${CMAKE_COMMAND} -E tar cfz + ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz + ${CPACK_SOURCE_PACKAGE_FILE_NAME} +) +ENDIF() + +MESSAGE(STATUS "Creating source package") + +EXECUTE_PROCESS( + COMMAND ${PACK_COMMAND} +) +MESSAGE(STATUS "Source package ${PACKAGE_DIR}.tar.gz created") diff --git a/cmake/mariadb_connector_c.cmake b/cmake/mariadb_connector_c.cmake new file mode 100644 index 00000000..a9b10334 --- /dev/null +++ b/cmake/mariadb_connector_c.cmake @@ -0,0 +1,53 @@ +SET(OPT CONC_) + +IF (CMAKE_BUILD_TYPE STREQUAL "Debug") + SET(CONC_WITH_RTC ON) +ENDIF() + +SET(CONC_WITH_SIGNCODE ${SIGNCODE}) +SET(SIGN_OPTIONS ${SIGNTOOL_PARAMETERS}) +SET(CONC_WITH_EXTERNAL_ZLIB ON) + +IF(SSL_DEFINES MATCHES "WOLFSSL") + IF(WIN32) + SET(CONC_WITH_SSL "SCHANNEL") + ELSE() + SET(CONC_WITH_SSL "GNUTLS") # that's what debian wants, right? + ENDIF() +ELSE() + SET(CONC_WITH_SSL "OPENSSL") + SET(OPENSSL_FOUND TRUE) +ENDIF() + +SET(CONC_WITH_CURL OFF) +SET(CONC_WITH_MYSQLCOMPAT ON) + +IF (INSTALL_LAYOUT STREQUAL "RPM") + SET(CONC_INSTALL_LAYOUT "RPM") +ELSEIF (INSTALL_LAYOUT STREQUAL "DEB") + SET(CONC_INSTALL_LAYOUT "DEB") +ELSE() + SET(CONC_INSTALL_LAYOUT "DEFAULT") +ENDIF() + +SET(PLUGIN_INSTALL_DIR ${INSTALL_PLUGINDIR}) +SET(MARIADB_UNIX_ADDR ${MYSQL_UNIX_ADDR}) + +SET(CLIENT_PLUGIN_PVIO_NPIPE STATIC) +SET(CLIENT_PLUGIN_PVIO_SHMEM STATIC) +SET(CLIENT_PLUGIN_PVIO_SOCKET STATIC) + +MESSAGE("== Configuring MariaDB Connector/C") +ADD_SUBDIRECTORY(libmariadb) + +IF(UNIX) + INSTALL(CODE "EXECUTE_PROCESS( + COMMAND ${CMAKE_COMMAND} -E make_directory \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR}) + EXECUTE_PROCESS( + COMMAND ${CMAKE_COMMAND} -E create_symlink mariadb_config ${INSTALL_BINDIR}/mariadb-config + WORKING_DIRECTORY \$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX})" + COMPONENT Development) +ENDIF() + +GET_DIRECTORY_PROPERTY(MARIADB_CONNECTOR_C_VERSION DIRECTORY libmariadb DEFINITION CPACK_PACKAGE_VERSION) +MESSAGE1(MARIADB_CONNECTOR_C_VERSION "MariaDB Connector/C ${MARIADB_CONNECTOR_C_VERSION}") diff --git a/cmake/merge_archives_unix.cmake b/cmake/merge_archives_unix.cmake new file mode 100644 index 00000000..a66dadda --- /dev/null +++ b/cmake/merge_archives_unix.cmake @@ -0,0 +1,34 @@ +# Copyright (c) 2020 IBM +# Use is subject to license terms. +# +# 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + + +# MRI scripts have a problem with +. It's a line contination character +# unfortunately there is no escape character. We know we don't have +# "+" in libraries or the MariaDB paths, but Ubuntu CI builds will have +# in their CI path due to the package names that Ubuntu generates. +# So here we replace the fully expanded paths in the TARGET_SCRIPT, +# strip off the TOP_DIR to make it a relative path to the top level directory +# and then execute AR on the top level directory. + +FILE(READ ${TARGET_SCRIPT} SCRIPT_CONTENTS) +STRING(REPLACE "${TOP_DIR}/" "" SCRIPT_CONTENTS_TRIMMED "${SCRIPT_CONTENTS}") +FILE(WRITE "${TARGET_SCRIPT}.mri" ${SCRIPT_CONTENTS_TRIMMED}) + +EXECUTE_PROCESS( + WORKING_DIRECTORY ${TOP_DIR} + COMMAND ${CMAKE_AR} -M + INPUT_FILE ${TARGET_SCRIPT}.mri +) diff --git a/cmake/misc.cmake b/cmake/misc.cmake new file mode 100644 index 00000000..2a0c57b1 --- /dev/null +++ b/cmake/misc.cmake @@ -0,0 +1,19 @@ +IF ("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}" VERSION_LESS "2.8.7") + FUNCTION(MESSAGE_ONCE id out) + MESSAGE(STATUS "${out}") + ENDFUNCTION() +ELSE() + FUNCTION(MESSAGE_ONCE id out) + STRING(MD5 hash "${out}") + IF(NOT __msg1_${id} STREQUAL "${hash}") + MESSAGE(STATUS "${out}") + ENDIF() + SET(__msg1_${id} ${hash} CACHE INTERNAL "") + ENDFUNCTION() +ENDIF() + +MACRO(SET_IF_UNSET VAR VAL) + IF(NOT DEFINED ${VAR}) + SET(${VAR} ${VAL}) + ENDIF() +ENDMACRO() diff --git a/cmake/mysql_add_executable.cmake b/cmake/mysql_add_executable.cmake new file mode 100644 index 00000000..426bdaf1 --- /dev/null +++ b/cmake/mysql_add_executable.cmake @@ -0,0 +1,123 @@ +# Copyright (c) 2009, 2010, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# Add executable plus some additional MySQL specific stuff +# Usage (same as for standard CMake's ADD_EXECUTABLE) +# +# MYSQL_ADD_EXECUTABLE(target source1...sourceN) +# +# MySQL specifics: +# - instruct CPack to install executable under ${CMAKE_INSTALL_PREFIX}/bin directory +# On Windows : +# - add version resource +# - instruct CPack to do autenticode signing if SIGNCODE is set + +INCLUDE(CMakeParseArguments) + +FUNCTION (MYSQL_ADD_EXECUTABLE) + # Pass-through arguments for ADD_EXECUTABLE + CMAKE_PARSE_ARGUMENTS(ARG + "WIN32;MACOSX_BUNDLE;EXCLUDE_FROM_ALL" + "DESTINATION;COMPONENT" + "" + ${ARGN} + ) + LIST(GET ARG_UNPARSED_ARGUMENTS 0 target) + LIST(REMOVE_AT ARG_UNPARSED_ARGUMENTS 0) + + SET(sources ${ARG_UNPARSED_ARGUMENTS}) + ADD_VERSION_INFO(${target} EXECUTABLE sources) + + IF(MSVC) + # Add compatibility manifest, to fix GetVersionEx on Windows 8.1 and later + IF (CMAKE_VERSION VERSION_GREATER 3.3) + SET(sources ${sources} ${PROJECT_SOURCE_DIR}/cmake/win_compatibility.manifest) + ENDIF() + ENDIF() + + IF (ARG_WIN32) + SET(WIN32 WIN32) + ELSE() + UNSET(WIN32) + ENDIF() + IF (ARG_MACOSX_BUNDLE) + SET(MACOSX_BUNDLE MACOSX_BUNDLE) + ELSE() + UNSET(MACOSX_BUNDLE) + ENDIF() + IF (ARG_EXCLUDE_FROM_ALL) + SET(EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL) + ELSE() + UNSET(EXCLUDE_FROM_ALL) + ENDIF() + + ADD_EXECUTABLE(${target} ${WIN32} ${MACOSX_BUNDLE} ${EXCLUDE_FROM_ALL} ${sources}) + + # tell CPack where to install + IF(NOT ARG_EXCLUDE_FROM_ALL) + IF(NOT ARG_DESTINATION) + SET(ARG_DESTINATION ${INSTALL_BINDIR}) + ENDIF() + IF(ARG_COMPONENT) + SET(COMP ${ARG_COMPONENT}) + ELSEIF(MYSQL_INSTALL_COMPONENT) + SET(COMP ${MYSQL_INSTALL_COMPONENT}) + ELSE() + SET(COMP Client) + ENDIF() + IF (COMP MATCHES ${SKIP_COMPONENTS}) + RETURN() + ENDIF() + + IF (WITH_STRIPPED_CLIENT AND NOT target STREQUAL mariadbd) + INSTALL(CODE "SET(CMAKE_INSTALL_DO_STRIP 1)" COMPONENT ${COMP}) + SET(reset_strip ON) + ENDIF() + + MYSQL_INSTALL_TARGETS(${target} DESTINATION ${ARG_DESTINATION} COMPONENT ${COMP}) + + IF (reset_strip) + INSTALL(CODE "SET(CMAKE_INSTALL_DO_STRIP 0)" COMPONENT ${COMP}) + ENDIF() + ENDIF() + + # create MySQL named "legacy links" + GET_SYMLINK(${target} link) + IF(link) + IF(UNIX) + ADD_CUSTOM_COMMAND(TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E create_symlink + ${target} ${link} + COMMENT "Creating ${link} link" + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}) + INSTALL(PROGRAMS + ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${link} + DESTINATION + ${ARG_DESTINATION} + COMPONENT ${COMP}) + ELSE() + # Windows note: + # Here, hardlinks are used, because cmake can't install symlinks. + # In packages, there are won't be links, just copies. + SET(link ${link}.exe) + ADD_CUSTOM_COMMAND(TARGET ${target} POST_BUILD + COMMAND cmake -E remove -f ${link} + COMMAND mklink /H ${link} $<TARGET_FILE_NAME:${target}> + COMMENT "Creating ${link} link" + WORKING_DIRECTORY $<TARGET_FILE_DIR:${target}>) + INSTALL(PROGRAMS $<TARGET_FILE_DIR:${target}>/${link} DESTINATION ${ARG_DESTINATION} COMPONENT ${COMP}) + ENDIF() + ENDIF() +ENDFUNCTION() diff --git a/cmake/mysql_version.cmake b/cmake/mysql_version.cmake new file mode 100644 index 00000000..fd8d0215 --- /dev/null +++ b/cmake/mysql_version.cmake @@ -0,0 +1,147 @@ +# Copyright (c) 2009, 2012, Oracle and/or its affiliates. +# +# 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# +# Global constants, only to be changed between major releases. +# + +SET(SHARED_LIB_MAJOR_VERSION "19") +SET(PROTOCOL_VERSION "10") +SET(DOT_FRM_VERSION "6") + +# Generate "something" to trigger cmake rerun when VERSION changes +CONFIGURE_FILE( + ${CMAKE_SOURCE_DIR}/VERSION + ${CMAKE_BINARY_DIR}/VERSION.dep +) + +# Read value for a variable from VERSION. + +MACRO(MYSQL_GET_CONFIG_VALUE keyword var) + IF(NOT ${var}) + FILE (STRINGS ${CMAKE_SOURCE_DIR}/VERSION str REGEX "^[ ]*${keyword}=") + IF(str) + STRING(REPLACE "${keyword}=" "" str ${str}) + STRING(REGEX REPLACE "[ ].*" "" str "${str}") + SET(${var} ${str}) + ENDIF() + ENDIF() +ENDMACRO() + + +# Read mysql version for configure script + +MACRO(GET_MYSQL_VERSION) + MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_MAJOR" MAJOR_VERSION) + MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_MINOR" MINOR_VERSION) + MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_PATCH" PATCH_VERSION) + MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_EXTRA" EXTRA_VERSION) + MYSQL_GET_CONFIG_VALUE("SERVER_MATURITY" SERVER_MATURITY) + +IF(NOT "${MAJOR_VERSION}" MATCHES "[0-9]+" OR + NOT "${MINOR_VERSION}" MATCHES "[0-9]+" OR + NOT "${PATCH_VERSION}" MATCHES "[0-9]+") + MESSAGE(FATAL_ERROR "VERSION file cannot be parsed.") + ENDIF() + + SET(VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}${EXTRA_VERSION}") + SET(SERVER_VERSION ${VERSION}) + MESSAGE(STATUS "MariaDB ${VERSION}") + SET(MYSQL_BASE_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}" CACHE INTERNAL "MySQL Base version") + SET(MYSQL_NO_DASH_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}") + MATH(EXPR MYSQL_VERSION_ID "10000*${MAJOR_VERSION} + 100*${MINOR_VERSION} + ${PATCH_VERSION}") + MARK_AS_ADVANCED(VERSION MYSQL_VERSION_ID MYSQL_BASE_VERSION) + SET(CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION}) + SET(CPACK_PACKAGE_VERSION_MINOR ${MINOR_VERSION}) + SET(CPACK_PACKAGE_VERSION_PATCH ${PATCH_VERSION}${EXTRA_VERSION}) +ENDMACRO() + +# Get mysql version and other interesting variables +GET_MYSQL_VERSION() + +# Maturity level +string(TOUPPER ${SERVER_MATURITY} SERVER_MATURITY) +SET(SERVER_MATURITY_LEVEL MariaDB_PLUGIN_MATURITY_${SERVER_MATURITY}) + +SET(MYSQL_TCP_PORT_DEFAULT 0) +SET_IF_UNSET(MYSQL_TCP_PORT 3306) + +SET_IF_UNSET(COMPILATION_COMMENT "Source distribution") + +INCLUDE(package_name) +IF(NOT CPACK_PACKAGE_FILE_NAME) + GET_PACKAGE_FILE_NAME(CPACK_PACKAGE_FILE_NAME) +ENDIF() + +SET_IF_UNSET(CPACK_SOURCE_PACKAGE_FILE_NAME "mariadb-${VERSION}") +SET_IF_UNSET(CPACK_PACKAGE_CONTACT "MariaDB Developers <maria-developers@lists.launchpad.net>") +SET_IF_UNSET(CPACK_PACKAGE_VENDOR "MariaDB Foundation") +SET_IF_UNSET(CPACK_PACKAGE_DESCRIPTION "${CPACK_PACKAGE_DESCRIPTION_SUMMARY} + +It is GPL v2 licensed, which means you can use the it free of charge under the +conditions of the GNU General Public License Version 2 (http://www.gnu.org/licenses/). + +MariaDB documentation can be found at https://mariadb.com/kb +MariaDB bug reports should be submitted through https://jira.mariadb.org + +") +SET(CPACK_SOURCE_GENERATOR "TGZ") + +# Definitions for windows version resources +SET(PRODUCTNAME "MariaDB Server") +SET(COMPANYNAME ${CPACK_PACKAGE_VENDOR}) + +# Windows 'date' command has unpredictable output, so cannot rely on it to +# set MYSQL_COPYRIGHT_YEAR - if someone finds a portable way to do so then +# it might be useful +#IF (WIN32) +# EXECUTE_PROCESS(COMMAND "date" "/T" OUTPUT_VARIABLE TMP_DATE) +# STRING(REGEX REPLACE "(..)/(..)/..(..).*" "\\3\\2\\1" MYSQL_COPYRIGHT_YEAR ${TMP_DATE}) +IF(UNIX) + EXECUTE_PROCESS(COMMAND "date" "+%Y" OUTPUT_VARIABLE MYSQL_COPYRIGHT_YEAR OUTPUT_STRIP_TRAILING_WHITESPACE) +ENDIF() + +# Add version information to the exe and dll files +# Refer to http://msdn.microsoft.com/en-us/library/aa381058(VS.85).aspx +# for more info. +IF(MSVC) + # Tiny version is used to identify the build, it can be set with cmake -DTINY_VERSION=<number> + # to bzr revno for example (in the CI builds) + IF(NOT TINY_VERSION) + SET(TINY_VERSION "0") + ENDIF() + + GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) + + SET(FILETYPE VFT_APP) + CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in + ${CMAKE_BINARY_DIR}/versioninfo_exe.rc) + + SET(FILETYPE VFT_DLL) + CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in + ${CMAKE_BINARY_DIR}/versioninfo_dll.rc) + + FUNCTION(ADD_VERSION_INFO target target_type sources_var) + IF("${target_type}" MATCHES "SHARED" OR "${target_type}" MATCHES "MODULE") + SET(rcfile ${CMAKE_BINARY_DIR}/versioninfo_dll.rc) + ELSEIF("${target_type}" MATCHES "EXE") + SET(rcfile ${CMAKE_BINARY_DIR}/versioninfo_exe.rc) + ENDIF() + SET(${sources_var} ${${sources_var}} ${rcfile} PARENT_SCOPE) + ENDFUNCTION() +ELSE() + FUNCTION(ADD_VERSION_INFO) + ENDFUNCTION() +ENDIF() diff --git a/cmake/numa.cmake b/cmake/numa.cmake new file mode 100644 index 00000000..0ccb560d --- /dev/null +++ b/cmake/numa.cmake @@ -0,0 +1,53 @@ +MACRO (MYSQL_CHECK_NUMA) + + STRING(TOLOWER "${WITH_NUMA}" WITH_NUMA_LOWERCASE) + + IF(NOT WITH_NUMA) + MESSAGE_ONCE(numa "WITH_NUMA=OFF: NUMA memory allocation policy disabled") + + ELSEIF(NOT WITH_NUMA_LOWERCASE STREQUAL "auto" AND NOT WITH_NUMA_LOWERCASE STREQUAL "on") + MESSAGE(FATAL_ERROR "Wrong value for WITH_NUMA") + + ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Linux") + CHECK_INCLUDE_FILES(numa.h HAVE_NUMA_H) + CHECK_INCLUDE_FILES(numaif.h HAVE_NUMAIF_H) + + IF(HAVE_NUMA_H AND HAVE_NUMAIF_H) + SET(SAVE_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) + SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} numa) + CHECK_C_SOURCE_COMPILES( + " + #include <numa.h> + #include <numaif.h> + int main() + { + struct bitmask *all_nodes= numa_all_nodes_ptr; + set_mempolicy(MPOL_DEFAULT, 0, 0); + return all_nodes != NULL; + }" + HAVE_LIBNUMA) + SET(CMAKE_REQUIRED_LIBRARIES ${SAVE_CMAKE_REQUIRED_LIBRARIES}) + IF(HAVE_LIBNUMA) + ADD_DEFINITIONS(-DHAVE_LIBNUMA=1) + SET(NUMA_LIBRARY "numa") + ENDIF() + ENDIF() + + ADD_FEATURE_INFO(NUMA HAVE_LIBNUMA "NUMA memory allocation policy") + IF(WITH_NUMA_LOWERCASE STREQUAL "auto" AND HAVE_LIBNUMA) + MESSAGE_ONCE(numa "WITH_NUMA=AUTO: NUMA memory allocation policy enabled") + ELSEIF(WITH_NUMA_LOWERCASE STREQUAL "auto" AND NOT HAVE_LIBNUMA) + MESSAGE_ONCE(numa "WITH_NUMA=AUTO: NUMA memory allocation policy disabled") + ELSEIF(HAVE_LIBNUMA) + MESSAGE_ONCE(numa "WITH_NUMA=ON: NUMA memory allocation policy enabled") + ELSE() + # Forget it in cache, abort the build. + UNSET(WITH_NUMA CACHE) + UNSET(NUMA_LIBRARY CACHE) + MESSAGE(FATAL_ERROR "WITH_NUMA=ON: Could not find NUMA headers/libraries") + ENDIF() + + ENDIF() + +ENDMACRO() + diff --git a/cmake/os/AIX.cmake b/cmake/os/AIX.cmake new file mode 100644 index 00000000..299b7919 --- /dev/null +++ b/cmake/os/AIX.cmake @@ -0,0 +1,38 @@ +# Copyright (c) 2010, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + + +#Enable 64 bit file offsets +SET(_LARGE_FILES 1) +SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> -X32_64 qc <TARGET> <LINK_FLAGS> <OBJECTS>") +SET(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> -X32_64 q <TARGET> <LINK_FLAGS> <OBJECTS>") +SET(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> -X32_64 qc <TARGET> <LINK_FLAGS> <OBJECTS>") +SET(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> -X32_64 q <TARGET> <LINK_FLAGS> <OBJECTS>") + +IF(__AIX_COMPILER_XL) +# Fix xlC oddity - it complains about same inline function defined multiple times +# in different compilation units +INCLUDE(CheckCXXCompilerFlag) + CHECK_CXX_COMPILER_FLAG("-qstaticinline" HAVE_QSTATICINLINE) + IF(HAVE_QSTATICINLINE) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qstaticinline") + ENDIF() +ELSE() + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -maix64 -pthread -mcmodel=large") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -maix64 -pthread -mcmodel=large") +ENDIF() + +# make it WARN by default, not AUTO (that implies -Werror) +SET(MYSQL_MAINTAINER_MODE "WARN" CACHE STRING "Enable MariaDB maintainer-specific warnings. One of: NO (warnings are disabled) WARN (warnings are enabled) ERR (warnings are errors) AUTO (warnings are errors in Debug only)") diff --git a/cmake/os/Cygwin.cmake b/cmake/os/Cygwin.cmake new file mode 100644 index 00000000..a5424165 --- /dev/null +++ b/cmake/os/Cygwin.cmake @@ -0,0 +1,18 @@ +# Copyright (c) 2010 Sun Microsystems, Inc. +# Use is subject to license terms. +# +# 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# Cygwin is not Windows +SET(WIN32 0)
\ No newline at end of file diff --git a/cmake/os/Darwin.cmake b/cmake/os/Darwin.cmake new file mode 100644 index 00000000..21e18360 --- /dev/null +++ b/cmake/os/Darwin.cmake @@ -0,0 +1,16 @@ +# Copyright (c) 2010, 2014, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# This file includes OSX specific options and quirks, related to system checks diff --git a/cmake/os/FreeBSD.cmake b/cmake/os/FreeBSD.cmake new file mode 100644 index 00000000..9d3673aa --- /dev/null +++ b/cmake/os/FreeBSD.cmake @@ -0,0 +1,34 @@ + +# Copyright (c) 2010, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# This file includes FreeBSD specific options and quirks, related to system checks + +# Should not be needed any more, but kept for easy resurrection if needed +# #Legacy option, maybe not needed anymore , taken as is from autotools build +# ADD_DEFINITIONS(-DNET_RETRY_COUNT=1000000) + +# The below was used for really old versions of FreeBSD, roughly: before 5.1.9 +# ADD_DEFINITIONS(-DHAVE_BROKEN_REALPATH) + +# Find libexecinfo (library that contains backtrace_symbols etc) +SET(EXECINFO_ROOT /usr/local CACHE INTERNAL "Where to find execinfo library and header") +INCLUDE_DIRECTORIES(${EXECINFO_ROOT}/include) +SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${EXECINFO_ROOT}/include) +SET(ENV{LIB} "$ENV{LIB}:${EXECINFO_ROOT}/lib") +FIND_LIBRARY(EXECINFO NAMES execinfo) +IF(EXECINFO) + SET(LIBEXECINFO ${EXECINFO}) +ENDIF() diff --git a/cmake/os/GNU.cmake b/cmake/os/GNU.cmake new file mode 100644 index 00000000..898241e6 --- /dev/null +++ b/cmake/os/GNU.cmake @@ -0,0 +1,30 @@ +# Copyright (c) 2010, 2013, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# This file includes GNU/Hurd specific options and quirks, related to system checks + +# Something that needs to be set on legacy reasons +SET(_GNU_SOURCE 1) +SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_GNU_SOURCE=1) + +# Ensure we have clean build for shared libraries +# without unresolved symbols +# Not supported with AddressSanitizer and ThreadSanitizer +IF(NOT WITH_ASAN AND NOT WITH_TSAN) + SET(LINK_FLAG_NO_UNDEFINED "-Wl,--no-undefined") +ENDIF() + +# 64 bit file offset support flag +SET(_FILE_OFFSET_BITS 64) diff --git a/cmake/os/HP-UX.cmake b/cmake/os/HP-UX.cmake new file mode 100644 index 00000000..5bbc7994 --- /dev/null +++ b/cmake/os/HP-UX.cmake @@ -0,0 +1,48 @@ +# Copyright (c) 2010 Sun Microsystems, Inc. +# Use is subject to license terms. +# +# 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +INCLUDE(CheckCXXSourceCompiles) +# Enable 64 bit file offsets +SET(_LARGEFILE64_SOURCE 1) +SET(_FILE_OFFSET_BITS 64) +# If Itanium make shared library suffix .so +# OS understands both .sl and .so. CMake would +# use .sl, however MySQL prefers .so +IF(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "9000") + SET(CMAKE_SHARED_LIBRARY_SUFFIX ".so" CACHE INTERNAL "" FORCE) + SET(CMAKE_SHARED_MODULE_SUFFIX ".so" CACHE INTERNAL "" FORCE) +ENDIF() +IF(CMAKE_SYSTEM MATCHES "11") + ADD_DEFINITIONS(-DHPUX11) +ENDIF() + +IF(CMAKE_CXX_COMPILER_ID MATCHES "HP") + # Enable standard C++ flags if required + # HP seems a bit traditional and "new" features like ANSI for-scope + # still require special flag to be set + CHECK_CXX_SOURCE_COMPILES( + "int main() + { + for(int i=0; i<1; i++); + for(int i=0; i<1; i++); + return 0; + } + " HAVE_ANSI_FOR_SCOPE) + IF(NOT HAVE_ANSI_FOR_SCOPE) + # Enable conformant behavior + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Aa") + ENDIF() +ENDIF() diff --git a/cmake/os/Linux.cmake b/cmake/os/Linux.cmake new file mode 100644 index 00000000..0ce48cc2 --- /dev/null +++ b/cmake/os/Linux.cmake @@ -0,0 +1,42 @@ + +# Copyright (c) 2010, 2013, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# This file includes Linux specific options and quirks, related to system checks + +INCLUDE(CheckSymbolExists) + +# Something that needs to be set on legacy reasons +SET(TARGET_OS_LINUX 1) +SET(_GNU_SOURCE 1) +SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_GNU_SOURCE=1) + +# Fix CMake (< 2.8) flags. -rdynamic exports too many symbols. +FOREACH(LANG C CXX) + STRING(REPLACE "-rdynamic" "" + CMAKE_SHARED_LIBRARY_LINK_${LANG}_FLAGS + "${CMAKE_SHARED_LIBRARY_LINK_${LANG}_FLAGS}" + ) +ENDFOREACH() + +# Ensure we have clean build for shared libraries +# without unresolved symbols +# Not supported with the clang sanitizers +IF(NOT WITH_ASAN AND NOT WITH_TSAN AND NOT WITH_UBSAN) + SET(LINK_FLAG_NO_UNDEFINED "-Wl,--no-undefined") +ENDIF() + +# 64 bit file offset support flag +SET(_FILE_OFFSET_BITS 64) diff --git a/cmake/os/OS400.cmake b/cmake/os/OS400.cmake new file mode 100644 index 00000000..5a9b2aba --- /dev/null +++ b/cmake/os/OS400.cmake @@ -0,0 +1,18 @@ +# Copyright (c) 2010 Sun Microsystems, Inc. +# Use is subject to license terms. +# +# 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +GET_FILENAME_COMPONENT(_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +INCLUDE(${_SCRIPT_DIR}/AIX.cmake)
\ No newline at end of file diff --git a/cmake/os/OpenBSD.cmake b/cmake/os/OpenBSD.cmake new file mode 100644 index 00000000..c8b91944 --- /dev/null +++ b/cmake/os/OpenBSD.cmake @@ -0,0 +1,22 @@ +# Copyright (C) 2012 Monty Program Ab, 2021 Brad Smith +# +# 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# This file includes OpenBSD specific options and quirks, related to system checks + +# Find libexecinfo (library that contains backtrace_symbols etc) +FIND_LIBRARY(EXECINFO NAMES execinfo) +IF(EXECINFO) + SET(LIBEXECINFO ${EXECINFO}) +ENDIF() diff --git a/cmake/os/SunOS.cmake b/cmake/os/SunOS.cmake new file mode 100644 index 00000000..3a9d2dcc --- /dev/null +++ b/cmake/os/SunOS.cmake @@ -0,0 +1,99 @@ +# Copyright (c) 2010, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +INCLUDE(CheckSymbolExists) +INCLUDE(CheckCSourceRuns) +INCLUDE(CheckCSourceCompiles) + +# Enable 64 bit file offsets +SET(_FILE_OFFSET_BITS 64) + +# Legacy option, without it my_pthread is having problems +ADD_DEFINITIONS(-DHAVE_RWLOCK_T) + +# On Solaris, use of intrinsics will screw the lib search logic +# Force using -lm, so rint etc are found. +SET(LIBM m) + +# CMake defined -lthread as thread flag. This crashes in dlopen +# when trying to load plugins workaround with -lpthread +SET(CMAKE_THREADS_LIBS_INIT -lpthread CACHE INTERNAL "" FORCE) + +# Solaris specific large page support +CHECK_SYMBOL_EXISTS(MHA_MAPSIZE_VA sys/mman.h HAVE_DECL_MHA_MAPSIZE_VA) +IF(HAVE_DECL_MHA_MAPSIZE_VA) + SET(HAVE_SOLARIS_LARGE_PAGES 1) +ENDIF() + + +# Solaris atomics +CHECK_C_SOURCE_RUNS( + " + #include <atomic.h> + int main() + { + int foo = -10; int bar = 10; + int64_t foo64 = -10; int64_t bar64 = 10; + if (atomic_add_int_nv((uint_t *)&foo, bar) || foo) + return -1; + bar = atomic_swap_uint((uint_t *)&foo, (uint_t)bar); + if (bar || foo != 10) + return -1; + bar = atomic_cas_uint((uint_t *)&bar, (uint_t)foo, 15); + if (bar) + return -1; + if (atomic_add_64_nv((volatile uint64_t *)&foo64, bar64) || foo64) + return -1; + bar64 = atomic_swap_64((volatile uint64_t *)&foo64, (uint64_t)bar64); + if (bar64 || foo64 != 10) + return -1; + bar64 = atomic_cas_64((volatile uint64_t *)&bar64, (uint_t)foo64, 15); + if (bar64) + return -1; + atomic_or_64((volatile uint64_t *)&bar64, 0); + return 0; + } +" HAVE_SOLARIS_ATOMIC) + + +# Check is special processor flag needs to be set on older GCC +#that defaults to v8 sparc . Code here is taken from my_rdtsc.h +IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_SIZEOF_VOID_P EQUAL 4 + AND CMAKE_SYSTEM_PROCESSOR MATCHES "sparc") + SET(SOURCE + " + int main() + { + long high\; + long low\; + __asm __volatile__ (\"rd %%tick,%1\; srlx %1,32,%0\" : \"=r\" ( high), \"=r\" (low))\; + return 0\; + } ") + CHECK_C_SOURCE_COMPILES(${SOURCE} HAVE_SPARC32_TICK) + IF(NOT HAVE_SPARC32_TICK) + SET(CMAKE_REQUIRED_FLAGS "-mcpu=v9") + CHECK_C_SOURCE_COMPILES(${SOURCE} HAVE_SPARC32_TICK_WITH_V9) + SET(CMAKE_REQUIRED_FLAGS) + IF(HAVE_SPARC32_TICK_WITH_V9) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=v9") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=v9") + ENDIF() + ENDIF() +ENDIF() + +IF(CMAKE_CXX_COMPILER_ID MATCHES "SunPro") + # Unnamed structs and unions + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -features=extensions") +ENDIF() diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake new file mode 100644 index 00000000..71ad4ab0 --- /dev/null +++ b/cmake/os/Windows.cmake @@ -0,0 +1,345 @@ +# Copyright (c) 2010, 2015, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# This file includes Windows specific hacks, mostly around compiler flags + +INCLUDE (CheckCSourceCompiles) +INCLUDE (CheckCXXSourceCompiles) +INCLUDE (CheckStructHasMember) +INCLUDE (CheckLibraryExists) +INCLUDE (CheckFunctionExists) +INCLUDE (CheckCSourceRuns) +INCLUDE (CheckSymbolExists) +INCLUDE (CheckTypeSize) + + +# avoid running system checks by using pre-cached check results +# system checks are expensive on VS since every tiny program is to be compiled in +# a VC solution. +GET_FILENAME_COMPONENT(_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +INCLUDE(${_SCRIPT_DIR}/WindowsCache.cmake) + + +# OS display name (version_compile_os etc). +# Used by the test suite to ignore bugs on some platforms, +IF(CMAKE_SIZEOF_VOID_P MATCHES 8) + SET(SYSTEM_TYPE "Win64") +ELSE() + SET(SYSTEM_TYPE "Win32") +ENDIF() + +# Intel compiler is almost Visual C++ +# (same compile flags etc). Set MSVC flag +IF(CMAKE_C_COMPILER MATCHES "icl") + SET(MSVC TRUE) +ENDIF() + +IF(MSVC AND CMAKE_CXX_COMPILER_ID MATCHES Clang) + SET(CLANG_CL TRUE) +ENDIF() + +ADD_DEFINITIONS(-D_WINDOWS -D__WIN__ -D_CRT_SECURE_NO_DEPRECATE) +ADD_DEFINITIONS(-D_WIN32_WINNT=0x0A00) +# We do not want the windows.h macros min/max +ADD_DEFINITIONS(-DNOMINMAX) +# Speed up build process excluding unused header files +ADD_DEFINITIONS(-DWIN32_LEAN_AND_MEAN) + +# Adjust compiler and linker flags +IF(MINGW AND CMAKE_SIZEOF_VOID_P EQUAL 4) + # mininal architecture flags, i486 enables GCC atomics + ADD_DEFINITIONS(-march=i486) +ENDIF() + +MACRO(ENABLE_SANITIZERS) + IF(NOT MSVC) + MESSAGE(FATAL_ERROR "clang-cl or MSVC necessary to enable asan/ubsan") + ENDIF() + # currently, asan is broken with static CRT. + IF(CLANG_CL AND NOT(MSVC_CRT_TYPE STREQUAL "/MD")) + SET(MSVC_CRT_TYPE "/MD" CACHE INTERNAL "" FORCE) + ENDIF() + IF(CMAKE_SIZEOF_VOID_P EQUAL 4) + SET(ASAN_ARCH i386) + ELSE() + SET(ASAN_ARCH x86_64) + ENDIF() + + # After installation, clang lib directory should be added to PATH + # (e.g C:/Program Files/LLVM/lib/clang/5.0.1/lib/windows) + SET(SANITIZER_LIBS) + SET(SANITIZER_LINK_LIBRARIES) + SET(SANITIZER_COMPILE_FLAGS) + IF(WITH_ASAN) + IF(CLANG_CL) + LIST(APPEND SANITIZER_LIBS + clang_rt.asan_dynamic-${ASAN_ARCH}.lib clang_rt.asan_dynamic_runtime_thunk-${ASAN_ARCH}.lib) + ENDIF() + STRING(APPEND SANITIZER_COMPILE_FLAGS " -fsanitize=address") + ENDIF() + IF(WITH_UBSAN) + STRING(APPEND SANITIZER_COMPILE_FLAGS " -fsanitize=undefined -fno-sanitize=alignment") + ENDIF() + FOREACH(lib ${SANITIZER_LIBS}) + FIND_LIBRARY(${lib}_fullpath ${lib}) + IF(NOT ${lib}_fullpath) + MESSAGE(FATAL_ERROR "Can't enable sanitizer : missing ${lib}") + ENDIF() + LIST(APPEND CMAKE_REQUIRED_LIBRARIES ${${lib}_fullpath}) + STRING(APPEND CMAKE_C_STANDARD_LIBRARIES " \"${${lib}_fullpath}\" ") + STRING(APPEND CMAKE_CXX_STANDARD_LIBRARIES " \"${${lib}_fullpath}\" ") + ENDFOREACH() + STRING(APPEND CMAKE_C_FLAGS ${SANITIZER_COMPILE_FLAGS}) + STRING(APPEND CMAKE_CXX_FLAGS ${SANITIZER_COMPILE_FLAGS}) +ENDMACRO() + + +IF(MSVC) + IF(MSVC_VERSION LESS 1920) + MESSAGE(FATAL_ERROR "Visual Studio q2019 or later is required") + ENDIF() + # Disable mingw based pkg-config found in Strawberry perl + SET(PKG_CONFIG_EXECUTABLE 0 CACHE INTERNAL "") + + SET(MSVC_CRT_TYPE /MT CACHE STRING + "Runtime library - specify runtime library for linking (/MT,/MTd,/MD,/MDd)" + ) + SET(VALID_CRT_TYPES /MTd /MDd /MD /MT) + IF (NOT ";${VALID_CRT_TYPES};" MATCHES ";${MSVC_CRT_TYPE};") + MESSAGE(FATAL_ERROR "Invalid value ${MSVC_CRT_TYPE} for MSVC_CRT_TYPE, choose one of /MT,/MTd,/MD,/MDd ") + ENDIF() + + IF(MSVC_CRT_TYPE MATCHES "/MD") + # Dynamic runtime (DLLs), need to install CRT libraries. + SET(CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT VCCRT) + SET(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS TRUE) + IF(MSVC_CRT_TYPE STREQUAL "/MDd") + SET (CMAKE_INSTALL_DEBUG_LIBRARIES_ONLY TRUE) + ENDIF() + INCLUDE(InstallRequiredSystemLibraries) + ENDIF() + + IF(WITH_ASAN AND (NOT CLANG_CL)) + SET(DYNAMIC_UCRT_LINK_DEFAULT OFF) + ELSE() + SET(DYNAMIC_UCRT_LINK_DEFAULT ON) + ENDIF() + + OPTION(DYNAMIC_UCRT_LINK "Link Universal CRT dynamically, if MSVC_CRT_TYPE=/MT" ${DYNAMIC_UCRT_LINK_DEFAULT}) + SET(DYNAMIC_UCRT_LINKER_OPTION " /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib") + + # Enable debug info also in Release build, + # and create PDB to be able to analyze crashes. + FOREACH(type EXE SHARED MODULE) + SET(CMAKE_${type}_LINKER_FLAGS_RELEASE + "${CMAKE_${type}_LINKER_FLAGS_RELEASE} /debug") + SET(CMAKE_${type}_LINKER_FLAGS_MINSIZEREL + "${CMAKE_${type}_LINKER_FLAGS_MINSIZEREL} /debug") + ENDFOREACH() + + # Force runtime libraries + # Compile with /Zi to get debugging information + + FOREACH(lang C CXX) + SET(CMAKE_${lang}_FLAGS_RELEASE "${CMAKE_${lang}_FLAGS_RELEASE} /Zi") + ENDFOREACH() + FOREACH(flag + CMAKE_C_FLAGS CMAKE_CXX_FLAGS + CMAKE_C_FLAGS_INIT CMAKE_CXX_FLAGS_INIT + CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO + CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG_INIT + CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO + CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG_INIT + CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL + ) + STRING(REGEX REPLACE "/M[TD][d]?" "${MSVC_CRT_TYPE}" "${flag}" "${${flag}}" ) + STRING(REPLACE "/ZI " "/Zi " "${flag}" "${${flag}}") + IF((NOT "${${flag}}" MATCHES "/Zi") AND (NOT "${${flag}}" MATCHES "/Z7")) + STRING(APPEND ${flag} " /Zi") + ENDIF() + ENDFOREACH() + + IF(WITH_ASAN OR WITH_UBSAN) + # Workaround something Linux specific + SET(SECURITY_HARDENED 0 CACHE INTERNAL "" FORCE) + ENABLE_SANITIZERS() + ENDIF() + + IF(CLANG_CL) + SET(CLANG_CL_FLAGS +"-Wno-unknown-warning-option -Wno-unused-private-field \ +-Wno-unused-parameter -Wno-inconsistent-missing-override \ +-Wno-unused-command-line-argument -Wno-pointer-sign \ +-Wno-deprecated-register -Wno-missing-braces \ +-Wno-unused-function -Wno-unused-local-typedef -msse4.2 " + ) + IF(CMAKE_SIZEOF_VOID_P MATCHES 8) + STRING(APPEND CLANG_CL_FLAGS "-mpclmul ") + ENDIF() + STRING(APPEND CMAKE_C_FLAGS " ${CLANG_CL_FLAGS} ${MSVC_CRT_TYPE}") + STRING(APPEND CMAKE_CXX_FLAGS " ${CLANG_CL_FLAGS} ${MSVC_CRT_TYPE}") + ENDIF() + + FOREACH(type EXE SHARED MODULE) + STRING(REGEX REPLACE "/STACK:([^ ]+)" "" CMAKE_${type}_LINKER_FLAGS "${CMAKE_${type}_LINKER_FLAGS}") + IF(WITH_ASAN) + SET(build_types RELWITHDEBINFO DEBUG) + ELSE() + SET(build_types RELWITHDEBINFO) + ENDIF() + FOREACH(btype ${build_types}) + STRING(REGEX REPLACE "/INCREMENTAL:([^ ]+)" "/INCREMENTAL:NO" CMAKE_${type}_LINKER_FLAGS_${btype} "${CMAKE_${type}_LINKER_FLAGS_${btype}}") + STRING(REGEX REPLACE "/INCREMENTAL$" "/INCREMENTAL:NO" CMAKE_${type}_LINKER_FLAGS_${btype} "${CMAKE_${type}_LINKER_FLAGS_${btype}}") + ENDFOREACH() + IF(NOT CLANG_CL) + STRING(APPEND CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO " /release /OPT:REF,ICF") + ENDIF() + IF(DYNAMIC_UCRT_LINK AND (MSVC_CRT_TYPE STREQUAL "/MT")) + FOREACH(config RELEASE RELWITHDEBINFO DEBUG MINSIZEREL) + STRING(APPEND CMAKE_${type}_LINKER_FLAGS_${config} ${DYNAMIC_UCRT_LINKER_OPTION}) + ENDFOREACH() + ENDIF() + ENDFOREACH() + + + # Mark 32 bit executables large address aware so they can + # use > 2GB address space + IF(CMAKE_SIZEOF_VOID_P MATCHES 4) + STRING(APPEND CMAKE_EXE_LINKER_FLAGS " /LARGEADDRESSAWARE") + ENDIF() + + # Speed up multiprocessor build + IF (NOT CLANG_CL) + STRING(APPEND CMAKE_C_FLAGS " /MP") + STRING(APPEND CMAKE_CXX_FLAGS " /MP") + STRING(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " /Gw") + STRING(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " /Gw") + ENDIF() + + #TODO: update the code and remove the disabled warnings + STRING(APPEND CMAKE_C_FLAGS " /we4700 /we4311 /we4477 /we4302 /we4090") + STRING(APPEND CMAKE_CXX_FLAGS " /we4099 /we4700 /we4311 /we4477 /we4302 /we4090") + IF(MSVC_VERSION GREATER 1910 AND NOT CLANG_CL) + STRING(APPEND CMAKE_CXX_FLAGS " /permissive-") + STRING(APPEND CMAKE_C_FLAGS " /diagnostics:caret") + STRING(APPEND CMAKE_CXX_FLAGS " /diagnostics:caret") + ENDIF() + ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_WARNINGS) + IF(MYSQL_MAINTAINER_MODE MATCHES "ERR") + STRING(APPEND CMAKE_C_FLAGS " /WX") + STRING(APPEND CMAKE_CXX_FLAGS " /WX") + FOREACH(type EXE SHARED MODULE) + FOREACH(cfg RELEASE DEBUG RELWITHDEBINFO) + SET(CMAKE_${type}_LINKER_FLAGS_${cfg} "${CMAKE_${type}_LINKER_FLAGS_${cfg}} /WX") + ENDFOREACH() + ENDFOREACH() + ENDIF() + IF(MSVC_VERSION LESS 1910) + # Noisy warning C4800: 'type': forcing value to bool 'true' or 'false' (performance warning), + # removed in VS2017 + STRING(APPEND CMAKE_CXX_FLAGS " /wd4800") + ELSEIF (NOT CLANG_CL) + STRING(APPEND CMAKE_CXX_FLAGS " /d2OptimizeHugeFunctions") + ENDIF() +ENDIF() + +# Always link with socket/synchronization libraries +STRING(APPEND CMAKE_C_STANDARD_LIBRARIES " ws2_32.lib synchronization.lib") +STRING(APPEND CMAKE_CXX_STANDARD_LIBRARIES " ws2_32.lib synchronization.lib") + +# System checks +SET(SIGNAL_WITH_VIO_CLOSE 1) # Something that runtime team needs + +# IPv6 constants appeared in Vista SDK first. We need to define them in any case if they are +# not in headers, to handle dual mode sockets correctly. +CHECK_SYMBOL_EXISTS(IPPROTO_IPV6 "winsock2.h" HAVE_IPPROTO_IPV6) +IF(NOT HAVE_IPPROTO_IPV6) + SET(HAVE_IPPROTO_IPV6 41) +ENDIF() +CHECK_SYMBOL_EXISTS(IPV6_V6ONLY "winsock2.h;ws2ipdef.h" HAVE_IPV6_V6ONLY) +IF(NOT HAVE_IPV6_V6ONLY) + SET(IPV6_V6ONLY 27) +ENDIF() + +# Some standard functions exist there under different +# names (e.g popen is _popen or strok_r is _strtok_s) +# If a replacement function exists, HAVE_FUNCTION is +# defined to 1. CMake variable <function_name> will also +# be defined to the replacement name. +# So for example, CHECK_FUNCTION_REPLACEMENT(popen _popen) +# will define HAVE_POPEN to 1 and set variable named popen +# to _popen. If the header template, one needs to have +# cmakedefine popen @popen@ which will expand to +# define popen _popen after CONFIGURE_FILE + +MACRO(CHECK_FUNCTION_REPLACEMENT function replacement) + STRING(TOUPPER ${function} function_upper) + CHECK_FUNCTION_EXISTS(${function} HAVE_${function_upper}) + IF(NOT HAVE_${function_upper}) + CHECK_FUNCTION_EXISTS(${replacement} HAVE_${replacement}) + IF(HAVE_${replacement}) + SET(HAVE_${function_upper} 1 ) + SET(${function} ${replacement}) + ENDIF() + ENDIF() +ENDMACRO() +MACRO(CHECK_SYMBOL_REPLACEMENT symbol replacement header) + STRING(TOUPPER ${symbol} symbol_upper) + CHECK_SYMBOL_EXISTS(${symbol} ${header} HAVE_${symbol_upper}) + IF(NOT HAVE_${symbol_upper}) + CHECK_SYMBOL_EXISTS(${replacement} ${header} HAVE_${replacement}) + IF(HAVE_${replacement}) + SET(HAVE_${symbol_upper} 1) + SET(${symbol} ${replacement}) + ENDIF() + ENDIF() +ENDMACRO() + +CHECK_SYMBOL_REPLACEMENT(S_IROTH _S_IREAD sys/stat.h) +CHECK_SYMBOL_REPLACEMENT(S_IFIFO _S_IFIFO sys/stat.h) +CHECK_SYMBOL_REPLACEMENT(SIGQUIT SIGTERM signal.h) +CHECK_SYMBOL_REPLACEMENT(SIGPIPE SIGINT signal.h) +CHECK_FUNCTION_REPLACEMENT(popen _popen) +CHECK_FUNCTION_REPLACEMENT(pclose _pclose) +CHECK_FUNCTION_REPLACEMENT(access _access) +CHECK_FUNCTION_REPLACEMENT(strcasecmp _stricmp) +CHECK_FUNCTION_REPLACEMENT(strncasecmp _strnicmp) +CHECK_SYMBOL_REPLACEMENT(snprintf _snprintf stdio.h) +CHECK_FUNCTION_REPLACEMENT(strtok_r strtok_s) +CHECK_FUNCTION_REPLACEMENT(strtoll _strtoi64) +CHECK_FUNCTION_REPLACEMENT(strtoull _strtoui64) +CHECK_FUNCTION_REPLACEMENT(vsnprintf _vsnprintf) +CHECK_TYPE_SIZE(ssize_t SIZE_OF_SSIZE_T) +IF(NOT HAVE_SIZE_OF_SSIZE_T) + SET(ssize_t SSIZE_T) +ENDIF() + +SET(FN_NO_CASE_SENSE 1) +SET(USE_SYMDIR 1) + +# Force static C runtime for targets in current directory +# (useful to get rid of MFC dll's dependency, or in installer) +MACRO(FORCE_STATIC_CRT) + FOREACH(flag + CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO + CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG_INIT + CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO + CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG_INIT + CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL + ) + STRING(REGEX REPLACE "/MD[d]?" "/MT" "${flag}" "${${flag}}" ) + STRING(REPLACE "${DYNAMIC_UCRT_LINKER_OPTION}" "" "${flag}" "${${flag}}") + ENDFOREACH() +ENDMACRO() diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake new file mode 100644 index 00000000..e2a4aa9e --- /dev/null +++ b/cmake/os/WindowsCache.cmake @@ -0,0 +1,342 @@ +# Copyright (c) 2010, 2014, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# Avoid system checks on Windows by pre-caching results. Most of the system checks +# are not relevant for Windows anyway and it takes lot more time to run them, +# since CMake to creates a Visual Studio project for each tiny test. +# Note that only we cache values on VC++ only, MinGW would give slightly +# different results. + +IF(MSVC) +SET(BFD_H_EXISTS 0 CACHE INTERNAL "") +SET(HAVE_ACCESS 1 CACHE INTERNAL "") +SET(HAVE_ALARM CACHE INTERNAL "") +SET(HAVE_ALLOCA_H CACHE INTERNAL "") +SET(HAVE_ARPA_INET_H CACHE INTERNAL "") +SET(HAVE_BACKTRACE CACHE INTERNAL "") +SET(HAVE_BACKTRACE_SYMBOLS CACHE INTERNAL "") +SET(HAVE_BACKTRACE_SYMBOLS_FD CACHE INTERNAL "") +SET(HAVE_BFILL CACHE INTERNAL "") +SET(HAVE_BSD_SIGNALS CACHE INTERNAL "") +SET(HAVE_CLOCK_GETTIME CACHE INTERNAL "") +SET(HAVE_COMPRESS CACHE INTERNAL "") +SET(HAVE_CRYPT CACHE INTERNAL "") +SET(HAVE_CRYPT_H CACHE INTERNAL "") +SET(HAVE_CUSERID CACHE INTERNAL "") +SET(HAVE_DECL_MADVISE CACHE INTERNAL "") +SET(HAVE_DIRENT_H CACHE INTERNAL "") +SET(HAVE_DLERROR CACHE INTERNAL "") +SET(HAVE_DLFCN_H CACHE INTERNAL "") +SET(HAVE_DLOPEN CACHE INTERNAL "") +SET(HAVE_EXECINFO_H CACHE INTERNAL "") +SET(HAVE_FCHMOD CACHE INTERNAL "") +SET(HAVE_FCNTL CACHE INTERNAL "") +SET(HAVE_FCNTL_H 1 CACHE INTERNAL "") +SET(HAVE_FCNTL_NONBLOCK CACHE INTERNAL "") +SET(HAVE_FDATASYNC CACHE INTERNAL "") +SET(HAVE_DECL_FDATASYNC CACHE INTERNAL "") +SET(HAVE_FEDISABLEEXCEPT CACHE INTERNAL "") +SET(HAVE_FENV_H CACHE INTERNAL "") +SET(HAVE_FESETROUND CACHE INTERNAL "") +SET(HAVE_FLOAT_H 1 CACHE INTERNAL "") +SET(HAVE_FNMATCH_H CACHE INTERNAL "") +SET(HAVE_FPU_CONTROL_H CACHE INTERNAL "") +SET(HAVE_FSEEKO CACHE INTERNAL "") +SET(HAVE_FSYNC CACHE INTERNAL "") +SET(HAVE_FTIME 1 CACHE INTERNAL "") +SET(HAVE_FTRUNCATE CACHE INTERNAL "") +SET(HAVE_GETIFADDRS CACHE INTERNAL "") +SET(HAVE_GETCWD 1 CACHE INTERNAL "") +SET(HAVE_GETHOSTBYADDR_R CACHE INTERNAL "") +SET(HAVE_GETHRTIME CACHE INTERNAL "") +SET(HAVE_GETPAGESIZE CACHE INTERNAL "") +SET(HAVE_GETPASS CACHE INTERNAL "") +SET(HAVE_GETPASSPHRASE CACHE INTERNAL "") +SET(HAVE_GETPWNAM CACHE INTERNAL "") +SET(HAVE_GETPWUID CACHE INTERNAL "") +SET(HAVE_GETRLIMIT CACHE INTERNAL "") +SET(HAVE_GETRUSAGE CACHE INTERNAL "") +SET(HAVE_GETTIMEOFDAY CACHE INTERNAL "") +SET(HAVE_GETWD CACHE INTERNAL "") +SET(HAVE_GMTIME_R 1 CACHE INTERNAL "") +SET(HAVE_GRP_H CACHE INTERNAL "") +SET(HAVE_IA64INTRIN_H CACHE INTERNAL "") +SET(HAVE_IEEEFP_H CACHE INTERNAL "") +SET(HAVE_INDEX CACHE INTERNAL "") +SET(HAVE_INITGROUPS CACHE INTERNAL "") +SET(HAVE_INTTYPES_H CACHE INTERNAL "") +SET(HAVE_IPPROTO_IPV6 CACHE INTERNAL "") +SET(HAVE_IPV6 TRUE CACHE INTERNAL "") +SET(HAVE_IPV6_V6ONLY 1 CACHE INTERNAL "") +SET(HAVE_LANGINFO_H CACHE INTERNAL "") +SET(HAVE_LDIV 1 CACHE INTERNAL "") +SET(HAVE_LIMITS_H 1 CACHE INTERNAL "") +SET(HAVE_LINUX_MMAN_H CACHE INTERNAL "") +SET(HAVE_LOCALE_H 1 CACHE INTERNAL "") +SET(HAVE_LOCALTIME_R 1 CACHE INTERNAL "") +SET(HAVE_LRAND48 CACHE INTERNAL "") +SET(HAVE_LSTAT CACHE INTERNAL "") +SET(HAVE_MADVISE CACHE INTERNAL "") +SET(HAVE_MALLINFO CACHE INTERNAL "") +SET(HAVE_MALLINFO2 CACHE INTERNAL "") +SET(HAVE_MALLOC_H 1 CACHE INTERNAL "") +SET(HAVE_MALLOC_ZONE CACHE INTERNAL "") +SET(HAVE_MEMALIGN CACHE INTERNAL "") +SET(HAVE_MEMCPY 1 CACHE INTERNAL "") +SET(HAVE_MEMMOVE 1 CACHE INTERNAL "") +SET(HAVE_MEMORY_H 1 CACHE INTERNAL "") +SET(HAVE_MKSTEMP CACHE INTERNAL "") +SET(HAVE_MKOSTEMP CACHE INTERNAL "") +SET(HAVE_MLOCK CACHE INTERNAL "") +SET(HAVE_MLOCKALL CACHE INTERNAL "") +SET(HAVE_MMAP CACHE INTERNAL "") +SET(HAVE_MMAP64 CACHE INTERNAL "") +SET(HAVE_NETDB_H CACHE INTERNAL "") +SET(HAVE_NETINET_IN6_H CACHE INTERNAL "") +SET(HAVE_NETINET_IN_H CACHE INTERNAL "") +SET(HAVE_NL_LANGINFO CACHE INTERNAL "") +SET(HAVE_PASE_ENVIRONMENT CACHE INTERNAL "") +SET(HAVE_PATHS_H CACHE INTERNAL "") +SET(HAVE_PCLOSE CACHE INTERNAL "") +SET(HAVE_PERROR 1 CACHE INTERNAL "") +SET(HAVE_PEERCRED CACHE INTERNAL "") +SET(HAVE_PAM_APPL_H CACHE INTERNAL "") +SET(HAVE_POLL_H CACHE INTERNAL "") +SET(HAVE_POPEN CACHE INTERNAL "") +SET(HAVE_POLL CACHE INTERNAL "") +SET(HAVE_POSIX_FALLOCATE CACHE INTERNAL "") +SET(HAVE_POSIX_SIGNALS CACHE INTERNAL "") +SET(HAVE_PREAD CACHE INTERNAL "") +SET(HAVE_PRINTSTACK CACHE INTERNAL "") +SET(HAVE_PTHREAD_ATTR_CREATE CACHE INTERNAL "") +SET(HAVE_PTHREAD_ATTR_GETSTACKSIZE CACHE INTERNAL "") +SET(HAVE_PTHREAD_ATTR_SETSCOPE CACHE INTERNAL "") +SET(HAVE_PTHREAD_ATTR_SETSTACKSIZE CACHE INTERNAL "") +SET(HAVE_PTHREAD_CONDATTR_CREATE CACHE INTERNAL "") +SET(HAVE_PTHREAD_GETAFFINITY_NP CACHE INTERNAL "") +SET(HAVE_PTHREAD_INIT CACHE INTERNAL "") +SET(HAVE_PTHREAD_KEY_DELETE CACHE INTERNAL "") +SET(HAVE_PTHREAD_RWLOCK_RDLOCK CACHE INTERNAL "") +SET(HAVE_PTHREAD_SIGMASK CACHE INTERNAL "") +SET(HAVE_PTHREAD_YIELD_NP CACHE INTERNAL "") +SET(HAVE_PTHREAD_YIELD_ZERO_ARG CACHE INTERNAL "") +SET(HAVE_PUTENV 1 CACHE INTERNAL "") +SET(HAVE_PWD_H CACHE INTERNAL "") +SET(HAVE_READDIR_R CACHE INTERNAL "") +SET(HAVE_READLINK CACHE INTERNAL "") +SET(HAVE_READ_REAL_TIME CACHE INTERNAL "") +SET(HAVE_REALPATH CACHE INTERNAL "") +SET(HAVE_RENAME 1 CACHE INTERNAL "") +SET(HAVE_RWLOCK_INIT CACHE INTERNAL "") +SET(HAVE_SCHED_H CACHE INTERNAL "") +SET(HAVE_SCHED_YIELD CACHE INTERNAL "") +SET(HAVE_SELECT 1 CACHE INTERNAL "") +SET(HAVE_SELECT_H CACHE INTERNAL "") +SET(HAVE_SETENV CACHE INTERNAL "") +SET(HAVE_SETLOCALE 1 CACHE INTERNAL "") +SET(HAVE_SIGACTION CACHE INTERNAL "") +SET(HAVE_SIGINT 1 CACHE INTERNAL "") +SET(HAVE_SIGPIPE CACHE INTERNAL "") +SET(HAVE_SIGQUIT CACHE INTERNAL "") +SET(HAVE_SIGSET CACHE INTERNAL "") +SET(HAVE_SIGTERM 1 CACHE INTERNAL "") +SET(HAVE_SIGTHREADMASK CACHE INTERNAL "") +SET(HAVE_SIGWAIT CACHE INTERNAL "") +SET(HAVE_SIGWAITINFO CACHE INTERNAL "") +SET(HAVE_SIZEOF_CHARP TRUE CACHE INTERNAL "") +SET(SIZEOF_CHARP ${CMAKE_SIZEOF_VOID_P} CACHE INTERNAL "") +SET(HAVE_SIZEOF_IN6_ADDR TRUE CACHE INTERNAL "") +SET(HAVE_SIZEOF_INT TRUE CACHE INTERNAL "") +SET(SIZEOF_INT 4 CACHE INTERNAL "") +SET(HAVE_SIZEOF_INT16 FALSE CACHE INTERNAL "") +SET(HAVE_SIZEOF_INT32 FALSE CACHE INTERNAL "") +SET(HAVE_SIZEOF_INT64 FALSE CACHE INTERNAL "") +SET(HAVE_SIZEOF_INT8 FALSE CACHE INTERNAL "") +SET(HAVE_SIZEOF_LONG TRUE CACHE INTERNAL "") +SET(SIZEOF_LONG 4 CACHE INTERNAL "") +SET(HAVE_SIZEOF_LONG_LONG TRUE CACHE INTERNAL "") +SET(SIZEOF_LONG_LONG 8 CACHE INTERNAL "") +SET(HAVE_SIZEOF_MODE_T FALSE CACHE INTERNAL "") +SET(HAVE_SIZEOF_OFF_T TRUE CACHE INTERNAL "") +SET(SIZEOF_OFF_T 4 CACHE INTERNAL "") +SET(HAVE_SIZEOF_SIGSET_T FALSE CACHE INTERNAL "") +SET(HAVE_SIZEOF_SIZE_T TRUE CACHE INTERNAL "") +SET(SIZEOF_SIZE_T ${CMAKE_SIZEOF_VOID_P} CACHE INTERNAL "") +SET(HAVE_SIZEOF_SOCKADDR_IN6 TRUE CACHE INTERNAL "") +SET(HAVE_SIZEOF_UCHAR FALSE CACHE INTERNAL "") +SET(HAVE_SIZEOF_UINT FALSE CACHE INTERNAL "") +SET(HAVE_SIZEOF_UINT16 FALSE CACHE INTERNAL "") +SET(HAVE_SIZEOF_UINT32 FALSE CACHE INTERNAL "") +SET(HAVE_SIZEOF_UINT64 FALSE CACHE INTERNAL "") +SET(HAVE_SIZEOF_UINT8 FALSE CACHE INTERNAL "") +SET(HAVE_SIZEOF_ULONG FALSE CACHE INTERNAL "") +SET(HAVE_SIZE_OF_SSIZE_T FALSE CACHE INTERNAL "") +SET(HAVE_SLEEP CACHE INTERNAL "") +SET(HAVE_SOCKADDR_STORAGE_SS_FAMILY 1 CACHE INTERNAL "") +SET(HAVE_SOLARIS_STYLE_GETHOST CACHE INTERNAL "") +SET(STACK_DIRECTION -1 CACHE INTERNAL "") +SET(HAVE_STDARG_H 1 CACHE INTERNAL "") +SET(HAVE_STDDEF_H 1 CACHE INTERNAL "") +SET(HAVE_STDINT_H CACHE INTERNAL "") +SET(HAVE_STDLIB_H 1 CACHE INTERNAL "") +SET(HAVE_STPCPY CACHE INTERNAL "") +SET(HAVE_STRCASECMP CACHE INTERNAL "") +SET(HAVE_STRCOLL 1 CACHE INTERNAL "") +SET(HAVE_STRERROR 1 CACHE INTERNAL "") +SET(HAVE_STRINGS_H CACHE INTERNAL "") +SET(HAVE_STRING_H 1 CACHE INTERNAL "") +SET(HAVE_STRNDUP CACHE INTERNAL "") +SET(HAVE_STRNLEN 1 CACHE INTERNAL "") +SET(HAVE_STRPBRK 1 CACHE INTERNAL "") +SET(HAVE_STRTOK_R CACHE INTERNAL "") +SET(HAVE_STRTOLL CACHE INTERNAL "") +SET(HAVE_STRTOUL 1 CACHE INTERNAL "") +SET(HAVE_STRTOULL CACHE INTERNAL "") +SET(HAVE_SYNCH_H CACHE INTERNAL "") +SET(HAVE_SYSENT_H CACHE INTERNAL "") +SET(HAVE_SYS_DIR_H CACHE INTERNAL "") +SET(HAVE_SYS_EVENT_H CACHE INTERNAL "") +SET(HAVE_SYS_ERRLIST CACHE INTERNAL "") +SET(HAVE_SYS_FILE_H CACHE INTERNAL "") +SET(HAVE_SYS_FPU_H CACHE INTERNAL "") +SET(HAVE_SYS_IOCTL_H CACHE INTERNAL "") +SET(HAVE_SYS_MALLOC_H CACHE INTERNAL "") +SET(HAVE_SYS_MMAN_H CACHE INTERNAL "") +SET(HAVE_SYS_PARAM_H CACHE INTERNAL "") +SET(HAVE_SYS_PRCTL_H CACHE INTERNAL "") +SET(HAVE_SYS_PTEM_H CACHE INTERNAL "") +SET(HAVE_SYS_PTE_H CACHE INTERNAL "") +SET(HAVE_SYS_RESOURCE_H CACHE INTERNAL "") +SET(HAVE_SYS_SELECT_H CACHE INTERNAL "") +SET(HAVE_SYS_SOCKIO_H CACHE INTERNAL "") +SET(HAVE_SYS_SOCKET_H CACHE INTERNAL "") +SET(HAVE_SYS_STAT_H 1 CACHE INTERNAL "") +SET(HAVE_SYS_STREAM_H CACHE INTERNAL "") +SET(HAVE_SYS_TIMEB_H 1 CACHE INTERNAL "") +SET(HAVE_SYS_TIMES_H CACHE INTERNAL "") +SET(HAVE_SYS_TIME_H CACHE INTERNAL "") +SET(HAVE_SYS_TYPES_H 1 CACHE INTERNAL "") +SET(HAVE_SYS_UN_H CACHE INTERNAL "") +SET(HAVE_SYS_UTIME_H 1 CACHE INTERNAL "") +SET(HAVE_SYS_VADVISE_H CACHE INTERNAL "") +SET(HAVE_SYS_WAIT_H CACHE INTERNAL "") +SET(HAVE_TCGETATTR CACHE INTERNAL "") +SET(HAVE_TELL 1 CACHE INTERNAL "") +SET(HAVE_TERMCAP_H CACHE INTERNAL "") +SET(HAVE_TERMIOS_H CACHE INTERNAL "") +SET(HAVE_TERMIO_H CACHE INTERNAL "") +SET(HAVE_TERM_H CACHE INTERNAL "") +SET(HAVE_THR_SETCONCURRENCY CACHE INTERNAL "") +SET(HAVE_THR_YIELD CACHE INTERNAL "") +SET(HAVE_TIME 1 CACHE INTERNAL "") +SET(HAVE_TIMES CACHE INTERNAL "") +SET(HAVE_TIMESPEC_TS_SEC CACHE INTERNAL "") +SET(HAVE_TIME_H 1 CACHE INTERNAL "") +SET(HAVE_TZNAME 1 CACHE INTERNAL "") +SET(HAVE_UNISTD_H CACHE INTERNAL "") +SET(HAVE_UTIME_H CACHE INTERNAL "") +SET(HAVE_VARARGS_H 1 CACHE INTERNAL "") +SET(HAVE_VASPRINTF CACHE INTERNAL "") +SET(HAVE_VSNPRINTF 1 CACHE INTERNAL "") +SET(HAVE_WEAK_SYMBOL CACHE INTERNAL "") +SET(HAVE_ATTRIBUTE_CLEANUP CACHE INTERNAL "") +SET(HAVE_WORDS_BIGENDIAN TRUE CACHE INTERNAL "") +SET(WORDS_BIGENDIAN CACHE INTERNAL "") +SET(HAVE__S_IFIFO 1 CACHE INTERNAL "") +SET(HAVE__S_IREAD 1 CACHE INTERNAL "") +SET(HAVE__finite 1 CACHE INTERNAL "") +SET(HAVE__pclose 1 CACHE INTERNAL "") +SET(HAVE__popen 1 CACHE INTERNAL "") +SET(HAVE__stricmp 1 CACHE INTERNAL "") +SET(HAVE__strnicmp 1 CACHE INTERNAL "") +SET(HAVE__strtoi64 1 CACHE INTERNAL "") +SET(HAVE__strtoui64 1 CACHE INTERNAL "") +SET(HAVE_strtok_s 1 CACHE INTERNAL "") +SET(STDC_HEADERS CACHE 1 INTERNAL "") +SET(TIME_WITH_SYS_TIME CACHE INTERNAL "") +SET(TIME_T_UNSIGNED 1 CACHE INTERNAL "") +SET(TIOCSTAT_IN_SYS_IOCTL CACHE INTERNAL "") +SET(HAVE_S_IROTH CACHE INTERNAL "") +SET(HAVE_S_IFIFO CACHE INTERNAL "") +SET(QSORT_TYPE_IS_VOID 1 CACHE INTERNAL "") +SET(SIGNAL_RETURN_TYPE_IS_VOID 1 CACHE INTERNAL "") +SET(C_HAS_inline CACHE INTERNAL "") +SET(C_HAS___inline 1 CACHE INTERNAL "") +SET(FIONREAD_IN_SYS_IOCTL CACHE INTERNAL "") +SET(FIONREAD_IN_SYS_FILIO CACHE INTERNAL "") +SET(GWINSZ_IN_SYS_IOCTL CACHE INTERNAL "") +SET(HAVE_NDIR_H CACHE INTERNAL "") +SET(HAVE_SYS_NDIR_H CACHE INTERNAL "") +SET(HAVE_SYS_NDIR_H CACHE INTERNAL "") +SET(HAVE_ASM_TERMBITS_H CACHE INTERNAL "") +SET(HAVE_TERMBITS_H CACHE INTERNAL "") +SET(HAVE_WCHAR_H 1 CACHE INTERNAL "") +SET(HAVE_WCTYPE_H 1 CACHE INTERNAL "") +SET(HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP CACHE INTERNAL "") +SET(HAVE_SOCKADDR_IN_SIN_LEN CACHE INTERNAL "") +SET(HAVE_SOCKADDR_IN6_SIN6_LEN CACHE INTERNAL "") +SET(HAVE_VALGRIND_MEMCHECK_H CACHE INTERNAL "") +SET(HAVE_EVENT_H CACHE INTERNAL "") +SET(HAVE_LINUX_UNISTD_H CACHE INTERNAL "") +SET(HAVE_SYS_UTSNAME_H CACHE INTERNAL "") +SET(HAVE_PTHREAD_ATTR_GETGUARDSIZE CACHE INTERNAL "") +SET(HAVE_SOCKPEERCRED CACHE INTERNAL "") +SET(HAVE_ABI_CXA_DEMANGLE CACHE INTERNAL "") +SET(HAVE_GCC_C11_ATOMICS CACHE INTERNAL "") +SET(HAVE_VISIBILITY_HIDDEN CACHE INTERNAL "") +SET(HAVE_ACCEPT4 CACHE INTERNAL "") +SET(HAVE_LINK_H CACHE INTERNAL "") +SET(HAVE_DLADDR CACHE INTERNAL "") +SET(HAVE_CXX_NEW 1 CACHE INTERNAL "") +SET(STRUCT_DIRENT_HAS_D_INO CACHE INTERNAL "") +SET(STRUCT_DIRENT_HAS_D_NAMLEN CACHE INTERNAL "") +SET(HAVE_UCONTEXT_H CACHE INTERNAL "") +SET(STRUCT_TIMESPEC_HAS_TV_SEC 1 CACHE INTERNAL "") +SET(STRUCT_TIMESPEC_HAS_TV_NSEC 1 CACHE INTERNAL "") +SET(HAVE_UNISTD CACHE INTERNAL "") +SET(HAVE_SIGNAL_H CACHE INTERNAL "") +SET(HAVE_LZ4_H CACHE INTERNAL "") +SET(HAVE_LZ4_COMPRESS_DEFAULT CACHE INTERNAL "") +SET(HAVE_LZO_H CACHE INTERNAL "") +SET(HAVE_LZO_SHARED_LIB CACHE INTERNAL "") +SET(HAVE_LZMA_H CACHE INTERNAL "") +SET(HAVE_LZMA_DECODE CACHE INTERNAL "") +SET(HAVE_LZMA_ENCODE CACHE INTERNAL "") +SET(HAVE_BZLIB2_COMPRESS CACHE INTERNAL "") +SET(HAVE_BZLIB2_DECOMPRESS CACHE INTERNAL "") +SET(HAVE_BZLIB2_H CACHE INTERNAL "") +SET(HAVE_SNAPPY_H CACHE INTERNAL "") +SET(HAVE_SCHED_GETCPU CACHE INTERNAL "") +SET(HAVE_NANOSLEEP CACHE INTERNAL "") +SET(HAVE_PTHREAD_THREADID_NP CACHE INTERNAL "") +SET(HAVE_SYS_GETTID CACHE INTERNAL "") +SET(HAVE_GETTID CACHE INTERNAL "") +SET(HAVE_INTEGER_PTHREAD_SELF CACHE INTERNAL "") +SET(HAVE_PTHREAD_GETTHREADID_NP CACHE INTERNAL "") +SET(HAVE_TIMER_DELETE CACHE INTERNAL "") +SET(HAVE_MALLOC_USABLE_SIZE CACHE INTERNAL "") +SET(HAVE_PAM_EXT_H CACHE INTERNAL "") +SET(HAVE_PAM_SYSLOG CACHE INTERNAL "") +SET(HAVE_XUCRED CACHE INTERNAL "") +SET(HAVE_GETPEERUCRED CACHE INTERNAL "") +SET(HAVE_GETPWUID_POSIX_FINAL CACHE INTERNAL "") +SET(HAVE_CRACK_H CACHE INTERNAL "") +SET(HAVE_LIBCRACK CACHE INTERNAL "") +SET(HAVE_SNAPPY_SHARED_LIB INTERNAL "") +SET(HAVE_LZ4_SHARED_LIB INTERNAL "") +SET(HAVE_SYS_POLL_H CACHE INTERNAL "") +SET(HAVE_SYS_SYSCALL_H CACHE INTERNAL "") +SET(HAVE_SYS_STATVFS_H CACHE INTERNAL "") +ENDIF(MSVC) diff --git a/cmake/package_name.cmake b/cmake/package_name.cmake new file mode 100644 index 00000000..d14bf1f5 --- /dev/null +++ b/cmake/package_name.cmake @@ -0,0 +1,146 @@ +# Copyright (c) 2010, 2013, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# Produce meaningful package name for the binary package +# The logic is rather involved with special cases for different OSes +INCLUDE(CheckTypeSize) +CHECK_TYPE_SIZE("void *" SIZEOF_VOIDP) +MACRO(GET_PACKAGE_FILE_NAME Var) +IF(NOT VERSION) + MESSAGE(FATAL_ERROR + "Variable VERSION needs to be set prior to calling GET_PACKAGE_FILE_NAME") + ENDIF() + IF(NOT SYSTEM_NAME_AND_PROCESSOR) + SET(NEED_DASH_BETWEEN_PLATFORM_AND_MACHINE 1) + SET(DEFAULT_PLATFORM ${CMAKE_SYSTEM_NAME}) + SET(DEFAULT_MACHINE ${CMAKE_SYSTEM_PROCESSOR}) + IF(SIZEOF_VOIDP EQUAL 8) + SET(64BIT 1) + ENDIF() + + IF(NOT 64BIT AND CMAKE_SYSTEM_PROCESSOR MATCHES "^mips64") + SET(DEFAULT_MACHINE "mips") + ENDIF() + + IF(CMAKE_SYSTEM_NAME MATCHES "Windows") + SET(NEED_DASH_BETWEEN_PLATFORM_AND_MACHINE 0) + SET(DEFAULT_PLATFORM "win") + IF(64BIT) + SET(DEFAULT_MACHINE "x64") + ELSE() + SET(DEFAULT_MACHINE "32") + ENDIF() + ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Linux") + IF(NOT 64BIT AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") + SET(DEFAULT_MACHINE "i686") + ENDIF() + ELSEIF(CMAKE_SYSTEM_NAME MATCHES "SunOS") + # SunOS 5.10=> solaris10 + STRING(REPLACE "5." "" VER "${CMAKE_SYSTEM_VERSION}") + SET(DEFAULT_PLATFORM "solaris${VER}") + IF(64BIT) + IF(CMAKE_SYSTEM_PROCESSOR MATCHES "i386") + SET(DEFAULT_MACHINE "x86_64") + ELSE() + SET(DEFAULT_MACHINE "${CMAKE_SYSTEM_PROCESSOR}-64bit") + ENDIF() + ENDIF() + ELSEIF(CMAKE_SYSTEM_NAME MATCHES "HP-UX") + STRING(REPLACE "B." "" VER "${CMAKE_SYSTEM_VERSION}") + SET(DEFAULT_PLATFORM "hpux${VER}") + IF(64BIT) + SET(DEFAULT_MACHINE "${CMAKE_SYSTEM_PROCESSOR}-64bit") + ENDIF() + ELSEIF(CMAKE_SYSTEM_NAME MATCHES "AIX") + SET(DEFAULT_PLATFORM "${CMAKE_SYSTEM_NAME}5.${CMAKE_SYSTEM_VERSION}") + IF(64BIT) + SET(DEFAULT_MACHINE "${CMAKE_SYSTEM_PROCESSOR}-64bit") + ENDIF() + ELSEIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + STRING(REGEX MATCH "[0-9]+\\.[0-9]+" VER "${CMAKE_SYSTEM_VERSION}") + SET(DEFAULT_PLATFORM "${CMAKE_SYSTEM_NAME}${VER}") + IF(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64") + SET(DEFAULT_MACHINE "x86_64") + IF(NOT 64BIT) + SET(DEFAULT_MACHINE "i386") + ENDIF() + ENDIF() + ELSEIF(CMAKE_SYSTEM_NAME MATCHES "GNU") + SET(DEFAULT_PLATFORM "GNU") + SET(DEFAULT_MACHINE "i386") + ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Darwin") + IF(CMAKE_OSX_DEPLOYMENT_TARGET) + SET(DEFAULT_PLATFORM "osx${CMAKE_OSX_DEPLOYMENT_TARGET}") + ELSE() + SET(VER "${CMAKE_SYSTEM_VERSION}") + STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" VER "${VER}") + # Subtract 4 from Darwin version to get correct osx10.X + MATH(EXPR VER "${VER} -4") + SET(DEFAULT_PLATFORM "osx10.${VER}") + ENDIF() + + IF(CMAKE_OSX_ARCHITECTURES) + LIST(LENGTH CMAKE_OSX_ARCHITECTURES LEN) + IF(LEN GREATER 1) + SET(DEFAULT_MACHINE "universal") + ELSE() + SET(DEFAULT_MACHINE "${CMAKE_OSX_ARCHITECTURES}") + ENDIF() + ELSE() + IF(64BIT) + SET(DEFAULT_MACHINE "x86_64") + ELSE() + SET(DEFAULT_MACHINE "i386") + ENDIF() + ENDIF() + + IF(DEFAULT_MACHINE MATCHES "i386") + SET(DEFAULT_MACHINE "x86") + ENDIF() + ENDIF() + + IF(NOT PLATFORM) + SET(PLATFORM ${DEFAULT_PLATFORM}) + ENDIF() + IF(NOT MACHINE) + SET(MACHINE ${DEFAULT_MACHINE}) + ENDIF() + + IF(NEED_DASH_BETWEEN_PLATFORM_AND_MACHINE) + SET(SYSTEM_NAME_AND_PROCESSOR "${PLATFORM}-${MACHINE}") + ELSE() + SET(SYSTEM_NAME_AND_PROCESSOR "${PLATFORM}${MACHINE}") + ENDIF() + ENDIF() + + IF(SHORT_PRODUCT_TAG) + SET(PRODUCT_TAG "-${SHORT_PRODUCT_TAG}") + ELSEIF(MYSQL_SERVER_SUFFIX) + SET(PRODUCT_TAG "${MYSQL_SERVER_SUFFIX}") # Already has a leading dash + ELSE() + SET(PRODUCT_TAG) + ENDIF() + + SET(package_name "mariadb${PRODUCT_TAG}-${VERSION}-${SYSTEM_NAME_AND_PROCESSOR}") + + MESSAGE_ONCE(package_name "Packaging as: ${package_name}") + + # Sometimes package suffix is added (something like "-icc-glibc23") + IF(PACKAGE_SUFFIX) + SET(package_name "${package_name}${PACKAGE_SUFFIX}") + ENDIF() + STRING(TOLOWER ${package_name} package_name) + SET(${Var} ${package_name}) +ENDMACRO() diff --git a/cmake/pcre.cmake b/cmake/pcre.cmake new file mode 100644 index 00000000..3d4f163f --- /dev/null +++ b/cmake/pcre.cmake @@ -0,0 +1,82 @@ +INCLUDE (CheckCSourceRuns) +INCLUDE (ExternalProject) + +SET(WITH_PCRE "auto" CACHE STRING + "Which pcre to use (possible values are 'bundled', 'system', or 'auto')") + +MACRO(BUNDLE_PCRE2) + SET(dir "${CMAKE_BINARY_DIR}/extra/pcre2") + SET(PCRE_INCLUDES ${dir}/src/pcre2-build ${dir}/src/pcre2/src) + SET(byproducts) + FOREACH(lib pcre2-posix pcre2-8) + ADD_LIBRARY(${lib} STATIC IMPORTED GLOBAL) + ADD_DEPENDENCIES(${lib} pcre2) + IF(WIN32) + # Debug libary name. + # Same condition as in pcre2 CMakeLists.txt that adds "d" + GET_PROPERTY(MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + IF(MULTICONFIG) + SET(intdir "${CMAKE_CFG_INTDIR}/") + ELSE() + SET(intdir) + ENDIF() + + SET(file ${dir}/src/pcre2-build/${intdir}${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}) + SET(file_d ${dir}/src/pcre2-build/${intdir}${CMAKE_STATIC_LIBRARY_PREFIX}${lib}d${CMAKE_STATIC_LIBRARY_SUFFIX}) + SET_TARGET_PROPERTIES(${lib} PROPERTIES IMPORTED_LOCATION_DEBUG ${file_d}) + ELSE() + SET(file ${dir}/src/pcre2-build/${CMAKE_STATIC_LIBRARY_PREFIX}${lib}${CMAKE_STATIC_LIBRARY_SUFFIX}) + SET(file_d) + ENDIF() + SET(byproducts ${byproducts} BUILD_BYPRODUCTS ${file} ${file_d}) + SET_TARGET_PROPERTIES(${lib} PROPERTIES IMPORTED_LOCATION ${file}) + ENDFOREACH() + FOREACH(v "" "_DEBUG" "_RELWITHDEBINFO" "_RELEASE" "_MINSIZEREL") + STRING(REPLACE "/WX" "" pcre2_flags${v} "${CMAKE_C_FLAGS${v}}") + IF(MSVC) + # Suppress a warning + STRING(APPEND pcre2_flags${v} " /wd4244 " ) + # Disable asan support + STRING(REPLACE "-fsanitize=address" "" pcre2_flags${v} "${CMAKE_C_FLAGS${v}}") + ENDIF() + ENDFOREACH() + ExternalProject_Add( + pcre2 + PREFIX "${dir}" + URL "http://ftp.pcre.org/pub/pcre/pcre2-10.37.zip" + URL_MD5 8c1699a725d4b28410adf4b964ebbcb7 + INSTALL_COMMAND "" + CMAKE_ARGS + "-DPCRE2_BUILD_TESTS=OFF" + "-DPCRE2_BUILD_PCRE2GREP=OFF" + "-DBUILD_SHARED_LIBS=OFF" + "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" + "-DCMAKE_C_FLAGS=${pcre2_flags} ${PIC_FLAG}" + "-DCMAKE_C_FLAGS_DEBUG=${pcre2_flags_DEBUG}" + "-DCMAKE_C_FLAGS_RELWITHDEBINFO=${pcre2_flags_RELWITHDEBINFO}" + "-DCMAKE_C_FLAGS_RELEASE=${pcre2_flags_RELEASE}" + "-DCMAKE_C_FLAGS_MINSIZEREL=${pcre2_flags_MINSIZEREL}" + "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}" + ${stdlibs} + ${byproducts} + ) +SET_TARGET_PROPERTIES(pcre2 PROPERTIES EXCLUDE_FROM_ALL TRUE) +ENDMACRO() + +MACRO (CHECK_PCRE) + IF(WITH_PCRE STREQUAL "system" OR WITH_PCRE STREQUAL "auto") + CHECK_LIBRARY_EXISTS(pcre2-8 pcre2_match_8 "" HAVE_PCRE2) + ENDIF() + IF(NOT HAVE_PCRE2 OR WITH_PCRE STREQUAL "bundled") + IF (WITH_PCRE STREQUAL "system") + MESSAGE(FATAL_ERROR "system pcre2-8 library is not found or unusable") + ENDIF() + BUNDLE_PCRE2() + ELSE() + CHECK_LIBRARY_EXISTS(pcre2-posix PCRE2regcomp "" NEEDS_PCRE2_DEBIAN_HACK) + IF(NEEDS_PCRE2_DEBIAN_HACK) + SET(PCRE2_DEBIAN_HACK "-Dregcomp=PCRE2regcomp -Dregexec=PCRE2regexec -Dregerror=PCRE2regerror -Dregfree=PCRE2regfree") + ENDIF() + ENDIF() +ENDMACRO() + diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake new file mode 100644 index 00000000..6bc1de3e --- /dev/null +++ b/cmake/plugin.cmake @@ -0,0 +1,326 @@ +# Copyright (c) 2009, 2018, Oracle and/or its affiliates. +# Copyright (c) 2011, 2019, MariaDB Corporation. +# +# 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + + +INCLUDE(CMakeParseArguments) + +# MYSQL_ADD_PLUGIN(plugin_name source1...sourceN +# [STORAGE_ENGINE] +# [STATIC_ONLY|MODULE_ONLY] +# [MANDATORY|DEFAULT] +# [DISABLED] +# [NOT_EMBEDDED|RECOMPILE_FOR_EMBEDDED] +# [CLIENT] +# [MODULE_OUTPUT_NAME module_name] +# [STATIC_OUTPUT_NAME static_name] +# [COMPONENT component] +# [CONFIG cnf_file_name] +# [VERSION version_string] +# [LINK_LIBRARIES lib1...libN] +# [DEPENDENCIES target1...targetN] + +MACRO(MYSQL_ADD_PLUGIN) + CMAKE_PARSE_ARGUMENTS(ARG + "STORAGE_ENGINE;STATIC_ONLY;MODULE_ONLY;MANDATORY;DEFAULT;DISABLED;NOT_EMBEDDED;RECOMPILE_FOR_EMBEDDED;CLIENT" + "MODULE_OUTPUT_NAME;STATIC_OUTPUT_NAME;COMPONENT;CONFIG;VERSION" + "LINK_LIBRARIES;DEPENDENCIES" + ${ARGN} + ) + IF(NOT WITHOUT_SERVER OR ARG_CLIENT) + + # Add common include directories + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include + ${CMAKE_SOURCE_DIR}/sql + ${PCRE_INCLUDES} + ${SSL_INCLUDE_DIRS} + ${ZLIB_INCLUDE_DIR}) + + LIST(GET ARG_UNPARSED_ARGUMENTS 0 plugin) + SET(SOURCES ${ARG_UNPARSED_ARGUMENTS}) + LIST(REMOVE_AT SOURCES 0) + STRING(TOUPPER ${plugin} plugin) + STRING(TOLOWER ${plugin} target) + + IF (ARG_MANDATORY) + UNSET(PLUGIN_${plugin} CACHE) + SET(PLUGIN_${plugin} "YES") + ELSE() + SET (compat ".") + # Figure out whether to build plugin. + # recognize and support the maze of old WITH/WITHOUT combinations + IF(WITHOUT_${plugin}_STORAGE_ENGINE + OR WITHOUT_${plugin} + OR WITHOUT_PLUGIN_${plugin} + OR WITH_NONE) + + SET(compat "${compat}without") + ENDIF() + IF(WITH_${plugin}_STORAGE_ENGINE + OR WITH_${plugin} + OR WITH_PLUGIN_${plugin} + OR WITH_ALL + OR WITH_MAX + OR WITH_MAX_NO_NDB + OR ARG_DEFAULT) + + SET(compat "with${compat}") + ENDIF() + + IF (ARG_DISABLED) + SET(howtobuild NO) + ELSEIF (compat STREQUAL ".") + SET(howtobuild DYNAMIC) + ELSEIF (compat STREQUAL "with.") + IF (NOT ARG_MODULE_ONLY) + SET(howtobuild STATIC) + ELSE() + SET(howtobuild DYNAMIC) + ENDIF() + ELSEIF (compat STREQUAL ".without") + SET(howtobuild NO) + ELSEIF (compat STREQUAL "with.without") + SET(howtobuild STATIC) + ENDIF() + + # NO - not at all + # YES - static if possible, otherwise dynamic if possible, otherwise abort + # AUTO - static if possible, otherwise dynamic, if possible + # STATIC - static if possible, otherwise not at all + # DYNAMIC - dynamic if possible, otherwise not at all + SET(PLUGIN_${plugin} ${howtobuild} + CACHE STRING "How to build plugin ${plugin}. Options are: NO STATIC DYNAMIC YES AUTO.") + ENDIF() + + IF (NOT PLUGIN_${plugin} MATCHES "^(NO|YES|AUTO|STATIC|DYNAMIC)$") + MESSAGE(FATAL_ERROR "Invalid value for PLUGIN_${plugin}") + ENDIF() + + IF(ARG_STORAGE_ENGINE) + SET(with_var "WITH_${plugin}_STORAGE_ENGINE" ) + ELSE() + SET(with_var "WITH_${plugin}") + ENDIF() + UNSET(${with_var} CACHE) + + IF(NOT ARG_DEPENDENCIES) + SET(ARG_DEPENDENCIES) + ENDIF() + + IF(ARG_VERSION) + SET(version_string ";PLUGIN_${plugin}_VERSION=\"${ARG_VERSION}\"") + ENDIF() + + IF(NOT ARG_MODULE_OUTPUT_NAME) + IF(ARG_STORAGE_ENGINE) + SET(ARG_MODULE_OUTPUT_NAME "ha_${target}") + ELSE() + SET(ARG_MODULE_OUTPUT_NAME "${target}") + ENDIF() + ENDIF() + + # Build either static library or module + IF (PLUGIN_${plugin} MATCHES "(STATIC|AUTO|YES)" AND NOT ARG_MODULE_ONLY + AND NOT ARG_CLIENT) + + IF(CMAKE_GENERATOR MATCHES "Makefiles|Ninja") + # If there is a shared library from previous shared build, + # remove it. This is done just for mysql-test-run.pl + # so it does not try to use stale shared lib as plugin + # in test. + FILE(REMOVE + ${CMAKE_CURRENT_BINARY_DIR}/${ARG_MODULE_OUTPUT_NAME}${CMAKE_SHARED_MODULE_SUFFIX}) + ENDIF() + + ADD_LIBRARY(${target} STATIC ${SOURCES}) + DTRACE_INSTRUMENT(${target}) + ADD_DEPENDENCIES(${target} GenError ${ARG_DEPENDENCIES}) + RESTRICT_SYMBOL_EXPORTS(${target}) + IF(WITH_EMBEDDED_SERVER AND (NOT ARG_NOT_EMBEDDED)) + # Embedded library should contain PIC code and be linkable + # to shared libraries (on systems that need PIC) + IF(ARG_RECOMPILE_FOR_EMBEDDED OR NOT _SKIP_PIC) + # Recompile some plugins for embedded + ADD_CONVENIENCE_LIBRARY(${target}_embedded ${SOURCES}) + RESTRICT_SYMBOL_EXPORTS(${target}_embedded) + DTRACE_INSTRUMENT(${target}_embedded) + IF(ARG_RECOMPILE_FOR_EMBEDDED) + SET_TARGET_PROPERTIES(${target}_embedded + PROPERTIES COMPILE_DEFINITIONS "EMBEDDED_LIBRARY${version_string}") + ENDIF() + ADD_DEPENDENCIES(${target}_embedded GenError) + ENDIF() + ENDIF() + + IF(ARG_STATIC_OUTPUT_NAME) + SET_TARGET_PROPERTIES(${target} PROPERTIES + OUTPUT_NAME ${ARG_STATIC_OUTPUT_NAME}) + ENDIF() + + IF(ARG_LINK_LIBRARIES) + TARGET_LINK_LIBRARIES (${target} ${ARG_LINK_LIBRARIES}) + ENDIF() + + SET(${with_var} ON CACHE INTERNAL "Link ${plugin} statically to the server" FORCE) + + # Update mysqld dependencies + SET (MYSQLD_STATIC_PLUGIN_LIBS ${MYSQLD_STATIC_PLUGIN_LIBS} + ${target} ${ARG_LINK_LIBRARIES} CACHE INTERNAL "" FORCE) + + IF(WITH_EMBEDDED_SERVER AND (NOT ARG_NOT_EMBEDDED)) + SET (EMBEDDED_PLUGIN_LIBS ${EMBEDDED_PLUGIN_LIBS} + ${target} ${ARG_LINK_LIBRARIES} CACHE INTERNAL "" FORCE) + ENDIF() + + IF(ARG_NOT_EMBEDDED) + SET(builtin_entry "#ifndef EMBEDDED_LIBRARY\n builtin_maria_${target}_plugin,\n#endif") + ELSE() + SET(builtin_entry " builtin_maria_${target}_plugin,") + ENDIF() + + IF(ARG_MANDATORY) + SET (mysql_mandatory_plugins + "${mysql_mandatory_plugins}${builtin_entry}\n") + SET (mysql_mandatory_plugins ${mysql_mandatory_plugins} PARENT_SCOPE) + ELSE() + SET (mysql_optional_plugins + "${mysql_optional_plugins}${builtin_entry}\n") + SET (mysql_optional_plugins ${mysql_optional_plugins} PARENT_SCOPE) + ENDIF() + ELSEIF(PLUGIN_${plugin} MATCHES "(DYNAMIC|AUTO|YES)" + AND NOT ARG_STATIC_ONLY AND NOT WITHOUT_DYNAMIC_PLUGINS) + + ADD_VERSION_INFO(${target} MODULE SOURCES) + ADD_LIBRARY(${target} MODULE ${SOURCES}) + DTRACE_INSTRUMENT(${target}) + + SET_TARGET_PROPERTIES (${target} PROPERTIES PREFIX "") + IF (NOT ARG_CLIENT) + SET_TARGET_PROPERTIES (${target} PROPERTIES + COMPILE_DEFINITIONS "MYSQL_DYNAMIC_PLUGIN${version_string}") + ENDIF() + + TARGET_LINK_LIBRARIES (${target} mysqlservices ${ARG_LINK_LIBRARIES}) + + IF(CMAKE_SYSTEM_NAME MATCHES AIX) + TARGET_LINK_OPTIONS(${target} PRIVATE "-Wl,-bE:${CMAKE_SOURCE_DIR}/libservices/mysqlservices_aix.def") + ENDIF() + + # Server plugins use symbols defined in mysqld executable. + # Some operating systems like Windows and OSX and are pretty strict about + # unresolved symbols. Others are less strict and allow unresolved symbols + # in shared libraries. On Linux for example, CMake does not even add + # executable to the linker command line (it would result into link error). + # Thus we skip TARGET_LINK_LIBRARIES on Linux, as it would only generate + # an additional dependency. + IF(ARG_RECOMPILE_FOR_EMBEDDED OR ARG_STORAGE_ENGINE) + IF(MSVC OR CMAKE_SYSTEM_NAME MATCHES AIX) + TARGET_LINK_LIBRARIES(${target} server) + ELSEIF(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") + TARGET_LINK_LIBRARIES (${target} mariadbd) + ENDIF() + ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND NOT WITH_ASAN AND NOT WITH_TSAN AND NOT WITH_UBSAN AND NOT WITH_MSAN) + TARGET_LINK_LIBRARIES (${target} "-Wl,--no-undefined") + ENDIF() + + ADD_DEPENDENCIES(${target} GenError ${ARG_DEPENDENCIES}) + + SET_TARGET_PROPERTIES(${target} PROPERTIES + OUTPUT_NAME "${ARG_MODULE_OUTPUT_NAME}") + # Install dynamic library + IF(ARG_COMPONENT) + IF(CPACK_COMPONENTS_ALL AND + NOT CPACK_COMPONENTS_ALL MATCHES ${ARG_COMPONENT} + AND INSTALL_SYSCONF2DIR) + IF (ARG_STORAGE_ENGINE) + STRING(REPLACE "-" "_" ver ${SERVER_VERSION}) + SET(ver " = ${ver}-%{release}") + ELSE() + SET(ver "") + ENDIF() + SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} ${ARG_COMPONENT}) + SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} PARENT_SCOPE) + + IF (NOT ARG_CLIENT) + SET(CPACK_RPM_${ARG_COMPONENT}_PACKAGE_REQUIRES "MariaDB-server${ver}" PARENT_SCOPE) + ENDIF() + SET(CPACK_RPM_${ARG_COMPONENT}_USER_FILELIST ${ignored} PARENT_SCOPE) + IF (ARG_VERSION) + SET(CPACK_RPM_${ARG_COMPONENT}_PACKAGE_VERSION ${SERVER_VERSION}_${ARG_VERSION} PARENT_SCOPE) + SET_PLUGIN_DEB_VERSION(${target} ${SERVER_VERSION}-${ARG_VERSION}) + ENDIF() + IF(NOT ARG_CLIENT AND UNIX) + IF (NOT ARG_CONFIG) + SET(ARG_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${target}.cnf") + FILE(WRITE ${ARG_CONFIG} "[mariadb]\nplugin-load-add=${ARG_MODULE_OUTPUT_NAME}.so\n") + ENDIF() + SET(CPACK_RPM_${ARG_COMPONENT}_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*" PARENT_SCOPE) + SET(CPACK_RPM_${ARG_COMPONENT}_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/plugin-postin.sh PARENT_SCOPE) + SET(CPACK_RPM_${ARG_COMPONENT}_POST_TRANS_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/server-posttrans.sh PARENT_SCOPE) + ENDIF() + ENDIF() + ELSE() + SET(ARG_COMPONENT Server) + ENDIF() + MYSQL_INSTALL_TARGETS(${target} DESTINATION ${INSTALL_PLUGINDIR} COMPONENT ${ARG_COMPONENT}) + IF(ARG_CONFIG AND INSTALL_SYSCONF2DIR) + INSTALL(FILES ${ARG_CONFIG} COMPONENT ${ARG_COMPONENT} DESTINATION ${INSTALL_SYSCONF2DIR}) + ENDIF() + ENDIF() + + GET_FILENAME_COMPONENT(subpath ${CMAKE_CURRENT_SOURCE_DIR} NAME) + IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/mysql-test") + INSTALL_MYSQL_TEST("${CMAKE_CURRENT_SOURCE_DIR}/mysql-test/" "plugin/${subpath}") + ENDIF() + + GET_TARGET_PROPERTY(plugin_type ${target} TYPE) + STRING(REGEX REPLACE "_LIBRARY$" "" plugin_type ${plugin_type}) + STRING(REGEX REPLACE "^NO$" "" plugin_type ${plugin_type}) + IF(ARG_STORAGE_ENGINE) + ADD_FEATURE_INFO(${plugin} PLUGIN_${plugin} "Storage Engine ${plugin_type}") + ELSEIF(ARG_CLIENT) + ADD_FEATURE_INFO(${plugin} PLUGIN_${plugin} "Client plugin ${plugin_type}") + ELSE() + ADD_FEATURE_INFO(${plugin} PLUGIN_${plugin} "Server plugin ${plugin_type}") + ENDIF() + ENDIF(NOT WITHOUT_SERVER OR ARG_CLIENT) +ENDMACRO() + + +# Add all CMake projects under storage and plugin +# subdirectories, configure sql_builtins.cc +MACRO(CONFIGURE_PLUGINS) + IF(NOT WITHOUT_SERVER) + FILE(GLOB dirs_storage ${CMAKE_SOURCE_DIR}/storage/*) + ENDIF() + + FILE(GLOB dirs_plugin ${CMAKE_SOURCE_DIR}/plugin/*) + FOREACH(dir ${dirs_storage} ${dirs_plugin}) + IF (EXISTS ${dir}/CMakeLists.txt) + ADD_SUBDIRECTORY(${dir}) + ENDIF() + ENDFOREACH() + + GET_CMAKE_PROPERTY(ALL_VARS VARIABLES) + FOREACH (V ${ALL_VARS}) + IF (V MATCHES "^PLUGIN_" AND ${V} MATCHES "YES") + STRING(SUBSTRING ${V} 7 -1 plugin) + STRING(TOLOWER ${plugin} target) + IF (NOT TARGET ${target}) + MESSAGE(FATAL_ERROR "Plugin ${plugin} cannot be built") + ENDIF() + ENDIF() + ENDFOREACH() +ENDMACRO() diff --git a/cmake/pmem.cmake b/cmake/pmem.cmake new file mode 100644 index 00000000..b59db3cc --- /dev/null +++ b/cmake/pmem.cmake @@ -0,0 +1,13 @@ +INCLUDE(CheckIncludeFiles) +OPTION(WITH_PMEM "Enable persistent memory features" OFF) +IF(WITH_PMEM) + FIND_LIBRARY(LIBPMEM pmem) + CHECK_INCLUDE_FILES(libpmem.h HAVE_LIBPMEM_H) + IF (NOT LIBPMEM) + MESSAGE(FATAL_ERROR "Can't find libpmem") + ELSEIF(NOT HAVE_LIBPMEM_H) + MESSAGE(FATAL_ERROR "Can't find libpmem.h") + ELSE() + ADD_DEFINITIONS(-DHAVE_PMEM) + ENDIF() +ENDIF() diff --git a/cmake/readline.cmake b/cmake/readline.cmake new file mode 100644 index 00000000..c8bbc7fc --- /dev/null +++ b/cmake/readline.cmake @@ -0,0 +1,225 @@ +# Copyright (c) 2009, 2010 Sun Microsystems, Inc. +# Use is subject to license terms. +# +# 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +INCLUDE(CheckCXXSourceCompiles) + +MACRO (MYSQL_CHECK_MULTIBYTE) + CHECK_INCLUDE_FILE(wctype.h HAVE_WCTYPE_H) + CHECK_INCLUDE_FILE(wchar.h HAVE_WCHAR_H) + IF(HAVE_WCHAR_H) + SET(CMAKE_EXTRA_INCLUDE_FILES wchar.h) + CHECK_TYPE_SIZE(mbstate_t SIZEOF_MBSTATE_T) + SET(CMAKE_EXTRA_INCLUDE_FILES) + IF(SIZEOF_MBSTATE_T) + SET(HAVE_MBSTATE_T 1) + ENDIF() + ENDIF() + + CHECK_FUNCTION_EXISTS(mbrlen HAVE_MBRLEN) + CHECK_FUNCTION_EXISTS(mbsrtowcs HAVE_MBSRTOWCS) + CHECK_FUNCTION_EXISTS(mbrtowc HAVE_MBRTOWC) + CHECK_FUNCTION_EXISTS(wcwidth HAVE_WCWIDTH) + CHECK_FUNCTION_EXISTS(iswlower HAVE_ISWLOWER) + CHECK_FUNCTION_EXISTS(iswupper HAVE_ISWUPPER) + CHECK_FUNCTION_EXISTS(towlower HAVE_TOWLOWER) + CHECK_FUNCTION_EXISTS(towupper HAVE_TOWUPPER) + CHECK_FUNCTION_EXISTS(iswctype HAVE_ISWCTYPE) + + SET(CMAKE_EXTRA_INCLUDE_FILES wchar.h) + CHECK_TYPE_SIZE(wchar_t SIZEOF_WCHAR_T) + IF(SIZEOF_WCHAR_T) + SET(HAVE_WCHAR_T 1) + ENDIF() + + SET(CMAKE_EXTRA_INCLUDE_FILES wctype.h) + CHECK_TYPE_SIZE(wctype_t SIZEOF_WCTYPE_T) + CHECK_TYPE_SIZE(wint_t SIZEOF_WINT_T) + SET(CMAKE_EXTRA_INCLUDE_FILES) + +ENDMACRO() + +MACRO (FIND_CURSES) + FIND_PACKAGE(Curses REQUIRED) + MARK_AS_ADVANCED(CURSES_CURSES_H_PATH CURSES_FORM_LIBRARY CURSES_HAVE_CURSES_H) + IF(NOT CURSES_FOUND) + SET(ERRORMSG "Curses library not found. Please install appropriate package, + remove CMakeCache.txt and rerun cmake.") + IF(CMAKE_SYSTEM_NAME MATCHES "Linux") + SET(ERRORMSG ${ERRORMSG} + "On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates " + "it is ncurses-devel.") + ENDIF() + MESSAGE(FATAL_ERROR ${ERRORMSG}) + ENDIF() + + IF(CURSES_HAVE_CURSES_H) + SET(HAVE_CURSES_H 1 CACHE INTERNAL "") + ENDIF() + IF(CMAKE_SYSTEM_NAME MATCHES "HP") + # CMake uses full path to library /lib/libcurses.sl + # On Itanium, it results into architecture mismatch+ + # the library is for PA-RISC + SET(CURSES_LIBRARY "curses" CACHE INTERNAL "" FORCE) + ENDIF() + + IF(CMAKE_SYSTEM_NAME MATCHES "Linux") + # -Wl,--as-needed breaks linking with -lcurses, e.g on Fedora + # Lower-level libcurses calls are exposed by libtinfo + CHECK_LIBRARY_EXISTS(${CURSES_LIBRARY} tputs "" HAVE_TPUTS_IN_CURSES) + IF(NOT HAVE_TPUTS_IN_CURSES) + CHECK_LIBRARY_EXISTS(tinfo tputs "" HAVE_TPUTS_IN_TINFO) + IF(HAVE_TPUTS_IN_TINFO) + SET(CURSES_LIBRARY tinfo) + ENDIF() + ENDIF() + ENDIF() + CHECK_LIBRARY_EXISTS(${CURSES_LIBRARY} setupterm "" HAVE_SETUPTERM) + CHECK_LIBRARY_EXISTS(${CURSES_LIBRARY} vidattr "" HAVE_VIDATTR) +ENDMACRO() + +MACRO (MYSQL_USE_BUNDLED_READLINE) + SET(USE_NEW_READLINE_INTERFACE 1) + SET(HAVE_HIST_ENTRY 0 CACHE INTERNAL "" FORCE) + SET(MY_READLINE_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extra/readline) + SET(MY_READLINE_LIBRARY readline) + ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/extra/readline) +ENDMACRO() + +MACRO (MYSQL_FIND_SYSTEM_READLINE) + + FIND_PATH(READLINE_INCLUDE_DIR readline.h PATH_SUFFIXES readline) + FIND_LIBRARY(READLINE_LIBRARY NAMES readline) + MARK_AS_ADVANCED(READLINE_INCLUDE_DIR READLINE_LIBRARY) + + IF(READLINE_LIBRARY AND READLINE_INCLUDE_DIR) + SET(CMAKE_REQUIRED_LIBRARIES ${READLINE_LIBRARY} ${CURSES_LIBRARY}) + SET(CMAKE_REQUIRED_INCLUDES ${READLINE_INCLUDE_DIR}) + CHECK_CXX_SOURCE_COMPILES(" + #include <stdio.h> + #include <readline.h> + int main(int argc, char **argv) + { + rl_completion_func_t *func1= (rl_completion_func_t*)0; + rl_compentry_func_t *func2= (rl_compentry_func_t*)0; + }" + NEW_READLINE_INTERFACE) + + CHECK_C_SOURCE_COMPILES(" + #include <stdio.h> + #include <readline.h> + #if RL_VERSION_MAJOR > 5 + #error + #endif + int main(int argc, char **argv) + { + return 0; + }" + READLINE_V5) + + IF(NEW_READLINE_INTERFACE) + IF (READLINE_V5) + SET(USE_NEW_READLINE_INTERFACE 1) + ELSE() + IF(NOT_FOR_DISTRIBUTION) + SET(NON_DISTRIBUTABLE_WARNING "GPLv3" CACHE INTERNAL "") + SET(USE_NEW_READLINE_INTERFACE 1) + ELSE() + SET(USE_NEW_READLINE_INTERFACE 0) + ENDIF(NOT_FOR_DISTRIBUTION) + ENDIF(READLINE_V5) + ENDIF(NEW_READLINE_INTERFACE) + ENDIF() +ENDMACRO() + +MACRO (MYSQL_FIND_SYSTEM_LIBEDIT) + FIND_PATH(LIBEDIT_INCLUDE_DIR readline.h PATH_SUFFIXES editline edit/readline) + FIND_LIBRARY(LIBEDIT_LIBRARY edit) + MARK_AS_ADVANCED(LIBEDIT_INCLUDE_DIR LIBEDIT_LIBRARY) + + IF(LIBEDIT_LIBRARY AND LIBEDIT_INCLUDE_DIR) + SET(CMAKE_REQUIRED_LIBRARIES ${LIBEDIT_LIBRARY}) + SET(CMAKE_REQUIRED_INCLUDES ${LIBEDIT_INCLUDE_DIR}) + CHECK_CXX_SOURCE_COMPILES(" + #include <stdio.h> + #include <readline.h> + int main(int argc, char **argv) + { + int res= (*rl_completion_entry_function)(0,0); + completion_matches(0,0); + }" + LIBEDIT_HAVE_COMPLETION_INT) + + CHECK_CXX_SOURCE_COMPILES(" + #include <stdio.h> + #include <readline.h> + int main(int argc, char **argv) + { + char res= *(*rl_completion_entry_function)(0,0); + completion_matches(0,0); + }" + LIBEDIT_HAVE_COMPLETION_CHAR) + IF(LIBEDIT_HAVE_COMPLETION_INT OR LIBEDIT_HAVE_COMPLETION_CHAR) + SET(USE_LIBEDIT_INTERFACE 1) + ENDIF() + ENDIF() +ENDMACRO() + + +MACRO (MYSQL_CHECK_READLINE) + IF (NOT WIN32) + MYSQL_CHECK_MULTIBYTE() + SET(WITH_READLINE OFF CACHE BOOL "Use bundled readline") + FIND_CURSES() + + IF(WITH_READLINE) + MYSQL_USE_BUNDLED_READLINE() + ELSE() + # OSX includes incompatible readline lib + IF (NOT APPLE) + MYSQL_FIND_SYSTEM_READLINE() + ENDIF() + IF(USE_NEW_READLINE_INTERFACE) + SET(MY_READLINE_INCLUDE_DIR ${READLINE_INCLUDE_DIR}) + SET(MY_READLINE_LIBRARY ${READLINE_LIBRARY} ${CURSES_LIBRARY}) + ELSE() + MYSQL_FIND_SYSTEM_LIBEDIT() + IF(USE_LIBEDIT_INTERFACE) + SET(MY_READLINE_INCLUDE_DIR ${LIBEDIT_INCLUDE_DIR}) + SET(MY_READLINE_LIBRARY ${LIBEDIT_LIBRARY} ${CURSES_LIBRARY}) + SET(USE_NEW_READLINE_INTERFACE ${LIBEDIT_HAVE_COMPLETION_CHAR}) + ELSE() + MYSQL_USE_BUNDLED_READLINE() + ENDIF() + ENDIF() + ENDIF() + + SET(CMAKE_REQUIRED_LIBRARIES ${MY_READLINE_LIBRARY}) + SET(CMAKE_REQUIRED_INCLUDES ${MY_READLINE_INCLUDE_DIR}) + CHECK_CXX_SOURCE_COMPILES(" + #include <stdio.h> + #include <readline.h> + int main(int argc, char **argv) + { + HIST_ENTRY entry; + return 0; + }" + HAVE_HIST_ENTRY) + SET(CMAKE_REQUIRED_LIBRARIES) + SET(CMAKE_REQUIRED_INCLUDES) + ENDIF(NOT WIN32) + CHECK_INCLUDE_FILES ("curses.h;term.h" HAVE_TERM_H) +ENDMACRO() + diff --git a/cmake/sign.cmake.in b/cmake/sign.cmake.in new file mode 100644 index 00000000..50768a3d --- /dev/null +++ b/cmake/sign.cmake.in @@ -0,0 +1,36 @@ +# If timestamping is used, it can (rarely) fail, when public timestamping service has issues. +# +# To handle the error gracefully and tranparently, we'll retry the signtool command, +# second time without "/t URL" parameter +SET(SIGNTOOL_PARAMETERS_NO_TIMESTAMP "@SIGNTOOL_PARAMETERS@") +LIST(FIND SIGNTOOL_PARAMETERS_NO_TIMESTAMP /t idx) +IF(NOT(idx EQUAL -1)) + LIST(REMOVE_AT SIGNTOOL_PARAMETERS_NO_TIMESTAMP ${idx}) + #remove the URL following /t , as well + LIST(REMOVE_AT SIGNTOOL_PARAMETERS_NO_TIMESTAMP ${idx}) +ENDIF() + +GET_FILENAME_COMPONENT(SIGNTOOL_DIR "@SIGNTOOL_EXECUTABLE@" DIRECTORY) +GET_FILENAME_COMPONENT(SIGNTOOL_NAME "@SIGNTOOL_EXECUTABLE@" NAME) + +FILE(GLOB_RECURSE files "@CMAKE_BINARY_DIR@/*.signme") +MESSAGE(STATUS "signing files") + + +FOREACH(f ${files}) + STRING(REPLACE ".signme" "" exe_location "${f}") + + string (REPLACE ";" " " params "@SIGNTOOL_PARAMETERS@") + + EXECUTE_PROCESS(COMMAND + cmd /c "${SIGNTOOL_NAME}" sign @SIGNTOOL_PARAMETERS@ "${exe_location}" 2>NUL + || "${SIGNTOOL_NAME}" sign ${SIGNTOOL_PARAMETERS_NO_TIMESTAMP} "${exe_location}" + WORKING_DIRECTORY ${SIGNTOOL_DIR} + RESULT_VARIABLE ERR) + IF(NOT ${ERR} EQUAL 0) + MESSAGE( "Error ${ERR} signing ${exe_location}") + ELSE() + FILE(REMOVE ${f}) + ENDIF() + +ENDFOREACH() diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake new file mode 100644 index 00000000..7c2488be --- /dev/null +++ b/cmake/ssl.cmake @@ -0,0 +1,192 @@ +# Copyright (c) 2009, 2012, Oracle and/or its affiliates. +# Copyright (c) 2011, 2017, MariaDB Corporation +# +# 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# We support different versions of SSL: +# - "bundled" uses source code in <source dir>/extra/wolfssl +# - "system" (typically) uses headers/libraries in /usr/lib and /usr/lib64 +# - a custom installation of openssl can be used like this +# - cmake -DCMAKE_PREFIX_PATH=</path/to/custom/openssl> -DWITH_SSL="system" +# or +# - cmake -DWITH_SSL=</path/to/custom/openssl> +# +# The default value for WITH_SSL is "bundled" +# set in cmake/build_configurations/feature_set.cmake +# +# For custom build/install of openssl, see the accompanying README and +# INSTALL* files. When building with gcc, you must build the shared libraries +# (in addition to the static ones): +# ./config --prefix=</path/to/custom/openssl> --shared; make; make install +# On some platforms (mac) you need to choose 32/64 bit architecture. +# Build/Install of openssl on windows is slightly different: you need to run +# perl and nmake. You might also need to +# 'set path=</path/to/custom/openssl>\bin;%PATH% +# in order to find the .dll files at runtime. + +SET(WITH_SSL_DOC "bundled (use wolfssl)") +SET(WITH_SSL_DOC + "${WITH_SSL_DOC}, yes (prefer os library if present, otherwise use bundled)") +SET(WITH_SSL_DOC + "${WITH_SSL_DOC}, system (use os library)") +SET(WITH_SSL_DOC + "${WITH_SSL_DOC}, </path/to/custom/installation>") + +MACRO (CHANGE_SSL_SETTINGS string) + SET(WITH_SSL ${string} CACHE STRING ${WITH_SSL_DOC} FORCE) +ENDMACRO() + +MACRO (MYSQL_USE_BUNDLED_SSL) + SET(INC_DIRS + ${CMAKE_BINARY_DIR}/extra/wolfssl + ${CMAKE_SOURCE_DIR}/extra/wolfssl/wolfssl + ${CMAKE_SOURCE_DIR}/extra/wolfssl/wolfssl/wolfssl + ) + SET(SSL_LIBRARIES wolfssl wolfcrypt) + SET(SSL_INCLUDE_DIRS ${INC_DIRS}) + SET(SSL_DEFINES "-DHAVE_OPENSSL -DHAVE_WOLFSSL -DWOLFSSL_USER_SETTINGS") + SET(HAVE_ERR_remove_thread_state ON CACHE INTERNAL "wolfssl doesn't have ERR_remove_thread_state") + SET(HAVE_EncryptAes128Ctr OFF CACHE INTERNAL "wolfssl does support AES-CTR, but differently from openssl") + SET(HAVE_EncryptAes128Gcm OFF CACHE INTERNAL "wolfssl does not support AES-GCM") + SET(HAVE_X509_check_host ON CACHE INTERNAL "wolfssl does support X509_check_host") + CHANGE_SSL_SETTINGS("bundled") + ADD_SUBDIRECTORY(extra/wolfssl) + MESSAGE_ONCE(SSL_LIBRARIES "SSL_LIBRARIES = ${SSL_LIBRARIES}") +ENDMACRO() + +# MYSQL_CHECK_SSL +# +# Provides the following configure options: +# WITH_SSL=[yes|bundled|system|<path/to/custom/installation>] +MACRO (MYSQL_CHECK_SSL) + IF(NOT WITH_SSL) + IF(WIN32) + CHANGE_SSL_SETTINGS("bundled") + ELSE() + SET(WITH_SSL "yes") + ENDIF() + ENDIF() + + # See if WITH_SSL is of the form </path/to/custom/installation> + FILE(GLOB WITH_SSL_HEADER ${WITH_SSL}/include/openssl/ssl.h) + IF (WITH_SSL_HEADER) + SET(WITH_SSL_PATH ${WITH_SSL} CACHE PATH "path to custom SSL installation") + ENDIF() + + IF(WITH_SSL STREQUAL "bundled") + MYSQL_USE_BUNDLED_SSL() + # Reset some variables, in case we switch from /path/to/ssl to "bundled". + IF (WITH_SSL_PATH) + UNSET(WITH_SSL_PATH) + UNSET(WITH_SSL_PATH CACHE) + ENDIF() + IF (OPENSSL_ROOT_DIR) + UNSET(OPENSSL_ROOT_DIR) + UNSET(OPENSSL_ROOT_DIR CACHE) + ENDIF() + IF (OPENSSL_INCLUDE_DIR) + UNSET(OPENSSL_INCLUDE_DIR) + UNSET(OPENSSL_INCLUDE_DIR CACHE) + ENDIF() + IF (WIN32 AND OPENSSL_APPLINK_C) + UNSET(OPENSSL_APPLINK_C) + UNSET(OPENSSL_APPLINK_C CACHE) + ENDIF() + IF (OPENSSL_SSL_LIBRARY) + UNSET(OPENSSL_SSL_LIBRARY) + UNSET(OPENSSL_SSL_LIBRARY CACHE) + ENDIF() + ELSEIF(WITH_SSL STREQUAL "system" OR + WITH_SSL STREQUAL "yes" OR + WITH_SSL_PATH + ) + IF(NOT OPENSSL_ROOT_DIR) + IF(WITH_SSL_PATH) + SET(OPENSSL_ROOT_DIR ${WITH_SSL_PATH}) + ENDIF() + ENDIF() + FIND_PACKAGE(OpenSSL) + SET_PACKAGE_PROPERTIES(OpenSSL PROPERTIES TYPE RECOMMENDED) + IF(OPENSSL_FOUND) + SET(OPENSSL_LIBRARY ${OPENSSL_SSL_LIBRARY}) + INCLUDE(CheckSymbolExists) + SET(SSL_SOURCES "") + SET(SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY}) + IF(CMAKE_SYSTEM_NAME MATCHES "SunOS") + SET(SSL_LIBRARIES ${SSL_LIBRARIES} ${LIBSOCKET}) + ENDIF() + IF(CMAKE_SYSTEM_NAME MATCHES "Linux") + SET(SSL_LIBRARIES ${SSL_LIBRARIES} ${CMAKE_DL_LIBS}) + ENDIF() + + MESSAGE_ONCE(OPENSSL_INCLUDE_DIR "OPENSSL_INCLUDE_DIR = ${OPENSSL_INCLUDE_DIR}") + MESSAGE_ONCE(OPENSSL_SSL_LIBRARY "OPENSSL_SSL_LIBRARY = ${OPENSSL_SSL_LIBRARY}") + MESSAGE_ONCE(OPENSSL_CRYPTO_LIBRARY "OPENSSL_CRYPTO_LIBRARY = ${OPENSSL_CRYPTO_LIBRARY}") + MESSAGE_ONCE(OPENSSL_VERSION "OPENSSL_VERSION = ${OPENSSL_VERSION}") + MESSAGE_ONCE(SSL_LIBRARIES "SSL_LIBRARIES = ${SSL_LIBRARIES}") + SET(SSL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR}) + SET(SSL_INTERNAL_INCLUDE_DIRS "") + SET(SSL_DEFINES "-DHAVE_OPENSSL") + + SET(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) + SET(CMAKE_REQUIRED_LIBRARIES ${SSL_LIBRARIES}) + SET(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) + CHECK_SYMBOL_EXISTS(ERR_remove_thread_state "openssl/err.h" + HAVE_ERR_remove_thread_state) + CHECK_SYMBOL_EXISTS(EVP_aes_128_ctr "openssl/evp.h" + HAVE_EncryptAes128Ctr) + CHECK_SYMBOL_EXISTS(EVP_aes_128_gcm "openssl/evp.h" + HAVE_EncryptAes128Gcm) + CHECK_SYMBOL_EXISTS(X509_check_host "openssl/x509v3.h" + HAVE_X509_check_host) + SET(CMAKE_REQUIRED_INCLUDES) + SET(CMAKE_REQUIRED_LIBRARIES) + ELSE() + IF(WITH_SSL STREQUAL "system") + MESSAGE(FATAL_ERROR "Cannot find appropriate system libraries for SSL. Use WITH_SSL=bundled to enable SSL support") + ENDIF() + MYSQL_USE_BUNDLED_SSL() + ENDIF() + ELSE() + MESSAGE(FATAL_ERROR + "Wrong option for WITH_SSL. Valid values are: ${WITH_SSL_DOC}") + ENDIF() +ENDMACRO() + + +# Many executables will depend on libeay32.dll and ssleay32.dll at runtime. +# In order to ensure we find the right version(s), we copy them into +# the same directory as the executables. +# NOTE: Using dlls will likely crash in malloc/free, +# see INSTALL.W32 which comes with the openssl sources. +# So we should be linking static versions of the libraries. +MACRO (COPY_OPENSSL_DLLS target_name) + IF (WIN32 AND WITH_SSL_PATH) + GET_FILENAME_COMPONENT(CRYPTO_NAME "${OPENSSL_CRYPTO_LIBRARY}" NAME_WE) + GET_FILENAME_COMPONENT(OPENSSL_NAME "${OPENSSL_SSL_LIBRARY}" NAME_WE) + FILE(GLOB HAVE_CRYPTO_DLL "${WITH_SSL_PATH}/bin/${CRYPTO_NAME}.dll") + FILE(GLOB HAVE_OPENSSL_DLL "${WITH_SSL_PATH}/bin/${OPENSSL_NAME}.dll") + IF (HAVE_CRYPTO_DLL AND HAVE_OPENSSL_DLL) + ADD_CUSTOM_COMMAND(OUTPUT ${target_name} + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${WITH_SSL_PATH}/bin/${CRYPTO_NAME}.dll" + "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${CRYPTO_NAME}.dll" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${WITH_SSL_PATH}/bin/${OPENSSL_NAME}.dll" + "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${OPENSSL_NAME}.dll" + ) + ADD_CUSTOM_TARGET(${target_name} ALL) + ENDIF() + ENDIF() +ENDMACRO() diff --git a/cmake/stack_direction.c b/cmake/stack_direction.c new file mode 100644 index 00000000..1f7a5d0b --- /dev/null +++ b/cmake/stack_direction.c @@ -0,0 +1,33 @@ +/* + Copyright (c) 2009 Sun Microsystems, Inc. + Use is subject to license terms. + + 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 + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */ + +/* Check stack direction (0-down, 1-up) */ +int f(int *a) +{ + int b; + return(&b > a)?1:0; +} +/* + Prevent compiler optimizations by calling function + through pointer. +*/ +volatile int (*ptr_f)(int *) = f; +int main() +{ + int a; + return ptr_f(&a); +} diff --git a/cmake/submodules.cmake b/cmake/submodules.cmake new file mode 100644 index 00000000..91f9f9e4 --- /dev/null +++ b/cmake/submodules.cmake @@ -0,0 +1,41 @@ +# update submodules automatically + +OPTION(UPDATE_SUBMODULES "Update submodules automatically" ON) +IF(NOT UPDATE_SUBMODULES) + RETURN() +ENDIF() + +IF(GIT_EXECUTABLE AND EXISTS "${CMAKE_SOURCE_DIR}/.git") + EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" config --get cmake.update-submodules + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + OUTPUT_VARIABLE cmake_update_submodules + RESULT_VARIABLE git_config_get_result) + IF(cmake_update_submodules MATCHES no) + SET(update_result 0) + SET(SUBMODULE_UPDATE_CONFIG_MESSAGE +"\n\nTo update submodules automatically, set cmake.update-submodules to 'yes', or 'force' to update automatically: + ${GIT_EXECUTABLE} config cmake.update-submodules yes") + ELSEIF(git_config_get_result EQUAL 128) + SET(update_result 0) + ELSEIF (cmake_update_submodules MATCHES force) + MESSAGE(STATUS "Updating submodules (forced)") + EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update --init --force --recursive --depth=1 + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE update_result) + ELSEIF (cmake_update_submodules MATCHES yes) + EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update --init --recursive --depth=1 + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE update_result) + ELSE() + MESSAGE(STATUS "Updating submodules") + EXECUTE_PROCESS(COMMAND "${GIT_EXECUTABLE}" submodule update --init --recursive --depth=1 + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE update_result) + ENDIF() +ENDIF() + +IF(update_result OR NOT EXISTS ${CMAKE_SOURCE_DIR}/libmariadb/CMakeLists.txt) + MESSAGE(FATAL_ERROR "No MariaDB Connector/C! Run + ${GIT_EXECUTABLE} submodule update --init --recursive +Then restart the build.${SUBMODULE_UPDATE_CONFIG_MESSAGE}") +ENDIF() diff --git a/cmake/symlinks.cmake b/cmake/symlinks.cmake new file mode 100644 index 00000000..3f3b4e4a --- /dev/null +++ b/cmake/symlinks.cmake @@ -0,0 +1,54 @@ +# Create lists +if(COMMAND REGISTER_SYMLINK) + return() +endif() + +macro(REGISTER_SYMLINK from to) + list(APPEND MARIADB_SYMLINK_FROMS ${from}) + list(APPEND MARIADB_SYMLINK_TOS ${to}) +endmacro() + +# MariaDB names for executables +REGISTER_SYMLINK("mariadb" "mysql") +REGISTER_SYMLINK("mariadb-access" "mysqlaccess") +REGISTER_SYMLINK("mariadb-admin" "mysqladmin") +REGISTER_SYMLINK("mariadb-backup" "mariabackup") +REGISTER_SYMLINK("mariadb-binlog" "mysqlbinlog") +REGISTER_SYMLINK("mariadb-check" "mysqlcheck") +REGISTER_SYMLINK("mariadb-client-test-embedded" "mysql_client_test_embedded") +REGISTER_SYMLINK("mariadb-client-test" "mysql_client_test") +REGISTER_SYMLINK("mariadb_config" "mysql_config") +REGISTER_SYMLINK("mariadb-convert-table-format" "mysql_convert_table_format") +REGISTER_SYMLINK("mariadb-dump" "mysqldump") +REGISTER_SYMLINK("mariadb-dumpslow" "mysqldumpslow") +REGISTER_SYMLINK("mariadb-embedded" "mysql_embedded") +REGISTER_SYMLINK("mariadb-find-rows" "mysql_find_rows") +REGISTER_SYMLINK("mariadb-fix-extensions" "mysql_fix_extensions") +REGISTER_SYMLINK("mariadb-hotcopy" "mysqlhotcopy") +REGISTER_SYMLINK("mariadb-import" "mysqlimport") +REGISTER_SYMLINK("mariadb-install-db" "mysql_install_db") +REGISTER_SYMLINK("mariadb-ldb" "mysql_ldb") +REGISTER_SYMLINK("mariadb-plugin" "mysql_plugin") +REGISTER_SYMLINK("mariadb-secure-installation" "mysql_secure_installation") +REGISTER_SYMLINK("mariadb-setpermission" "mysql_setpermission") +REGISTER_SYMLINK("mariadb-show" "mysqlshow") +REGISTER_SYMLINK("mariadb-slap" "mysqlslap") +REGISTER_SYMLINK("mariadb-test" "mysqltest") +REGISTER_SYMLINK("mariadb-test-embedded" "mysqltest_embedded") +REGISTER_SYMLINK("mariadb-tzinfo-to-sql" "mysql_tzinfo_to_sql") +REGISTER_SYMLINK("mariadb-upgrade" "mysql_upgrade") +REGISTER_SYMLINK("mariadb-upgrade-service" "mysql_upgrade_service") +REGISTER_SYMLINK("mariadb-upgrade-wizard" "mysql_upgrade_wizard") +REGISTER_SYMLINK("mariadb-waitpid" "mysql_waitpid") +REGISTER_SYMLINK("mariadbd" "mysqld") +REGISTER_SYMLINK("mariadbd-multi" "mysqld_multi") +REGISTER_SYMLINK("mariadbd-safe" "mysqld_safe") +REGISTER_SYMLINK("mariadbd-safe-helper" "mysqld_safe_helper") + +MACRO(GET_SYMLINK name out) + set(${out}) + list(FIND MARIADB_SYMLINK_FROMS ${name} _index) + if (${_index} GREATER -1) + list(GET MARIADB_SYMLINK_TOS ${_index} ${out}) + endif() +ENDMACRO() diff --git a/cmake/systemd.cmake b/cmake/systemd.cmake new file mode 100644 index 00000000..978be0b9 --- /dev/null +++ b/cmake/systemd.cmake @@ -0,0 +1,70 @@ +# Copyright (c) 2015, Daniel Black. 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +MACRO(CHECK_SYSTEMD) + IF(UNIX) + INCLUDE(FindPkgConfig) + # http://www.cmake.org/cmake/help/v3.0/module/FindPkgConfig.html + SET(WITH_SYSTEMD "auto" CACHE STRING "Enable systemd scripts and notification support") + IF(WITH_SYSTEMD STREQUAL "yes" OR WITH_SYSTEMD STREQUAL "auto") + IF(PKG_CONFIG_FOUND) + IF (NOT DEFINED LIBSYSTEMD_FOUND) + IF(WITH_SYSTEMD STREQUAL "yes") + pkg_search_module(LIBSYSTEMD REQUIRED libsystemd libsystemd-daemon) + ELSE() + pkg_search_module(LIBSYSTEMD libsystemd libsystemd-daemon) + ENDIF() + ENDIF() + IF(HAVE_DLOPEN) + SET(LIBSYSTEMD ${LIBSYSTEMD_LDFLAGS} ${LIBSYSTEMD_LIBRARIES}) + ELSE() + SET(LIBSYSTEMD ${LIBSYSTEMD_STATIC_LDFLAGS} ${LIBSYSTEMD_STATIC_LIBRARIES}) + ENDIF() + ELSE() + SET(LIBSYSTEMD systemd) + ENDIF() + SET(CMAKE_REQUIRED_LIBRARIES ${LIBSYSTEMD}) + CHECK_LIBRARY_EXISTS(systemd sd_listen_fds "" HAVE_SYSTEMD_SD_LISTEN_FDS) + CHECK_INCLUDE_FILES(systemd/sd-daemon.h HAVE_SYSTEMD_SD_DAEMON_H) + CHECK_FUNCTION_EXISTS(sd_notify HAVE_SYSTEMD_SD_NOTIFY) + CHECK_FUNCTION_EXISTS(sd_notifyf HAVE_SYSTEMD_SD_NOTIFYF) + SET(CMAKE_REQUIRED_LIBRARIES) + IF(HAVE_SYSTEMD_SD_DAEMON_H AND HAVE_SYSTEMD_SD_LISTEN_FDS + AND HAVE_SYSTEMD_SD_NOTIFY AND HAVE_SYSTEMD_SD_NOTIFYF) + SET(HAVE_SYSTEMD TRUE) + SET(SYSTEMD_SCRIPTS mariadb-service-convert galera_new_cluster galera_recovery) + IF(DEB) + SET(SYSTEMD_EXECSTARTPRE "ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld") + SET(SYSTEMD_EXECSTARTPOST "ExecStartPost=/etc/mysql/debian-start") + ENDIF() + MESSAGE_ONCE(systemd "Systemd features enabled") + ELSE() + UNSET(LIBSYSTEMD) + UNSET(HAVE_SYSTEMD) + UNSET(HAVE_SYSTEMD_SD_DAEMON_H) + UNSET(HAVE_SYSTEMD_SD_LISTEN_FDS) + UNSET(HAVE_SYSTEMD_SD_NOTIFY) + UNSET(HAVE_SYSTEMD_SD_NOTIFYF) + MESSAGE_ONCE(systemd "Systemd features not enabled") + IF(WITH_SYSTEMD STREQUAL "yes") + MESSAGE(FATAL_ERROR "Requested WITH_SYSTEMD=yes however no dependencies installed/found") + ENDIF() + ENDIF() + ELSEIF(NOT WITH_SYSTEMD STREQUAL "no") + MESSAGE(FATAL_ERROR "Invalid value for WITH_SYSTEMD. Must be 'yes', 'no', or 'auto'.") + ENDIF() + ADD_FEATURE_INFO(SYSTEMD LIBSYSTEMD "Systemd scripts and notification support") + ENDIF() +ENDMACRO() diff --git a/cmake/tags.cmake b/cmake/tags.cmake new file mode 100644 index 00000000..309bfae9 --- /dev/null +++ b/cmake/tags.cmake @@ -0,0 +1,26 @@ +# Copyright (c) 2010, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# Generate tag files +IF(UNIX) + ADD_CUSTOM_TARGET (tags + COMMAND support-files/build-tags + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + ADD_CUSTOM_TARGET (ctags + COMMAND ctags -R -f CTAGS + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) +ENDIF() diff --git a/cmake/versioninfo.rc.in b/cmake/versioninfo.rc.in new file mode 100644 index 00000000..29b39353 --- /dev/null +++ b/cmake/versioninfo.rc.in @@ -0,0 +1,38 @@ +// Copyright (c) 2009, 2010, 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 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 +// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +#include <windows.h> +VS_VERSION_INFO VERSIONINFO +FILEVERSION @MAJOR_VERSION@,@MINOR_VERSION@,@PATCH_VERSION@,@TINY_VERSION@ +PRODUCTVERSION @MAJOR_VERSION@,@MINOR_VERSION@,@PATCH_VERSION@,@TINY_VERSION@ +FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +FILEFLAGS 0 +FILEOS VOS__WINDOWS32 +FILETYPE @FILETYPE@ +FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "FileVersion", "@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@.@TINY_VERSION@\0" + VALUE "ProductVersion", "@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@.@TINY_VERSION@\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END diff --git a/cmake/win_compatibility.manifest b/cmake/win_compatibility.manifest new file mode 100644 index 00000000..2e4b27a6 --- /dev/null +++ b/cmake/win_compatibility.manifest @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> + <application> + <!-- Windows Vista and Windows Server 2008 --> + <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> + + <!-- Windows 7 and Windows Server 2008 R2 --> + <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> + + <!-- Windows 8 and Windows Server 2012 --> + <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> + + <!-- Windows 8.1 and Windows Server 2012 R2 --> + <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> + + <!-- Windows 10 --> + <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> + + </application> + </compatibility> +</asmv1:assembly> diff --git a/cmake/wsrep.cmake b/cmake/wsrep.cmake new file mode 100644 index 00000000..368ae61d --- /dev/null +++ b/cmake/wsrep.cmake @@ -0,0 +1,70 @@ +# Copyright (c) 2011, Codership Oy <info@codership.com>. +# Copyright (c) 2013, Monty Program Ab. +# +# 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +# +# Galera library does not compile with windows +# +IF (NOT WITHOUT_SERVER) +IF(UNIX) + SET(with_wsrep_default ON) +ELSE() + SET(with_wsrep_default OFF) +ENDIF() + +OPTION(WITH_WSREP "WSREP replication API (to use, e.g. Galera Replication library)" ${with_wsrep_default}) +OPTION(WITH_WSREP_ALL + "Build all components of WSREP (unit tests, sample programs)" + OFF) + +IF(WITH_WSREP) + # Set the patch version + SET(WSREP_PATCH_VERSION "22") + + IF(NOT EXISTS "${CMAKE_SOURCE_DIR}/wsrep-lib/wsrep-API/v26/wsrep_api.h") + MESSAGE(FATAL_ERROR "No MariaDB wsrep-API code! Run + ${GIT_EXECUTABLE} submodule update --init --recursive +Then restart the build. +") + ENDIF() + # Obtain wsrep API version + FILE(STRINGS "${CMAKE_SOURCE_DIR}/wsrep-lib/wsrep-API/v26/wsrep_api.h" WSREP_API_VERSION + LIMIT_COUNT 1 REGEX "WSREP_INTERFACE_VERSION") + STRING(REGEX MATCH "([0-9]+)" WSREP_API_VERSION "${WSREP_API_VERSION}") + + SET(WSREP_VERSION "${WSREP_API_VERSION}.${WSREP_PATCH_VERSION}" + CACHE INTERNAL "WSREP version") + + SET(WSREP_PROC_INFO ${WITH_WSREP}) + + SET(WSREP_PATCH_VERSION "wsrep_${WSREP_VERSION}") + if (NOT WITH_WSREP_ALL) + SET(WSREP_LIB_WITH_UNIT_TESTS OFF CACHE BOOL + "Disable unit tests for wsrep-lib") + SET(WSREP_LIB_WITH_DBSIM OFF CACHE BOOL + "Disable building dbsim for wsrep-lib") + endif() + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/wsrep-lib/include) + INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/wsrep-lib/wsrep-API/v26) + + SET(old_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}) + SET(BUILD_SHARED_LIBS OFF) + ADD_SUBDIRECTORY(wsrep-lib) + SET(BUILD_SHARED_LIBS ${old_BUILD_SHARED_LIBS}) +ENDIF() +IF (NOT WIN32) + ADD_FEATURE_INFO(WSREP WITH_WSREP "WSREP replication API (to use, e.g. Galera Replication library)") +ENDIF() +ENDIF(NOT WITHOUT_SERVER) diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake new file mode 100644 index 00000000..628bbf15 --- /dev/null +++ b/cmake/zlib.cmake @@ -0,0 +1,62 @@ +# Copyright (c) 2009, 2018, 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 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA + +MACRO (MYSQL_USE_BUNDLED_ZLIB) + SET(ZLIB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/zlib ${CMAKE_BINARY_DIR}/zlib) + SET(BUILD_BUNDLED_ZLIB 1) + SET(ZLIB_LIBRARY zlib CACHE INTERNAL "Bundled zlib library") + SET(ZLIB_FOUND TRUE) + SET(WITH_ZLIB "bundled" CACHE STRING "Use bundled zlib") + ADD_SUBDIRECTORY(zlib) +ENDMACRO() + +# MYSQL_CHECK_ZLIB_WITH_COMPRESS +# +# Provides the following configure options: +# WITH_ZLIB_BUNDLED +# If this is set,we use bindled zlib +# If this is not set,search for system zlib. +# if system zlib is not found, use bundled copy +# ZLIB_LIBRARIES, ZLIB_INCLUDE_DIR and ZLIB_SOURCES +# are set after this macro has run + +MACRO (MYSQL_CHECK_ZLIB_WITH_COMPRESS) + + IF(WITH_ZLIB STREQUAL "bundled") + MYSQL_USE_BUNDLED_ZLIB() + ELSE() + INCLUDE(FindZLIB) + IF(ZLIB_FOUND) + INCLUDE(CheckFunctionExists) + SET(CMAKE_REQUIRED_LIBRARIES z) + CHECK_FUNCTION_EXISTS(crc32 HAVE_CRC32) + CHECK_FUNCTION_EXISTS(compressBound HAVE_COMPRESSBOUND) + CHECK_FUNCTION_EXISTS(deflateBound HAVE_DEFLATEBOUND) + SET(CMAKE_REQUIRED_LIBRARIES) + IF(HAVE_CRC32 AND HAVE_COMPRESSBOUND AND HAVE_DEFLATEBOUND) + SET(WITH_ZLIB "system" CACHE STRING + "Which zlib to use (possible values are 'bundled' or 'system')") + SET(ZLIB_SOURCES "") + ELSE() + SET(ZLIB_FOUND FALSE CACHE INTERNAL "Zlib found but not usable") + MESSAGE(STATUS "system zlib found but not usable") + ENDIF() + ENDIF() + IF(NOT ZLIB_FOUND) + MYSQL_USE_BUNDLED_ZLIB() + ENDIF() + ENDIF() + SET(HAVE_COMPRESS 1) +ENDMACRO() |