diff options
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/abi_check.cmake | 2 | ||||
-rw-r--r-- | cmake/build_configurations/mysql_release.cmake | 59 | ||||
-rw-r--r-- | cmake/bzip2.cmake | 33 | ||||
-rw-r--r-- | cmake/check_compiler_flag.cmake | 56 | ||||
-rw-r--r-- | cmake/configure.pl | 18 | ||||
-rw-r--r-- | cmake/cpack_rpm.cmake | 44 | ||||
-rw-r--r-- | cmake/cpack_source_ignore_files.cmake | 2 | ||||
-rw-r--r-- | cmake/cpu_info.cmake | 28 | ||||
-rw-r--r-- | cmake/dtrace.cmake | 3 | ||||
-rw-r--r-- | cmake/for_clients.cmake | 77 | ||||
-rw-r--r-- | cmake/info_macros.cmake.in | 6 | ||||
-rw-r--r-- | cmake/install_layout.cmake | 18 | ||||
-rw-r--r-- | cmake/install_macros.cmake | 19 | ||||
-rw-r--r-- | cmake/jemalloc.cmake | 2 | ||||
-rw-r--r-- | cmake/lz4.cmake | 54 | ||||
-rw-r--r-- | cmake/lzma.cmake | 33 | ||||
-rw-r--r-- | cmake/lzo.cmake | 48 | ||||
-rw-r--r-- | cmake/maintainer.cmake | 62 | ||||
-rw-r--r-- | cmake/mysql_version.cmake | 8 | ||||
-rw-r--r-- | cmake/os/Windows.cmake | 3 | ||||
-rw-r--r-- | cmake/os/WindowsCache.cmake | 3 | ||||
-rw-r--r-- | cmake/package_name.cmake | 7 | ||||
-rw-r--r-- | cmake/plugin.cmake | 201 | ||||
-rw-r--r-- | cmake/readline.cmake | 4 | ||||
-rw-r--r-- | cmake/snappy.cmake | 32 | ||||
-rw-r--r-- | cmake/ssl.cmake | 43 | ||||
-rw-r--r-- | cmake/systemd.cmake | 86 | ||||
-rw-r--r-- | cmake/wsrep.cmake | 43 |
28 files changed, 765 insertions, 229 deletions
diff --git a/cmake/abi_check.cmake b/cmake/abi_check.cmake index e8d2737f116..02124ae7ba1 100644 --- a/cmake/abi_check.cmake +++ b/cmake/abi_check.cmake @@ -43,6 +43,8 @@ IF(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang" AND RUN_ABI_CHECK) ${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 ) ADD_CUSTOM_TARGET(abi_check ALL diff --git a/cmake/build_configurations/mysql_release.cmake b/cmake/build_configurations/mysql_release.cmake index 78314342426..04860a40dbb 100644 --- a/cmake/build_configurations/mysql_release.cmake +++ b/cmake/build_configurations/mysql_release.cmake @@ -47,8 +47,6 @@ SET(FEATURE_SET_large 5) SET(FEATURE_SET_xlarge 6) SET(FEATURE_SET_community 7) -#SET(WITH_CASSANDRA_STORAGE_ENGINE ON) - IF(FEATURE_SET) STRING(TOLOWER ${FEATURE_SET} feature_set) SET(num ${FEATURE_SET_${feature_set}}) @@ -57,7 +55,7 @@ IF(FEATURE_SET) Should be xsmall, small, classic, large, or community ") ENDIF() - SET(WITH_PARTITION_STORAGE_ENGINE OFF) + SET(PLUGIN_PARTITION "NO") IF(num EQUAL FEATURE_SET_xsmall) SET(WITH_NONE ON) ENDIF() @@ -66,50 +64,46 @@ IF(FEATURE_SET) SET(WITH_EMBEDDED_SERVER ON CACHE BOOL "") ENDIF() IF(num GREATER FEATURE_SET_small) - SET(WITH_ARCHIVE_STORAGE_ENGINE ON) - SET(WITH_BLACKHOLE_STORAGE_ENGINE ON) - SET(WITH_FEDERATEDX_STORAGE_ENGINE ON) - SET(WITH_PLUGIN_FEEDBACK ON) + SET(PLUGIN_ARCHIVE "STATIC") + SET(PLUGIN_BLACKHOLE "STATIC") + SET(PLUGIN_FEDERATEDX "STATIC") + SET(PLUGIN_FEEDBACK "STATIC") ENDIF() IF(num GREATER FEATURE_SET_classic) - SET(WITH_INNOBASE_STORAGE_ENGINE ON) + SET(PLUGIN_INNOBASE "STATIC") ENDIF() IF(num GREATER FEATURE_SET_large) - SET(WITH_PARTITION_STORAGE_ENGINE ON) + 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() - - # Update cache with current values, remove engines we do not care about - # from build. - FOREACH(eng ARCHIVE BLACKHOLE FEDERATED INNOBASE PARTITION) - IF(NOT WITH_${eng}_STORAGE_ENGINE) - SET(WITHOUT_${eng}_STORAGE_ENGINE ON CACHE BOOL "") - MARK_AS_ADVANCED(WITHOUT_${eng}_STORAGE_ENGINE) - SET(WITH_${eng}_STORAGE_ENGINE OFF CACHE BOOL "") - ELSE() - SET(WITH_${eng}_STORAGE_ENGINE ON CACHE BOOL "") - ENDIF() - ENDFOREACH() ENDIF() OPTION(ENABLED_LOCAL_INFILE "" ON) -IF(RPM) +SET(WITH_INNODB_SNAPPY OFF CACHE STRING "") +IF(WIN32) + SET(WITH_LIBARCHIVE STATIC CACHE STRING "") +ELSEIF(RPM) SET(WITH_SSL system CACHE STRING "") SET(WITH_ZLIB system CACHE STRING "") SET(CHECKMODULE /usr/bin/checkmodule CACHE STRING "") SET(SEMODULE_PACKAGE /usr/bin/semodule_package CACHE STRING "") + SET(WITH_LIBARCHIVE ON 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(WITH_LIBARCHIVE ON CACHE STRING "") ELSE() SET(WITH_SSL bundled CACHE STRING "") SET(WITH_ZLIB bundled CACHE STRING "") + SET(WITH_JEMALLOC static CACHE STRING "") + SET(WITH_LIBARCHIVE STATIC CACHE STRING "") ENDIF() IF(NOT COMPILATION_COMMENT) @@ -127,8 +121,6 @@ IF(UNIX) SET(WITH_EXTRA_CHARSETS all CACHE STRING "") IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") - SET(WITH_JEMALLOC "static" CACHE STRING "") - IF(NOT IGNORE_AIO_CHECK) # Ensure aio is available on Linux (required by InnoDB) CHECK_INCLUDE_FILES(libaio.h HAVE_LIBAIO_H) @@ -172,6 +164,25 @@ IF(UNIX) 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") diff --git a/cmake/bzip2.cmake b/cmake/bzip2.cmake new file mode 100644 index 00000000000..0c15853d0b9 --- /dev/null +++ b/cmake/bzip2.cmake @@ -0,0 +1,33 @@ +# Copyright (C) 2014, SkySQL Ab. 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 + +SET(WITH_INNODB_BZIP2 AUTO CACHE STRING + "Build with bzip2. Possible values are 'ON', 'OFF', 'AUTO' and default is 'AUTO'") + +MACRO (MYSQL_CHECK_BZIP2) + IF (WITH_INNODB_BZIP2 STREQUAL "ON" OR WITH_INNODB_BZIP2 STREQUAL "AUTO") + CHECK_INCLUDE_FILES(bzlib.h HAVE_BZLIB2_H) + CHECK_LIBRARY_EXISTS(bz2 BZ2_bzBuffToBuffCompress "" HAVE_BZLIB2_COMPRESS) + CHECK_LIBRARY_EXISTS(bz2 BZ2_bzBuffToBuffDecompress "" HAVE_BZLIB2_DECOMPRESS) + + IF (HAVE_BZLIB2_COMPRESS AND HAVE_BZLIB2_DECOMPRESS AND HAVE_BZLIB2_H) + ADD_DEFINITIONS(-DHAVE_BZIP2=1) + LINK_LIBRARIES(bz2) + ELSE() + IF (WITH_INNODB_BZIP2 STREQUAL "ON") + MESSAGE(FATAL_ERROR "Required bzip2 library is not found") + ENDIF() + ENDIF() + ENDIF() +ENDMACRO() diff --git a/cmake/check_compiler_flag.cmake b/cmake/check_compiler_flag.cmake new file mode 100644 index 00000000000..673361ab8fe --- /dev/null +++ b/cmake/check_compiler_flag.cmake @@ -0,0 +1,56 @@ +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" + ) + +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/configure.pl b/cmake/configure.pl index a71795a3bc8..68baf436c1c 100644 --- a/cmake/configure.pl +++ b/cmake/configure.pl @@ -125,7 +125,7 @@ foreach my $option (@ARGV) foreach my $p (@plugins) { $p =~ s/-/_/g; - $cmakeargs = $cmakeargs." -DWITH_".uc($p)."=1"; + $cmakeargs = $cmakeargs." -DWITH_".uc($p)."=AUTO"; } next; } @@ -135,9 +135,14 @@ foreach my $option (@ARGV) $cmakeargs = $cmakeargs." -DWITH_EXTRA_CHARSETS=".$charsets; next; } - if($option =~ /without-plugin=/) + if($option =~ /without-plugin=/ || $option =~ /without-plugin-/) { - $cmakeargs = $cmakeargs." -DWITHOUT_".uc(substr($option,15))."=1"; + $cmakeargs = $cmakeargs." -DPLUGIN_".uc(substr($option,15))."=NO"; + next; + } + if($option =~ /with-plugin-(.*)=(.*)/) + { + $cmakeargs = $cmakeargs." -DPLUGIN_".uc($1)."=".uc($2); next; } if($option =~ /with-zlib-dir=bundled/) @@ -167,7 +172,7 @@ foreach my $option (@ARGV) } if($option =~ /with-debug/) { - $cmakeargs = $cmakeargs." -DCMAKE_BUILD_TYPE=Debug"; + $cmakeargs = $cmakeargs." -DCMAKE_BUILD_TYPE=Debug -DSECURITY_HARDENED=OFF"; next; } if($option =~ /with-ssl/) @@ -232,6 +237,11 @@ foreach my $option (@ARGV) $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"; diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index e5206d9690c..e80fb199f03 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -23,12 +23,16 @@ 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) + Common Client SharedLibraries ClientPlugins + backup +) -SET(CPACK_RPM_PACKAGE_NAME "MariaDB") +SET(CPACK_RPM_PACKAGE_NAME ${CPACK_PACKAGE_NAME}) IF(CMAKE_VERSION VERSION_LESS "3.6.0") SET(CPACK_PACKAGE_FILE_NAME "${CPACK_RPM_PACKAGE_NAME}-${VERSION}-${RPM}-${CMAKE_SYSTEM_PROCESSOR}") ELSE() @@ -41,8 +45,8 @@ 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 "http://mariadb.org") -SET(CPACK_RPM_PACKAGE_SUMMARY "MariaDB: a very fast and robust SQL database server") +SET(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_SUMMARY}) +SET(CPACK_RPM_PACKAGE_URL ${CPACK_PACKAGE_URL}) SET(CPACK_RPM_PACKAGE_DESCRIPTION "${CPACK_RPM_PACKAGE_SUMMARY} It is GPL v2 licensed, which means you can use the it free of charge under the @@ -60,8 +64,8 @@ SET(CPACK_RPM_SPEC_MORE_DEFINE " %define mysqldatadir ${INSTALL_MYSQLDATADIR} %define mysqld_user mysql %define mysqld_group mysql -%define _bindir ${CMAKE_INSTALL_PREFIX}/${INSTALL_BINDIR} -%define _sbindir ${CMAKE_INSTALL_PREFIX}/${INSTALL_SBINDIR} +%define _bindir ${INSTALL_BINDIRABS} +%define _sbindir ${INSTALL_SBINDIRABS} %define _sysconfdir ${INSTALL_SYSCONFDIR} ") @@ -83,14 +87,17 @@ SET(ignored "%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}/lib64" "%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/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}/*") @@ -100,6 +107,7 @@ SET(CPACK_RPM_client_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSC 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) @@ -127,6 +135,7 @@ SETA(CPACK_RPM_server_PACKAGE_OBSOLETES "MySQL" "mysql-server" "MySQL-server" + "MariaDB-Galera-server" "MySQL-OurDelta-server") SETA(CPACK_RPM_server_PACKAGE_PROVIDES "MariaDB" @@ -154,9 +163,20 @@ SETA(CPACK_RPM_test_PACKAGE_OBSOLETES SETA(CPACK_RPM_test_PACKAGE_PROVIDES "MySQL-test") -SETA(CPACK_RPM_server_PACKAGE_REQUIRES - ${CPACK_RPM_PACKAGE_REQUIRES} - "MariaDB-client") +SETA(CPACK_RPM_server_PACKAGE_REQUIRES + "${CPACK_RPM_PACKAGE_REQUIRES}" + "MariaDB-client") + +IF(WITH_WSREP) + SETA(CPACK_RPM_server_PACKAGE_REQUIRES + "galera" "rsync" "lsof" "grep" "gawk" "iproute" + "coreutils" "findutils" "tar") + IF (RPM MATCHES "sles11") + SETA(CPACK_RPM_server_PACKAGE_REQUIRES "util-linux") + ELSE() + SETA(CPACK_RPM_server_PACKAGE_REQUIRES "which") + ENDIF() +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) @@ -174,7 +194,7 @@ MACRO(ALTERNATIVE_NAME real alt) 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} ${alt}%{_isa}") + SET(${o} "${${o}} ${alt} ${alt}%{?_isa}") ENDMACRO(ALTERNATIVE_NAME) ALTERNATIVE_NAME("devel" "mysql-devel") diff --git a/cmake/cpack_source_ignore_files.cmake b/cmake/cpack_source_ignore_files.cmake index 0874311428e..0654fa38388 100644 --- a/cmake/cpack_source_ignore_files.cmake +++ b/cmake/cpack_source_ignore_files.cmake @@ -14,6 +14,8 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA SET(CPACK_SOURCE_IGNORE_FILES +\\\\.git/ +\\\\.gitignore CMakeCache\\\\.txt cmake_dist\\\\.cmake CPackSourceConfig\\\\.cmake diff --git a/cmake/cpu_info.cmake b/cmake/cpu_info.cmake index 32b98142ace..1772510e72b 100644 --- a/cmake/cpu_info.cmake +++ b/cmake/cpu_info.cmake @@ -15,15 +15,29 @@ # Symbols with information about the CPU. -FIND_PROGRAM(GETCONF getconf) -MARK_AS_ADVANCED(GETCONF) +IF(CMAKE_SYSTEM_NAME MATCHES "Darwin") + FIND_PROGRAM(SYSCTL sysctl) + MARK_AS_ADVANCED(SYSCTL) -IF(GETCONF) - EXECUTE_PROCESS( - COMMAND ${GETCONF} LEVEL1_DCACHE_LINESIZE - OUTPUT_VARIABLE CPU_LEVEL1_DCACHE_LINESIZE - ) + 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() + IF(CPU_LEVEL1_DCACHE_LINESIZE AND CPU_LEVEL1_DCACHE_LINESIZE GREATER 0) ELSE() SET(CPU_LEVEL1_DCACHE_LINESIZE 64) diff --git a/cmake/dtrace.cmake b/cmake/dtrace.cmake index 3edcdc4c1c5..d7ab0f31991 100644 --- a/cmake/dtrace.cmake +++ b/cmake/dtrace.cmake @@ -42,7 +42,8 @@ MACRO(CHECK_DTRACE) # 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 BUGGY_LINUX_DTRACE + AND NOT CMAKE_SYSTEM_NAME MATCHES "SunOS") SET(ENABLE_DTRACE ON CACHE BOOL "Enable dtrace") ENDIF() SET(HAVE_DTRACE ${ENABLE_DTRACE}) diff --git a/cmake/for_clients.cmake b/cmake/for_clients.cmake new file mode 100644 index 00000000000..dd79ea1039d --- /dev/null +++ b/cmake/for_clients.cmake @@ -0,0 +1,77 @@ +# +# 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() +IF(POLICY CMP0007) + CMAKE_POLICY(SET CMP0007 OLD) +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} ") + 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(mysqlclient LIBS) +EXTRACT_LINK_LIBRARIES(mysqlserver EMB_LIBS) + +SET(LIBS "-lmysqlclient ${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]UNIV_MUST_NOT_INLINE" "[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 lmtmalloc static-libcxa i-static static-intel) +REPLACE_FOR_CLIENTS(EMB_LIBS lmtmalloc static-libcxa i-static static-intel) + diff --git a/cmake/info_macros.cmake.in b/cmake/info_macros.cmake.in index fc2f8849337..89b04666c96 100644 --- a/cmake/info_macros.cmake.in +++ b/cmake/info_macros.cmake.in @@ -14,7 +14,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# Handle/create the "INFO_*" files describing a MySQL (server) binary. +# Handle/create the "INFO_*" files describing a MariaDB (server) binary. # This is part of the fix for bug#42969. @@ -81,7 +81,7 @@ MACRO(CREATE_INFO_SRC target_dir) # to debug, add: FILE(APPEND ${INFO_SRC} "\nResult ${RESULT}\n") # For better readability ... FILE(APPEND ${INFO_SRC} - "MySQL source ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}\n") + "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. @@ -96,7 +96,7 @@ MACRO(CREATE_INFO_SRC target_dir) FILE(WRITE ${INFO_SRC} "${SOURCE_INFO}\n") ELSE() # This is a fall-back. - FILE(WRITE ${INFO_SRC} "\nMySQL source ${VERSION}\n") + FILE(WRITE ${INFO_SRC} "\nMariaDB source ${VERSION}\n") ENDIF() ENDMACRO(CREATE_INFO_SRC) diff --git a/cmake/install_layout.cmake b/cmake/install_layout.cmake index ebf3852182c..5484691e94a 100644 --- a/cmake/install_layout.cmake +++ b/cmake/install_layout.cmake @@ -137,7 +137,7 @@ SET(INSTALL_SCRIPTDIR_RPM "bin") SET(INSTALL_SYSCONFDIR_RPM "/etc") SET(INSTALL_SYSCONF2DIR_RPM "/etc/my.cnf.d") # -IF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") +IF(CMAKE_SIZEOF_VOID_P EQUAL 8) SET(INSTALL_LIBDIR_RPM "lib64") SET(INSTALL_PLUGINDIR_RPM "lib64/mysql/plugin") ELSE() @@ -161,6 +161,9 @@ 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") # # DEB layout @@ -189,6 +192,10 @@ SET(INSTALL_SUPPORTFILESDIR_DEB "share/mysql") SET(INSTALL_MYSQLDATADIR_DEB "/var/lib/mysql") SET(INSTALL_UNIX_ADDRDIR_DEB "/var/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") + # # SVR4 layout # @@ -228,10 +235,17 @@ SET(OLD_INSTALL_LAYOUT ${INSTALL_LAYOUT} CACHE INTERNAL "") # will be defined as ${INSTALL_BINDIR_STANDALONE} by default if STANDALONE # layout is chosen) FOREACH(var BIN SBIN LIB MYSQLSHARE SHARE PLUGIN INCLUDE SCRIPT DOC MAN SYSCONF SYSCONF2 - INFO MYSQLTEST SQLBENCH DOCREADME SUPPORTFILES MYSQLDATA UNIX_ADDR) + INFO MYSQLTEST SQLBENCH DOCREADME SUPPORTFILES MYSQLDATA UNIX_ADDR + SYSTEMD_UNIT SYSTEMD_SYSUSERS SYSTEMD_TMPFILES) SET(INSTALL_${var}DIR ${INSTALL_${var}DIR_${INSTALL_LAYOUT}} CACHE STRING "${var} installation directory" ${FORCE}) MARK_AS_ADVANCED(INSTALL_${var}DIR) + + IF(IS_ABSOLUTE ${INSTALL_${var}DIR}) + SET(INSTALL_${var}DIRABS ${INSTALL_${var}DIR}) + ELSE() + SET(INSTALL_${var}DIRABS "${CMAKE_INSTALL_PREFIX}/${INSTALL_${var}DIR}") + ENDIF() ENDFOREACH() IF(NOT MYSQL_UNIX_ADDR) diff --git a/cmake/install_macros.cmake b/cmake/install_macros.cmake index 7da8edd22eb..121825f8f3c 100644 --- a/cmake/install_macros.cmake +++ b/cmake/install_macros.cmake @@ -35,11 +35,10 @@ FUNCTION (INSTALL_DEBUG_SYMBOLS) GET_TARGET_PROPERTY(target_type ${target} TYPE) set(comp "") - IF(ARG_COMPONENT STREQUAL "Server") - IF(target MATCHES "mysqld" OR type MATCHES "MODULE") - #MESSAGE("PDB: ${targets}") - SET(comp Server) - ENDIF() + + IF(target MATCHES "mysqld" OR type MATCHES "MODULE") + #MESSAGE("PDB: ${targets}") + SET(comp Server) ENDIF() IF(NOT comp MATCHES Server) @@ -115,13 +114,7 @@ FUNCTION(INSTALL_SCRIPT) SET(COMP) ENDIF() - INSTALL(FILES - ${script} - DESTINATION ${ARG_DESTINATION} - PERMISSIONS OWNER_READ OWNER_WRITE - OWNER_EXECUTE GROUP_READ GROUP_EXECUTE - WORLD_READ WORLD_EXECUTE ${COMP} - ) + INSTALL(PROGRAMS ${script} DESTINATION ${ARG_DESTINATION} ${COMP}) INSTALL_MANPAGE(${script}) ENDFUNCTION() @@ -289,7 +282,7 @@ FUNCTION(INSTALL_DEBUG_TARGET target) MESSAGE(FATAL_ERROR "Need DESTINATION parameter for INSTALL_DEBUG_TARGET") ENDIF() GET_TARGET_PROPERTY(target_location ${target} LOCATION) - IF(CMAKE_GENERATOR MATCHES "Makefiles") + IF(CMAKE_GENERATOR MATCHES "Makefiles|Ninja") STRING(REPLACE "${CMAKE_BINARY_DIR}" "${DEBUGBUILDDIR}" debug_target_location "${target_location}") ELSE() STRING(REPLACE "${CMAKE_CFG_INTDIR}" "Debug" debug_target_location "${target_location}" ) diff --git a/cmake/jemalloc.cmake b/cmake/jemalloc.cmake index 5a3c1bd935b..5ad636d0e6c 100644 --- a/cmake/jemalloc.cmake +++ b/cmake/jemalloc.cmake @@ -1,7 +1,7 @@ INCLUDE (CheckLibraryExists) SET(WITH_JEMALLOC auto CACHE STRING - "Build with jemalloc. Possible values are 'yes', 'no', 'auto'") + "Build with jemalloc. Possible values are 'yes', 'no', 'static', 'auto'") MACRO (CHECK_JEMALLOC) # compatibility with old WITH_JEMALLOC values diff --git a/cmake/lz4.cmake b/cmake/lz4.cmake new file mode 100644 index 00000000000..ec0e2aa85df --- /dev/null +++ b/cmake/lz4.cmake @@ -0,0 +1,54 @@ +# Copyright (C) 2014, SkySQL Ab. 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 + +SET(WITH_INNODB_LZ4 AUTO CACHE STRING + "Build with lz4. Possible values are 'ON', 'OFF', 'AUTO' and default is 'AUTO'") + +MACRO (MYSQL_CHECK_LZ4) + IF (WITH_INNODB_LZ4 STREQUAL "ON" OR WITH_INNODB_LZ4 STREQUAL "AUTO") + CHECK_INCLUDE_FILES(lz4.h HAVE_LZ4_H) + CHECK_LIBRARY_EXISTS(lz4 LZ4_compress_limitedOutput "" HAVE_LZ4_SHARED_LIB) + CHECK_LIBRARY_EXISTS(lz4 LZ4_compress_default "" HAVE_LZ4_COMPRESS_DEFAULT) + IF ((HAVE_LZ4_SHARED_LIB OR HAVE_LZ4_COMPRESS_DEFAULT) AND HAVE_LZ4_H) + IF (HAVE_LZ4_COMPRESS_DEFAULT) + ADD_DEFINITIONS(-DHAVE_LZ4_COMPRESS_DEFAULT=1) + ENDIF() + ADD_DEFINITIONS(-DHAVE_LZ4=1) + LINK_LIBRARIES(lz4) + ELSE() + IF (WITH_INNODB_LZ4 STREQUAL "ON") + MESSAGE(FATAL_ERROR "Required lz4 library is not found") + ENDIF() + ENDIF() + ENDIF() +ENDMACRO() + +MACRO (MYSQL_CHECK_LZ4_STATIC) + IF (WITH_INNODB_LZ4 STREQUAL "ON" OR WITH_INNODB_LZ4 STREQUAL "AUTO") + CHECK_INCLUDE_FILES(lz4.h HAVE_LZ4_H) + CHECK_LIBRARY_EXISTS(liblz4.a LZ4_compress_limitedOutput "" HAVE_LZ4_LIB) + CHECK_LIBRARY_EXISTS(liblz4.a LZ4_compress_default "" HAVE_LZ4_COMPRESS_DEFAULT) + IF ((HAVE_LZ4_LIB OR HAVE_LZ4_COMPRESS_DEFAULT) AND HAVE_LZ4_H) + IF (HAVE_LZ4_COMPRESS_DEFAULT) + ADD_DEFINITIONS(-DHAVE_LZ4_COMPRESS_DEFAULT=1) + ENDIF() + ADD_DEFINITIONS(-DHAVE_LZ4=1) + LINK_LIBRARIES(liblz4.a) + ELSE() + IF (WITH_INNODB_LZ4 STREQUAL "ON") + MESSAGE(FATAL_ERROR "Required lz4 library is not found") + ENDIF() + ENDIF() + ENDIF() +ENDMACRO() diff --git a/cmake/lzma.cmake b/cmake/lzma.cmake new file mode 100644 index 00000000000..12a28a17a43 --- /dev/null +++ b/cmake/lzma.cmake @@ -0,0 +1,33 @@ +# Copyright (C) 2014, SkySQL Ab. 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 + +SET(WITH_INNODB_LZMA AUTO CACHE STRING + "Build with lzma. Possible values are 'ON', 'OFF', 'AUTO' and default is 'AUTO'") + +MACRO (MYSQL_CHECK_LZMA) + IF (WITH_INNODB_LZMA STREQUAL "ON" OR WITH_INNODB_LZMA STREQUAL "AUTO") + CHECK_INCLUDE_FILES(lzma.h HAVE_LZMA_H) + CHECK_LIBRARY_EXISTS(lzma lzma_stream_buffer_decode "" HAVE_LZMA_DECODE) + CHECK_LIBRARY_EXISTS(lzma lzma_easy_buffer_encode "" HAVE_LZMA_ENCODE) + + IF (HAVE_LZMA_DECODE AND HAVE_LZMA_ENCODE AND HAVE_LZMA_H) + ADD_DEFINITIONS(-DHAVE_LZMA=1) + LINK_LIBRARIES(lzma) + ELSE() + IF (WITH_INNODB_LZMA STREQUAL "ON") + MESSAGE(FATAL_ERROR "Required lzma library is not found") + ENDIF() + ENDIF() + ENDIF() +ENDMACRO() diff --git a/cmake/lzo.cmake b/cmake/lzo.cmake new file mode 100644 index 00000000000..07cba011c06 --- /dev/null +++ b/cmake/lzo.cmake @@ -0,0 +1,48 @@ +# Copyright (C) 2014, SkySQL Ab. 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 + +SET(WITH_INNODB_LZO AUTO CACHE STRING + "Build with lzo. Possible values are 'ON', 'OFF', 'AUTO' and default is 'AUTO'") + +MACRO (MYSQL_CHECK_LZO_STATIC) + IF (WITH_INNODB_LZO STREQUAL "ON" OR WITH_INNODB_LZO STREQUAL "AUTO") + CHECK_INCLUDE_FILES(lzo/lzo1x.h HAVE_LZO_H) + CHECK_LIBRARY_EXISTS(liblzo2.a lzo1x_1_compress "" HAVE_LZO_LIB) + + IF(HAVE_LZO_LIB AND HAVE_LZO_H) + ADD_DEFINITIONS(-DHAVE_LZO=1) + LINK_LIBRARIES(liblzo2.a) + ELSE() + IF (WITH_INNODB_LZO STREQUAL "ON") + MESSAGE(FATAL_ERROR "Required lzo library is not found") + ENDIF() + ENDIF() + ENDIF() +ENDMACRO() + +MACRO (MYSQL_CHECK_LZO) + IF (WITH_INNODB_LZO STREQUAL "ON" OR WITH_INNODB_LZO STREQUAL "AUTO") + CHECK_INCLUDE_FILES(lzo/lzo1x.h HAVE_LZO_H) + CHECK_LIBRARY_EXISTS(lzo2 lzo1x_1_compress "" HAVE_LZO_SHARED_LIB) + + IF(HAVE_LZO_SHARED_LIB AND HAVE_LZO_H) + ADD_DEFINITIONS(-DHAVE_LZO=1) + LINK_LIBRARIES(lzo2) + ELSE() + IF (WITH_INNODB_LZO STREQUAL "ON") + MESSAGE(FATAL_ERROR "Required lzo library is not found") + ENDIF() + ENDIF() + ENDIF() +ENDMACRO() diff --git a/cmake/maintainer.cmake b/cmake/maintainer.cmake index 4fe2546d709..4e902d7fed8 100644 --- a/cmake/maintainer.cmake +++ b/cmake/maintainer.cmake @@ -14,45 +14,35 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Common warning flags for GCC, G++, Clang and Clang++ -SET(MY_WARNING_FLAGS "-Wall -Wextra -Wformat-security") -MY_CHECK_C_COMPILER_FLAG("-Wvla" HAVE_WVLA) # Requires GCC 4.3+ or Clang -IF(HAVE_WVLA) - SET(MY_WARNING_FLAGS "${MY_WARNING_FLAGS} -Wvla") -ENDIF() - -# Common warning flags for GCC and Clang -SET(MY_C_WARNING_FLAGS - "${MY_WARNING_FLAGS} -Wwrite-strings -Wdeclaration-after-statement") - -# Common warning flags for G++ and Clang++ -SET(MY_CXX_WARNING_FLAGS - "${MY_WARNING_FLAGS} -Woverloaded-virtual -Wno-unused-parameter") +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 + -Wvla + -Wwrite-strings + ) -# Extra warning flags for Clang++ -IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - SET(MY_CXX_WARNING_FLAGS - "${MY_CXX_WARNING_FLAGS} -Wno-null-conversion -Wno-unused-private-field") +IF(MYSQL_MAINTAINER_MODE MATCHES "ON") + SET(WHERE) +ELSEIF(MYSQL_MAINTAINER_MODE MATCHES "AUTO") + SET(WHERE DEBUG) ENDIF() -# Turn on Werror (warning => error) when using maintainer mode. -IF(MYSQL_MAINTAINER_MODE MATCHES "ERR") - SET(MY_C_WARNING_FLAGS "${MY_C_WARNING_FLAGS} -DFORCE_INIT_OF_VARS -Werror") - SET(MY_CXX_WARNING_FLAGS "${MY_CXX_WARNING_FLAGS} -DFORCE_INIT_OF_VARS -Werror") -ENDIF() +FOREACH(F ${MY_WARNING_FLAGS}) + MY_CHECK_AND_SET_COMPILER_FLAG(${F} ${WHERE}) +ENDFOREACH() -# Set warning flags for GCC/Clang -IF(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") - SET(MY_MAINTAINER_C_WARNINGS "${MY_C_WARNING_FLAGS}") -ENDIF() -# Set warning flags for G++/Clang++ -IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") - SET(MY_MAINTAINER_CXX_WARNINGS "${MY_CXX_WARNING_FLAGS}") +IF(CMAKE_C_COMPILER_ID MATCHES "GNU") + STRING(REPLACE " -E " " -E -dDI " CMAKE_C_CREATE_PREPROCESSED_SOURCE ${CMAKE_C_CREATE_PREPROCESSED_SOURCE}) ENDIF() - -IF(MYSQL_MAINTAINER_MODE MATCHES "ON") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MY_MAINTAINER_C_WARNINGS}") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_MAINTAINER_CXX_WARNINGS}") -ELSEIF(MYSQL_MAINTAINER_MODE MATCHES "AUTO") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${MY_MAINTAINER_C_WARNINGS}") - SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${MY_MAINTAINER_CXX_WARNINGS}") +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/mysql_version.cmake b/cmake/mysql_version.cmake index f147f6ef2bf..1802b1a2678 100644 --- a/cmake/mysql_version.cmake +++ b/cmake/mysql_version.cmake @@ -59,10 +59,6 @@ IF(NOT "${MAJOR_VERSION}" MATCHES "[0-9]+" OR 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}") - # Use NDBVERSION irregardless of whether this is Cluster or not, if not - # then the regex will be ignored anyway. - STRING(REGEX REPLACE "^.*-ndb-" "" NDBVERSION "${VERSION}") - STRING(REPLACE "-" "_" MYSQL_RPM_VERSION "${NDBVERSION}") 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}) @@ -93,10 +89,6 @@ ENDIF() IF(NOT CPACK_SOURCE_PACKAGE_FILE_NAME) SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mariadb-${VERSION}") - IF("${VERSION}" MATCHES "-ndb-") - STRING(REGEX REPLACE "^.*-ndb-" "" NDBVERSION "${VERSION}") - SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mysql-cluster-gpl-${NDBVERSION}") - ENDIF() ENDIF() SET(CPACK_PACKAGE_CONTACT "MariaDB team <info@montyprogram.com>") SET(CPACK_PACKAGE_VENDOR "Monty Program AB") diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake index e4221227d91..5b45c144b67 100644 --- a/cmake/os/Windows.cmake +++ b/cmake/os/Windows.cmake @@ -20,7 +20,6 @@ INCLUDE (CheckCXXSourceCompiles) INCLUDE (CheckStructHasMember) INCLUDE (CheckLibraryExists) INCLUDE (CheckFunctionExists) -INCLUDE (CheckCCompilerFlag) INCLUDE (CheckCSourceRuns) INCLUDE (CheckSymbolExists) INCLUDE (CheckTypeSize) @@ -51,7 +50,7 @@ IF(CMAKE_C_COMPILER MATCHES "icl") ENDIF() ADD_DEFINITIONS(-D_WINDOWS -D__WIN__ -D_CRT_SECURE_NO_DEPRECATE) -ADD_DEFINITIONS(-D_WIN32_WINNT=0x0501) +ADD_DEFINITIONS(-D_WIN32_WINNT=0x0600) # We do not want the windows.h macros min/max ADD_DEFINITIONS(-DNOMINMAX) # Speed up build process excluding unused header files diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake index 2808a6f749f..07a8085a411 100644 --- a/cmake/os/WindowsCache.cmake +++ b/cmake/os/WindowsCache.cmake @@ -76,6 +76,7 @@ SET(HAVE_FSYNC CACHE INTERNAL "") SET(HAVE_FTIME 1 CACHE INTERNAL "") SET(HAVE_FTRUNCATE CACHE INTERNAL "") SET(HAVE_GETADDRINFO 1 CACHE INTERNAL "") +SET(HAVE_GETIFADDRS CACHE INTERNAL "") SET(HAVE_GETCWD 1 CACHE INTERNAL "") SET(HAVE_GETHOSTBYADDR_R CACHE INTERNAL "") SET(HAVE_GETHRTIME CACHE INTERNAL "") @@ -317,6 +318,7 @@ IF(MSVC_VERSION GREATER 1310) SET(HAVE_VSNPRINTF 1 CACHE INTERNAL "") ENDIF() 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 "") @@ -365,7 +367,6 @@ SET(HAVE_SYS_UTSNAME_H CACHE INTERNAL "") SET(HAVE_PTHREAD_ATTR_GETGUARDSIZE CACHE INTERNAL "") SET(HAVE_UCONTEXT_H CACHE INTERNAL "") SET(HAVE_SOCKPEERCRED CACHE INTERNAL "") -SET(HAVE_GGDB3 CACHE INTERNAL "") SET(HAVE_ABI_CXA_DEMANGLE CACHE INTERNAL "") SET(HAVE_GCC_ATOMIC_BUILTINS CACHE INTERNAL "") SET(HAVE_GCC_C11_ATOMICS CACHE INTERNAL "") diff --git a/cmake/package_name.cmake b/cmake/package_name.cmake index 48ca3a4814d..4930a6bf40a 100644 --- a/cmake/package_name.cmake +++ b/cmake/package_name.cmake @@ -130,12 +130,7 @@ IF(NOT VERSION) SET(PRODUCT_TAG) ENDIF() - IF("${VERSION}" MATCHES "-ndb-") - STRING(REGEX REPLACE "^.*-ndb-" "" NDBVERSION "${VERSION}") - SET(package_name "mysql-cluster${PRODUCT_TAG}-${NDBVERSION}-${SYSTEM_NAME_AND_PROCESSOR}") - ELSE() - SET(package_name "mariadb${PRODUCT_TAG}-${VERSION}-${SYSTEM_NAME_AND_PROCESSOR}") - ENDIF() + SET(package_name "mariadb${PRODUCT_TAG}-${VERSION}-${SYSTEM_NAME_AND_PROCESSOR}") MESSAGE(STATUS "Packaging as: ${package_name}") diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index f14edf0cd20..591c448a793 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -19,6 +19,7 @@ INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_parse_arguments.cmake) # MYSQL_ADD_PLUGIN(plugin_name source1...sourceN # [STORAGE_ENGINE] +# [CLIENT] # [MANDATORY|DEFAULT] # [STATIC_ONLY|DYNAMIC_ONLY] # [MODULE_OUTPUT_NAME module_name] @@ -30,10 +31,11 @@ INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_parse_arguments.cmake) MACRO(MYSQL_ADD_PLUGIN) MYSQL_PARSE_ARGUMENTS(ARG "LINK_LIBRARIES;DEPENDENCIES;MODULE_OUTPUT_NAME;STATIC_OUTPUT_NAME;COMPONENT;CONFIG" - "STORAGE_ENGINE;STATIC_ONLY;MODULE_ONLY;MANDATORY;DEFAULT;DISABLED;RECOMPILE_FOR_EMBEDDED" + "STORAGE_ENGINE;STATIC_ONLY;MODULE_ONLY;MANDATORY;DEFAULT;DISABLED;RECOMPILE_FOR_EMBEDDED;CLIENT" ${ARGN} ) - + IF(NOT WITHOUT_SERVER OR ARG_CLIENT) + # Add common include directories INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql @@ -47,55 +49,70 @@ MACRO(MYSQL_ADD_PLUGIN) STRING(TOUPPER ${plugin} plugin) STRING(TOLOWER ${plugin} target) - # Figure out whether to build plugin - IF(WITH_PLUGIN_${plugin}) - SET(WITH_${plugin} 1) - ENDIF() + 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) - IF(WITH_MAX_NO_NDB) - SET(WITH_MAX 1) - SET(WITHOUT_NDBCLUSTER 1) - ENDIF() + 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) - IF(ARG_DEFAULT) - IF(NOT DEFINED WITH_${plugin} AND - NOT DEFINED WITH_${plugin}_STORAGE_ENGINE) - SET(WITH_${plugin} 1) + 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(WITH_${plugin}_STORAGE_ENGINE - OR WITH_${plugin} - OR WITH_ALL - OR WITH_MAX - AND NOT WITHOUT_${plugin}_STORAGE_ENGINE - AND NOT WITHOUT_${plugin} - AND NOT ARG_MODULE_ONLY) - - SET(WITH_${plugin} 1) - ELSEIF(WITHOUT_${plugin} OR WITHOUT_${plugin}_STORAGE_ENGINE OR - WITH_NONE OR ARG_DISABLED) - SET(WITHOUT_${plugin} 1) - SET(WITH_${plugin}_STORAGE_ENGINE 0) - SET(WITH_${plugin} 0) - ENDIF() - - - IF(ARG_MANDATORY) - SET(WITH_${plugin} 1) + + 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() - SET(BUILD_PLUGIN 1) IF(NOT ARG_MODULE_OUTPUT_NAME) IF(ARG_STORAGE_ENGINE) @@ -106,9 +123,10 @@ MACRO(MYSQL_ADD_PLUGIN) ENDIF() # Build either static library or module - IF (WITH_${plugin} AND NOT ARG_MODULE_ONLY) + IF (PLUGIN_${plugin} MATCHES "(STATIC|AUTO|YES)" AND NOT ARG_MODULE_ONLY + AND NOT ARG_CLIENT) - IF(CMAKE_GENERATOR MATCHES "Makefiles") + 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 @@ -136,23 +154,21 @@ MACRO(MYSQL_ADD_PLUGIN) 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() + # Update mysqld dependencies SET (MYSQLD_STATIC_PLUGIN_LIBS ${MYSQLD_STATIC_PLUGIN_LIBS} ${target} ${ARG_LINK_LIBRARIES} CACHE INTERNAL "" FORCE) - IF(ARG_MANDATORY) - SET(${with_var} ON CACHE INTERNAL "Link ${plugin} statically to the server" - FORCE) - ELSE() - SET(${with_var} ON CACHE BOOL "Link ${plugin} statically to the server" - FORCE) - ENDIF() + SET(${with_var} ON CACHE INTERNAL "Link ${plugin} statically to the server" FORCE) IF(ARG_MANDATORY) SET (mysql_mandatory_plugins @@ -163,27 +179,37 @@ MACRO(MYSQL_ADD_PLUGIN) "${mysql_optional_plugins} builtin_maria_${target}_plugin,") SET (mysql_optional_plugins ${mysql_optional_plugins} PARENT_SCOPE) ENDIF() - ELSEIF(NOT WITHOUT_${plugin} AND NOT ARG_STATIC_ONLY AND NOT WITHOUT_DYNAMIC_PLUGINS) - + 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 "" - COMPILE_DEFINITIONS "MYSQL_DYNAMIC_PLUGIN") - TARGET_LINK_LIBRARIES (${target} mysqlservices) - # Plugin uses symbols defined in mysqld executable. + SET_TARGET_PROPERTIES (${target} PROPERTIES PREFIX "") + IF (NOT ARG_CLIENT) + SET_TARGET_PROPERTIES (${target} PROPERTIES + COMPILE_DEFINITIONS "MYSQL_DYNAMIC_PLUGIN") + ENDIF() + + TARGET_LINK_LIBRARIES (${target} mysqlservices ${ARG_LINK_LIBRARIES}) + + # 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(MSVC) - ADD_DEPENDENCIES(${target} gen_mysqld_lib) - TARGET_LINK_LIBRARIES(${target} mysqld_import_lib) - ELSEIF(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") - TARGET_LINK_LIBRARIES (${target} mysqld) + IF(ARG_RECOMPILE_FOR_EMBEDDED OR ARG_STORAGE_ENGINE) + IF(MSVC) + ADD_DEPENDENCIES(${target} gen_mysqld_lib) + TARGET_LINK_LIBRARIES(${target} mysqld_import_lib) + ELSEIF(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") + TARGET_LINK_LIBRARIES (${target} mysqld) + ENDIF() + ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Linux") + TARGET_LINK_LIBRARIES (${target} "-Wl,--no-undefined") ENDIF() IF(ARG_LINK_LIBRARIES) @@ -191,52 +217,40 @@ MACRO(MYSQL_ADD_PLUGIN) ENDIF() ADD_DEPENDENCIES(${target} GenError ${ARG_DEPENDENCIES}) - IF(NOT ARG_MODULE_ONLY) - # set cached variable, e.g with checkbox in GUI - SET(${with_var} OFF CACHE BOOL "Link ${plugin} statically to the server" - FORCE) - ENDIF() 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(CPACK_COMPONENTS_ALL AND + NOT CPACK_COMPONENTS_ALL MATCHES ${ARG_COMPONENT} + AND INSTALL_SYSCONF2DIR) IF (ARG_STORAGE_ENGINE) SET(ver " = %{version}-%{release}") + ELSE() + SET(ver "") ENDIF() - SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} ${ARG_COMPONENT} PARENT_SCOPE) - SET(CPACK_RPM_${ARG_COMPONENT}_PACKAGE_REQUIRES "MariaDB${ver}" PARENT_SCOPE) + SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} ${ARG_COMPONENT}) + SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} PARENT_SCOPE) - IF (NOT ARG_CONFIG) - SET(ARG_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/${target}.cnf") - FILE(WRITE ${ARG_CONFIG} "[mariadb]\nplugin-load-add=${ARG_MODULE_OUTPUT_NAME}.so\n") + IF (NOT ARG_CLIENT) + SET(CPACK_RPM_${ARG_COMPONENT}_PACKAGE_REQUIRES "MariaDB${ver}" PARENT_SCOPE) ENDIF() - INSTALL(FILES ${ARG_CONFIG} COMPONENT ${ARG_COMPONENT} DESTINATION ${INSTALL_SYSCONF2DIR}) - # workarounds for cmake issues #13248 and #12864: SET(CPACK_RPM_${ARG_COMPONENT}_PACKAGE_PROVIDES "cmake_bug_13248" PARENT_SCOPE) SET(CPACK_RPM_${ARG_COMPONENT}_PACKAGE_OBSOLETES "cmake_bug_13248" PARENT_SCOPE) - SET(CPACK_RPM_${ARG_COMPONENT}_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*" PARENT_SCOPE) + SET(CPACK_RPM_${ARG_COMPONENT}_USER_FILELIST ${ignored} PARENT_SCOPE) + IF(NOT ARG_CLIENT AND NOT ARG_CONFIG AND UNIX) + SET(ARG_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/${target}.cnf") + FILE(WRITE ${ARG_CONFIG} "[mariadb]\nplugin-load-add=${ARG_MODULE_OUTPUT_NAME}.so\n") + INSTALL(FILES ${ARG_CONFIG} COMPONENT ${ARG_COMPONENT} DESTINATION ${INSTALL_SYSCONF2DIR}) + SET(CPACK_RPM_${ARG_COMPONENT}_USER_FILELIST ${ignored} "%config(noreplace) ${INSTALL_SYSCONF2DIR}/*" PARENT_SCOPE) + ENDIF() ENDIF() ELSE() SET(ARG_COMPONENT Server) ENDIF() MYSQL_INSTALL_TARGETS(${target} DESTINATION ${INSTALL_PLUGINDIR} COMPONENT ${ARG_COMPONENT}) #INSTALL_DEBUG_TARGET(${target} DESTINATION ${INSTALL_PLUGINDIR}/debug COMPONENT ${ARG_COMPONENT}) - ELSE() - IF(WITHOUT_${plugin}) - # Update cache variable - STRING(REPLACE "WITH_" "WITHOUT_" without_var ${with_var}) - SET(${without_var} ON CACHE BOOL "Don't build ${plugin}" - FORCE) - ENDIF() - SET(BUILD_PLUGIN 0) - ENDIF() - - IF(BUILD_PLUGIN AND ARG_LINK_LIBRARIES) - TARGET_LINK_LIBRARIES (${target} ${ARG_LINK_LIBRARIES}) ENDIF() GET_FILENAME_COMPONENT(subpath ${CMAKE_CURRENT_SOURCE_DIR} NAME) @@ -244,17 +258,32 @@ MACRO(MYSQL_ADD_PLUGIN) INSTALL_MYSQL_TEST("${CMAKE_CURRENT_SOURCE_DIR}/mysql-test/" "plugin/${subpath}") 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) - FILE(GLOB dirs_storage ${CMAKE_SOURCE_DIR}/storage/*) + 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/readline.cmake b/cmake/readline.cmake index 64e04ef8663..d03fe503882 100644 --- a/cmake/readline.cmake +++ b/cmake/readline.cmake @@ -116,9 +116,9 @@ 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}/cmd-line-utils/readline) + SET(MY_READLINE_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extra/readline) SET(MY_READLINE_LIBRARY readline) - ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/cmd-line-utils/readline) + ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/extra/readline) ENDMACRO() MACRO (MYSQL_FIND_SYSTEM_READLINE) diff --git a/cmake/snappy.cmake b/cmake/snappy.cmake new file mode 100644 index 00000000000..cb0839a3480 --- /dev/null +++ b/cmake/snappy.cmake @@ -0,0 +1,32 @@ +# Copyright (C) 2015, MariaDB Corporation. 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 + +SET(WITH_INNODB_SNAPPY AUTO CACHE STRING + "Build with snappy. Possible values are 'ON', 'OFF', 'AUTO' and default is 'AUTO'") + +MACRO (MYSQL_CHECK_SNAPPY) + IF (WITH_INNODB_SNAPPY STREQUAL "ON" OR WITH_INNODB_SNAPPY STREQUAL "AUTO") + CHECK_INCLUDE_FILES(snappy-c.h HAVE_SNAPPY_H) + CHECK_LIBRARY_EXISTS(snappy snappy_uncompress "" HAVE_SNAPPY_SHARED_LIB) + + IF(HAVE_SNAPPY_SHARED_LIB AND HAVE_SNAPPY_H) + ADD_DEFINITIONS(-DHAVE_SNAPPY=1) + LINK_LIBRARIES(snappy) + ELSE() + IF (WITH_INNODB_SNAPPY STREQUAL "ON") + MESSAGE(FATAL_ERROR "Required snappy library is not found") + ENDIF() + ENDIF() + ENDIF() +ENDMACRO() diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake index c5985a38621..18728c733db 100644 --- a/cmake/ssl.cmake +++ b/cmake/ssl.cmake @@ -57,6 +57,8 @@ MACRO (MYSQL_USE_BUNDLED_SSL) SET(SSL_INTERNAL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL) SET(SSL_DEFINES "-DHAVE_YASSL -DYASSL_PREFIX -DHAVE_OPENSSL -DMULTI_THREADED") SET(HAVE_ERR_remove_thread_state OFF CACHE INTERNAL "yassl doesn't have ERR_remove_thread_state") + SET(HAVE_EncryptAes128Ctr OFF CACHE INTERNAL "yassl doesn't support AES-CTR") + SET(HAVE_EncryptAes128Gcm OFF CACHE INTERNAL "yassl doesn't support AES-GCM") CHANGE_SSL_SETTINGS("bundled") ADD_SUBDIRECTORY(extra/yassl) ADD_SUBDIRECTORY(extra/yassl/taocrypt) @@ -147,48 +149,39 @@ MACRO (MYSQL_CHECK_SSL) IF (WITH_SSL_PATH) LIST(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES) ENDIF() - MESSAGE(STATUS "suffixes <${CMAKE_FIND_LIBRARY_SUFFIXES}>") FIND_LIBRARY(OPENSSL_LIBRARIES NAMES ssl ssleay32 ssleay32MD HINTS ${OPENSSL_ROOT_DIR}/lib) FIND_LIBRARY(CRYPTO_LIBRARY NAMES crypto libeay32 HINTS ${OPENSSL_ROOT_DIR}/lib) + MARK_AS_ADVANCED(CRYPTO_LIBRARY OPENSSL_LIBRARIES OPENSSL_ROOT_DIR + OPENSSL_INCLUDE_DIR) IF (WITH_SSL_PATH) LIST(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES) ENDIF() - IF(OPENSSL_INCLUDE_DIR AND - OPENSSL_LIBRARIES AND - CRYPTO_LIBRARY - ) + INCLUDE(CheckSymbolExists) + SET(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) + CHECK_SYMBOL_EXISTS(SHA512_DIGEST_LENGTH "openssl/sha.h" + HAVE_SHA512_DIGEST_LENGTH) + SET(CMAKE_REQUIRED_INCLUDES) + IF(OPENSSL_INCLUDE_DIR AND OPENSSL_LIBRARIES AND + CRYPTO_LIBRARY AND HAVE_SHA512_DIGEST_LENGTH) # Verify version number. Version information looks like: # #define OPENSSL_VERSION_NUMBER 0x1000103fL # Encoded as MNNFFPPS: major minor fix patch status FILE(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" OPENSSL_VERSION_NUMBER - REGEX "^#define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x[0-9].*" + REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x[0-9].*" ) STRING(REGEX REPLACE "^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9]).*$" "\\1" OPENSSL_MAJOR_VERSION "${OPENSSL_VERSION_NUMBER}" ) - INCLUDE(CheckSymbolExists) - SET(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) - CHECK_SYMBOL_EXISTS(SHA512_DIGEST_LENGTH "openssl/sha.h" - HAVE_SHA512_DIGEST_LENGTH) - SET(OPENSSL_FOUND TRUE) - ELSE() - SET(OPENSSL_FOUND FALSE) - ENDIF() - - IF(OPENSSL_FOUND AND HAVE_SHA512_DIGEST_LENGTH) - MESSAGE(STATUS "OPENSSL_INCLUDE_DIR = ${OPENSSL_INCLUDE_DIR}") - MESSAGE(STATUS "OPENSSL_LIBRARIES = ${OPENSSL_LIBRARIES}") - MESSAGE(STATUS "CRYPTO_LIBRARY = ${CRYPTO_LIBRARY}") MESSAGE(STATUS "OPENSSL_MAJOR_VERSION = ${OPENSSL_MAJOR_VERSION}") - - + ENDIF() + IF(TRUE) #OPENSSL_MAJOR_VERSION GREATER 0) SET(SSL_SOURCES "") SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES} ${CRYPTO_LIBRARY}) IF(CMAKE_SYSTEM_NAME MATCHES "SunOS") @@ -197,6 +190,10 @@ MACRO (MYSQL_CHECK_SSL) IF(CMAKE_SYSTEM_NAME MATCHES "Linux") SET(SSL_LIBRARIES ${SSL_LIBRARIES} ${LIBDL}) ENDIF() + + MESSAGE(STATUS "OPENSSL_INCLUDE_DIR = ${OPENSSL_INCLUDE_DIR}") + MESSAGE(STATUS "OPENSSL_LIBRARIES = ${OPENSSL_LIBRARIES}") + MESSAGE(STATUS "CRYPTO_LIBRARY = ${CRYPTO_LIBRARY}") MESSAGE(STATUS "SSL_LIBRARIES = ${SSL_LIBRARIES}") SET(SSL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR}) SET(SSL_INTERNAL_INCLUDE_DIRS "") @@ -205,6 +202,10 @@ MACRO (MYSQL_CHECK_SSL) SET(CMAKE_REQUIRED_LIBRARIES ${SSL_LIBRARIES}) 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) ELSE() IF(WITH_SSL STREQUAL "system") MESSAGE(SEND_ERROR "Cannot find appropriate system libraries for SSL. Use WITH_SSL=bundled to enable SSL support") diff --git a/cmake/systemd.cmake b/cmake/systemd.cmake new file mode 100644 index 00000000000..692d4df9f26 --- /dev/null +++ b/cmake/systemd.cmake @@ -0,0 +1,86 @@ +# 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-1301 USA + +INCLUDE(FindPkgConfig) +# http://www.cmake.org/cmake/help/v3.0/module/FindPkgConfig.html + +MACRO(CHECK_SYSTEMD) + IF(UNIX) + 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(WITH_SYSTEMD STREQUAL "yes") + pkg_search_module(LIBSYSTEMD REQUIRED libsystemd libsystemd-daemon) + ELSE() + pkg_search_module(LIBSYSTEMD libsystemd libsystemd-daemon) + ENDIF() + IF(HAVE_DLOPEN) + SET(LIBSYSTEMD ${LIBSYSTEMD_LIBRARIES}) + #SET(CMAKE_REQUIRED_FLAGS ${LIBSYSTEMD_CFLAGS}) + SET(MYSQLD_LINK_FLAGS "${MYSQLD_LINK_FLAGS} ${LIBSYSTEMD_LDFLAGS}") + ELSE() + SET(LIBSYSTEMD ${LIBSYSTEMD_STATIC_LIBRARIES}) + #SET(CMAKE_REQUIRED_FLAGS ${LIBSYSTEMD_STATIC_CFLAGS}) + SET(MYSQLD_LINK_FLAGS "${MYSQLD_LINK_FLAGS} ${LIBSYSTEMD_STATIC_LDFLAGS}") + ENDIF() + ELSE() + SET(LIBSYSTEMD systemd) + ENDIF() + SET(CMAKE_REQUIRED_LIBRARIES ${LIBSYSTEMD}) + CHECK_C_SOURCE_COMPILES( + " + #include <systemd/sd-daemon.h> + int main() + { + sd_listen_fds(0); + }" + HAVE_SYSTEMD) + CHECK_INCLUDE_FILES(systemd/sd-daemon.h HAVE_SYSTEMD_SD_DAEMON_H) + CHECK_FUNCTION_EXISTS(sd_listen_fds HAVE_SYSTEMD_SD_LISTEN_FDS) + 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 AND HAVE_SYSTEMD_SD_DAEMON_H AND HAVE_SYSTEMD_SD_LISTEN_FDS + AND HAVE_SYSTEMD_SD_NOTIFY AND HAVE_SYSTEMD_SD_NOTIFYF) + ADD_DEFINITIONS(-DHAVE_SYSTEMD) + SET(SYSTEMD_SCRIPTS mariadb-service-convert galera_new_cluster galera_recovery) + SET(SYSTEMD_DEB_FILES "usr/bin/mariadb-service-convert + usr/bin/galera_new_cluster + usr/bin/galera_recovery + ${INSTALL_SYSTEMD_UNITDIR}/mariadb.service + ${INSTALL_SYSTEMD_UNITDIR}/mariadb@.service + ${INSTALL_SYSTEMD_UNITDIR}/mariadb@bootstrap.service.d/use_galera_new_cluster.conf") + 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(STATUS "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(STATUS "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() + ENDIF() +ENDMACRO() diff --git a/cmake/wsrep.cmake b/cmake/wsrep.cmake new file mode 100644 index 00000000000..9fa127380a4 --- /dev/null +++ b/cmake/wsrep.cmake @@ -0,0 +1,43 @@ +# 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-1301 USA + +# +# Galera library does not compile with windows +# +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}) + +# Set the patch version +SET(WSREP_PATCH_VERSION "23") + +# Obtain wsrep API version +FILE(STRINGS "${MySQL_SOURCE_DIR}/wsrep/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}) + +IF(WITH_WSREP) + SET(WSREP_PATCH_VERSION "wsrep_${WSREP_VERSION}") +ENDIF() |