diff options
Diffstat (limited to 'cmake')
30 files changed, 220 insertions, 341 deletions
diff --git a/cmake/FindLZ4.cmake b/cmake/FindLZ4.cmake index e97dd63e2b0..46c1fdc1b9f 100644 --- a/cmake/FindLZ4.cmake +++ b/cmake/FindLZ4.cmake @@ -1,9 +1,9 @@ find_path(LZ4_INCLUDE_DIR NAMES lz4.h) -find_library(LZ4_LIBRARY NAMES lz4) +find_library(LZ4_LIBRARIES NAMES lz4) include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS( LZ4 DEFAULT_MSG - LZ4_LIBRARY LZ4_INCLUDE_DIR) + LZ4_LIBRARIES LZ4_INCLUDE_DIR) -mark_as_advanced(LZ4_INCLUDE_DIR LZ4_LIBRARY) +mark_as_advanced(LZ4_INCLUDE_DIR LZ4_LIBRARIES) diff --git a/cmake/FindZSTD.cmake b/cmake/FindZSTD.cmake index 0fd73501327..ede59010742 100644 --- a/cmake/FindZSTD.cmake +++ b/cmake/FindZSTD.cmake @@ -1,18 +1,21 @@ -find_path( - ZSTD_INCLUDE_DIR - NAMES "zstd.h" -) +# - 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_library( - ZSTD_LIBRARY - NAMES zstd -) +find_path(ZSTD_INCLUDE_DIR + NAMES zstd.h + HINTS ${ZSTD_ROOT_DIR}/include) -set(ZSTD_LIBRARIES ${ZSTD_LIBRARY}) +find_library(ZSTD_LIBRARIES + NAMES zstd + HINTS ${ZSTD_ROOT_DIR}/lib) include(FindPackageHandleStandardArgs) -find_package_handle_standard_args( - ZSTD DEFAULT_MSG ZSTD_INCLUDE_DIR ZSTD_LIBRARIES) - -mark_as_advanced(ZSTD_INCLUDE_DIR ZSTD_LIBRARIES ZSTD_FOUND) +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/bison.cmake b/cmake/bison.cmake deleted file mode 100644 index 1b2d1c38bae..00000000000 --- a/cmake/bison.cmake +++ /dev/null @@ -1,106 +0,0 @@ -# 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 - -IF(CMAKE_SYSTEM_NAME MATCHES "SunOS") - # On Solaris, /opt/csw often contains a newer bison - IF(NOT BISON_EXECUTABLE AND EXISTS /opt/csw/bin/bison) - SET(BISON_EXECUTABLE /opt/csw/bin/bison) - ENDIF() -ENDIF() -IF(WIN32) - SET(BISON_PATH_HINTS - HINTS - C:/gnuwin32/bin - C:/cygwin64/bin - C:/cygwin/bin) -ENDIF() -FIND_PROGRAM(BISON_EXECUTABLE NAMES bison win_bison - ${BISON_PATH_HINTS} - DOC "path to the bison executable") -MARK_AS_ADVANCED(BISON_EXECUTABLE "") -IF(NOT BISON_EXECUTABLE) - MESSAGE("Warning: Bison executable not found in PATH") -ELSEIF(BISON_EXECUTABLE AND NOT BISON_USABLE) - # Check version as well - EXEC_PROGRAM(${BISON_EXECUTABLE} ARGS --version OUTPUT_VARIABLE BISON_VERSION_STR) - # Get first line in case it's multiline - STRING(REGEX REPLACE "([^\n]+).*" "\\1" FIRST_LINE "${BISON_VERSION_STR}") - # get version information - STRING(REGEX REPLACE ".* ([0-9]+)\\.([0-9]+)" "\\1" BISON_VERSION_MAJOR "${FIRST_LINE}") - STRING(REGEX REPLACE ".* ([0-9]+)\\.([0-9]+)" "\\2" BISON_VERSION_MINOR "${FIRST_LINE}") - IF (BISON_VERSION_MAJOR LESS 2) - MESSAGE("Warning: bison version is old. please update to version 2") - ELSE() - SET(BISON_USABLE 1 CACHE INTERNAL "Bison version 2 or higher") - ENDIF() -ENDIF() - -# Use bison to generate C++ and header file -MACRO (RUN_BISON input_yy output_cc output_h) - IF(BISON_TOO_OLD) - IF(EXISTS ${output_cc} AND EXISTS ${output_h}) - SET(BISON_USABLE FALSE) - ENDIF() - ENDIF() - IF(BISON_USABLE) - # Workaround for VS regenerating output even - # when outputs are up-to-date. At least, fix output timestamp - # after build so that files that depend on generated header are - # not rebuilt. - IF(CMAKE_GENERATOR MATCHES "Visual Studio") - FIND_PROGRAM(TOUCH_EXECUTABLE touch DOC "Path to touch executable" - PATHS "C:/Program Files/Git/usr/bin" - "C:/Program Files (x86)/Git/usr/bin") - IF(TOUCH_EXECUTABLE) - SET(VS_FIX_OUTPUT_TIMESTAMPS - COMMAND ${TOUCH_EXECUTABLE} -r ${input_yy} ${output_cc} - COMMAND ${TOUCH_EXECUTABLE} -r ${input_yy} ${output_h}) - ENDIF() - ENDIF() - - ADD_CUSTOM_COMMAND( - OUTPUT ${output_cc} - ${output_h} - COMMAND ${BISON_EXECUTABLE} -y -p MYSQL - --output=${output_cc} - --defines=${output_h} - ${input_yy} - ${VS_FIX_OUTPUT_TIMESTAMPS} - DEPENDS ${input_yy} - ) - ELSE() - # Bison is missing or not usable, e.g too old - IF(EXISTS ${output_cc} AND EXISTS ${output_h}) - IF(${input_yy} IS_NEWER_THAN ${output_cc} OR ${input_yy} IS_NEWER_THAN ${output_h}) - # Possibly timestamps are messed up in source distribution. - MESSAGE("Warning: no usable bison found, ${input_yy} will not be rebuilt.") - ENDIF() - ELSE() - # Output files are missing, bail out. - SET(ERRMSG - "Bison (GNU parser generator) is required to build MySQL." - "Please install bison." - ) - IF(WIN32) - SET(ERRMSG ${ERRMSG} - "You can download bison from http://gnuwin32.sourceforge.net/packages/bison.htm " - "Choose 'Complete package, except sources' installation. We recommend to " - "install bison into a directory without spaces, e.g C:\\GnuWin32.") - ENDIF() - MESSAGE(FATAL_ERROR ${ERRMSG}) - ENDIF() - ENDIF() -ENDMACRO() diff --git a/cmake/build_configurations/mysql_release.cmake b/cmake/build_configurations/mysql_release.cmake index d844f436031..2db09ed2e37 100644 --- a/cmake/build_configurations/mysql_release.cmake +++ b/cmake/build_configurations/mysql_release.cmake @@ -158,6 +158,8 @@ IF(UNIX) 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: @@ -169,9 +171,6 @@ IF(UNIX) ") ENDIF() - # Remove libaio dependency from mysqld - #SET(XTRADB_PREFER_STATIC_LIBAIO 1) - # 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 diff --git a/cmake/build_depends.cmake b/cmake/build_depends.cmake index 333df580200..5adaee33740 100644 --- a/cmake/build_depends.cmake +++ b/cmake/build_depends.cmake @@ -39,6 +39,8 @@ IF(RPM) SET(BUILD_DEPS ${BUILD_DEPS} ${${V}_DEP}) ENDIF() ENDFOREACH() - LIST(REMOVE_DUPLICATES BUILD_DEPS) - STRING(REPLACE ";" " " CPACK_RPM_BUILDREQUIRES "${BUILD_DEPS}") + IF (BUILD_DEPS) + LIST(REMOVE_DUPLICATES BUILD_DEPS) + STRING(REPLACE ";" " " CPACK_RPM_BUILDREQUIRES "${BUILD_DEPS}") + ENDIF() ENDIF(RPM) diff --git a/cmake/configure.pl b/cmake/configure.pl index 3139587a8e1..c296c5ba4b8 100644 --- a/cmake/configure.pl +++ b/cmake/configure.pl @@ -145,6 +145,11 @@ foreach my $option (@ARGV) $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"; @@ -185,6 +190,16 @@ foreach my $option (@ARGV) $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); diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index eacb6310ece..fb2f24ba27c 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -143,7 +143,9 @@ SET(ignored "%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" @@ -212,11 +214,6 @@ 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) @@ -230,15 +227,16 @@ SET(CPACK_RPM_compat_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/ SET(CPACK_RPM_compat_POST_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/support-files/rpm/shared-post.sh) MACRO(ALTERNATIVE_NAME real alt) - SET(ver "%{version}-%{release}") - IF (${epoch}) - SET(ver "${epoch}:${ver}") + 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} ${alt}%{?_isa}") + SET(${o} "${${o}} ${alt}") ENDMACRO(ALTERNATIVE_NAME) ALTERNATIVE_NAME("devel" "mysql-devel") @@ -246,12 +244,14 @@ 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-speficic dependencies +# 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 + SET(epoch 1:) # this is fedora ALTERNATIVE_NAME("client" "mariadb") ALTERNATIVE_NAME("client" "mysql") ALTERNATIVE_NAME("devel" "mariadb-devel") @@ -259,7 +259,19 @@ ELSEIF(RPM MATCHES "fedora" OR RPM MATCHES "(rhel|centos)7") ALTERNATIVE_NAME("server" "mysql-compat-server") ALTERNATIVE_NAME("test" "mariadb-test") ELSEIF(RPM MATCHES "(rhel|centos)8") - SET(PYTHON_SHEBANG "/usr/bin/python3") + 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) + ALTERNATIVE_NAME("devel" "mariadb-connector-c-devel" ${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 @@ -269,6 +281,9 @@ ELSEIF(RPM MATCHES "sles") "mariadb-server = %{version}-%{release}" ) ENDIF() +IF(RPM MATCHES "fedora31" OR RPM MATCHES "(rhel|centos)8") + SET(PYTHON_SHEBANG "/usr/bin/python3" CACHE STRING "python shebang") +ENDIF() # If we want to build build MariaDB-shared-compat, # extract compat libraries from MariaDB-shared-5.3 rpm @@ -300,6 +315,7 @@ IF(compat53 AND compat101) 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}") diff --git a/cmake/crc32-vpmsum.cmake b/cmake/crc32-vpmsum.cmake deleted file mode 100644 index c1a2dee56e2..00000000000 --- a/cmake/crc32-vpmsum.cmake +++ /dev/null @@ -1,5 +0,0 @@ -IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64le") - SET(HAVE_CRC32_VPMSUM 1) - SET(CRC32_VPMSUM_LIBRARY crc32-vpmsum) - ADD_SUBDIRECTORY(extra/crc32-vpmsum) -ENDIF() diff --git a/cmake/crc32.cmake b/cmake/crc32.cmake new file mode 100644 index 00000000000..ee8afdb0e92 --- /dev/null +++ b/cmake/crc32.cmake @@ -0,0 +1,5 @@ +IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ppc64") + SET(HAVE_CRC32_VPMSUM 1) + SET(CRC32_LIBRARY crc32-vpmsum) + ADD_SUBDIRECTORY(extra/crc32-vpmsum) +ENDIF() diff --git a/cmake/create_initial_db.cmake.in b/cmake/create_initial_db.cmake index cc07947a164..9d061d86711 100644 --- a/cmake/create_initial_db.cmake.in +++ b/cmake/create_initial_db.cmake @@ -14,11 +14,6 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA # This script creates initial database for packaging on Windows -SET(CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@") -SET(CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@") -SET(MYSQLD_EXECUTABLE "@MYSQLD_EXECUTABLE@") -SET(CMAKE_CFG_INTDIR "@CMAKE_CFG_INTDIR@") -SET(WIN32 "@WIN32@") # Force Visual Studio to output to stdout IF(ENV{VS_UNICODE_OUTPUT}) SET ($ENV{VS_UNICODE_OUTPUT}) @@ -32,30 +27,27 @@ 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 ${CMAKE_SOURCE_DIR}/scripts/${FILENAME} CONTENTS) + 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 ${CMAKE_SOURCE_DIR}/scripts/fill_help_tables.sql CONTENTS) +FILE(READ ${TOP_SRCDIR}/scripts/fill_help_tables.sql CONTENTS) FILE(APPEND bootstrap.sql "${CONTENTS}") FILE(REMOVE_RECURSE mysql performance_schema) FILE(REMOVE ibdata1 ib_logfile0 ib_logfile1) MAKE_DIRECTORY(mysql) -IF(WIN32) - SET(CONSOLE --console) -ENDIF() SET(BOOTSTRAP_COMMAND ${MYSQLD_EXECUTABLE} --no-defaults - ${CONSOLE} + --console --bootstrap - --lc-messages-dir=${CMAKE_CURRENT_BINARY_DIR}/share + --lc-messages-dir=${BINDIR}/share --basedir=. --datadir=. --default-storage-engine=MyISAM @@ -65,10 +57,10 @@ SET(BOOTSTRAP_COMMAND GET_FILENAME_COMPONENT(CWD . ABSOLUTE) EXECUTE_PROCESS( - COMMAND "@CMAKE_COMMAND@" -E echo Executing ${BOOTSTRAP_COMMAND} + COMMAND "${CMAKE_COMMAND}" -E echo Executing ${BOOTSTRAP_COMMAND} ) EXECUTE_PROCESS ( - COMMAND "@CMAKE_COMMAND@" -E + COMMAND "${CMAKE_COMMAND}" -E echo input file bootstrap.sql, current directory ${CWD} ) EXECUTE_PROCESS ( diff --git a/cmake/dtrace.cmake b/cmake/dtrace.cmake index d3dded99497..dae3b56b584 100644 --- a/cmake/dtrace.cmake +++ b/cmake/dtrace.cmake @@ -148,11 +148,10 @@ FUNCTION(DTRACE_INSTRUMENT target) # 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. - GET_TARGET_PROPERTY(target_location ${target} LOCATION) ADD_CUSTOM_COMMAND( TARGET ${target} POST_BUILD - COMMAND ${CMAKE_AR} r ${target_location} ${outfile} - COMMAND ${CMAKE_RANLIB} ${target_location} + 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 "") diff --git a/cmake/dtrace_prelink.cmake b/cmake/dtrace_prelink.cmake index f2e678f06d5..e09fd5584a3 100644 --- a/cmake/dtrace_prelink.cmake +++ b/cmake/dtrace_prelink.cmake @@ -34,7 +34,7 @@ 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 directores. We have to copy the objects into temp. + # 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 diff --git a/cmake/for_clients.cmake b/cmake/for_clients.cmake index e52e3b34f21..27b1430f33e 100644 --- a/cmake/for_clients.cmake +++ b/cmake/for_clients.cmake @@ -11,9 +11,6 @@ SET(LIBS "") 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 diff --git a/cmake/install_layout.cmake b/cmake/install_layout.cmake index b2d9b7734ce..9e3549964e1 100644 --- a/cmake/install_layout.cmake +++ b/cmake/install_layout.cmake @@ -180,7 +180,7 @@ SET(INSTALL_SYSCONF2DIR_DEB "/etc/mysql/conf.d") SET(INSTALL_LIBDIR_DEB "lib/${CMAKE_CXX_LIBRARY_ARCHITECTURE}") SET(INSTALL_PLUGINDIR_DEB "lib/mysql/plugin") # -SET(INSTALL_INCLUDEDIR_DEB "include/mysql") +SET(INSTALL_INCLUDEDIR_DEB "include/mariadb") # SET(INSTALL_DOCDIR_DEB "share/doc") SET(INSTALL_DOCREADMEDIR_DEB "share/doc") diff --git a/cmake/install_macros.cmake b/cmake/install_macros.cmake index 9724620c068..ee1a39066b1 100644 --- a/cmake/install_macros.cmake +++ b/cmake/install_macros.cmake @@ -150,7 +150,7 @@ ENDFUNCTION() # Install symbolic link to CMake target. -# the link is created in the same directory as 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) @@ -250,8 +250,7 @@ FUNCTION(MYSQL_INSTALL_TARGETS) ENDIF() # Install man pages on Unix IF(UNIX) - GET_TARGET_PROPERTY(target_location ${target} LOCATION) - INSTALL_MANPAGE(${target_location}) + INSTALL_MANPAGE($<TARGET_FILE:${target}>) ENDIF() ENDFOREACH() @@ -267,92 +266,6 @@ GET_FILENAME_COMPONENT(BINARY_PARENTDIR ${CMAKE_BINARY_DIR} PATH) SET(DEBUGBUILDDIR "${BINARY_PARENTDIR}/debug" CACHE INTERNAL "Directory of debug build") -FUNCTION(INSTALL_DEBUG_TARGET target) - CMAKE_PARSE_ARGUMENTS(ARG - "" - "DESTINATION;RENAME;PDB_DESTINATION;COMPONENT" - "" - ${ARGN} - ) - GET_TARGET_PROPERTY(target_type ${target} TYPE) - IF(ARG_RENAME) - SET(RENAME_PARAM RENAME ${ARG_RENAME}${CMAKE_${target_type}_SUFFIX}) - ELSE() - SET(RENAME_PARAM) - ENDIF() - IF(NOT ARG_DESTINATION) - MESSAGE(FATAL_ERROR "Need DESTINATION parameter for INSTALL_DEBUG_TARGET") - ENDIF() - GET_TARGET_PROPERTY(target_location ${target} LOCATION) - 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}" ) - ENDIF() - IF(NOT ARG_COMPONENT) - SET(ARG_COMPONENT DebugBinaries) - ENDIF() - - # Define permissions - # For executable files - SET(PERMISSIONS_EXECUTABLE - PERMISSIONS - OWNER_READ OWNER_WRITE OWNER_EXECUTE - GROUP_READ GROUP_EXECUTE - WORLD_READ WORLD_EXECUTE) - - # Permissions for shared library (honors CMAKE_INSTALL_NO_EXE which is - # typically set on Debian) - IF(CMAKE_INSTALL_SO_NO_EXE) - SET(PERMISSIONS_SHARED_LIBRARY - PERMISSIONS - OWNER_READ OWNER_WRITE - GROUP_READ - WORLD_READ) - ELSE() - SET(PERMISSIONS_SHARED_LIBRARY ${PERMISSIONS_EXECUTABLE}) - ENDIF() - - # Shared modules get the same permissions as shared libraries - SET(PERMISSIONS_MODULE_LIBRARY ${PERMISSIONS_SHARED_LIBRARY}) - - # Define permissions for static library - SET(PERMISSIONS_STATIC_LIBRARY - PERMISSIONS - OWNER_READ OWNER_WRITE - GROUP_READ - WORLD_READ) - - INSTALL(FILES ${debug_target_location} - DESTINATION ${ARG_DESTINATION} - ${RENAME_PARAM} - ${PERMISSIONS_${target_type}} - CONFIGURATIONS Release RelWithDebInfo - COMPONENT ${ARG_COMPONENT} - OPTIONAL) - - IF(MSVC) - GET_FILENAME_COMPONENT(ext ${debug_target_location} EXT) - STRING(REPLACE "${ext}" ".pdb" debug_pdb_target_location "${debug_target_location}" ) - IF (RENAME_PARAM) - IF(NOT ARG_PDB_DESTINATION) - STRING(REPLACE "${ext}" ".pdb" "${ARG_RENAME}" pdb_rename) - SET(PDB_RENAME_PARAM RENAME "${pdb_rename}") - ENDIF() - ENDIF() - IF(NOT ARG_PDB_DESTINATION) - SET(ARG_PDB_DESTINATION "${ARG_DESTINATION}") - ENDIF() - INSTALL(FILES ${debug_pdb_target_location} - DESTINATION ${ARG_PDB_DESTINATION} - ${PDB_RENAME_PARAM} - CONFIGURATIONS Release RelWithDebInfo - COMPONENT ${ARG_COMPONENT} - OPTIONAL) - ENDIF() -ENDFUNCTION() - - FUNCTION(INSTALL_MYSQL_TEST from to) IF(INSTALL_MYSQLTESTDIR) INSTALL( diff --git a/cmake/jemalloc.cmake b/cmake/jemalloc.cmake index 08ab2877c89..55369157689 100644 --- a/cmake/jemalloc.cmake +++ b/cmake/jemalloc.cmake @@ -17,7 +17,7 @@ MACRO (CHECK_JEMALLOC) IF(WITH_JEMALLOC STREQUAL "static") SET(libname jemalloc_pic) - SET(CMAKE_REQUIRED_LIBRARIES pthread dl m) + SET(CMAKE_REQUIRED_LIBRARIES pthread ${CMAKE_DL_LIBS} m) SET(what bundled) ELSE() SET(libname jemalloc c) diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake index ffe746bfb08..4112faa341c 100644 --- a/cmake/libutils.cmake +++ b/cmake/libutils.cmake @@ -143,19 +143,19 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) SET(OSLIBS) FOREACH(LIB ${LIBS_TO_MERGE}) - GET_TARGET_PROPERTY(LIB_LOCATION ${LIB} LOCATION) - GET_TARGET_PROPERTY(LIB_TYPE ${LIB} TYPE) - IF(NOT LIB_LOCATION) + 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_LIBS ${STATIC_LIBS} ${LIB_LOCATION}) + SET(STATIC_TGTS ${STATIC_TGTS} ${LIB}) + SET(STATIC_LIBS ${STATIC_LIBS} $<TARGET_FILE:${LIB}>) ADD_DEPENDENCIES(${TARGET} ${LIB}) - # Extract dependend OS libraries + # Extract dependent OS libraries GET_DEPENDEND_OS_LIBS(${LIB} LIB_OSLIBS) LIST(APPEND OSLIBS ${LIB_OSLIBS}) ELSE() @@ -166,7 +166,7 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) ENDFOREACH() IF(OSLIBS) LIST(REMOVE_DUPLICATES OSLIBS) - TARGET_LINK_LIBRARIES(${TARGET} ${OSLIBS}) + TARGET_LINK_LIBRARIES(${TARGET} LINK_PRIVATE ${OSLIBS}) ENDIF() # Make the generated dummy source file depended on all static input @@ -175,7 +175,7 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) ADD_CUSTOM_COMMAND( OUTPUT ${SOURCE_FILE} COMMAND ${CMAKE_COMMAND} -E touch ${SOURCE_FILE} - DEPENDS ${STATIC_LIBS}) + DEPENDS ${STATIC_TGTS}) IF(MSVC) # To merge libs, just pass them to lib.exe command line. @@ -186,29 +186,27 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) SET_TARGET_PROPERTIES(${TARGET} PROPERTIES STATIC_LIBRARY_FLAGS "${LINKER_EXTRA_FLAGS}") ELSE() - GET_TARGET_PROPERTY(TARGET_LOCATION ${TARGET} LOCATION) IF(APPLE) # Use OSX's libtool to merge archives (ihandles universal # binaries properly) ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD - COMMAND rm ${TARGET_LOCATION} - COMMAND libtool -static -o ${TARGET_LOCATION} + 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 extracts objects from archives with "ar x" # and repacks them with "ar r" - SET(TARGET ${TARGET}) - CONFIGURE_FILE( - ${MYSQL_CMAKE_SCRIPT_DIR}/merge_archives_unix.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET}.cmake - @ONLY - ) ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD - COMMAND rm ${TARGET_LOCATION} - COMMAND ${CMAKE_COMMAND} -P - ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET}.cmake + COMMAND ${CMAKE_COMMAND} + -DTARGET_LOCATION="$<TARGET_FILE:${TARGET}>" + -DTARGET="${TARGET}" + -DSTATIC_LIBS="${STATIC_LIBS}" + -DCMAKE_CURRENT_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}" + -DCMAKE_AR="${CMAKE_AR}" + -DCMAKE_RANLIB="${CMAKE_RANLIB}" + -P "${MYSQL_CMAKE_SCRIPT_DIR}/merge_archives_unix.cmake" ) ENDIF() ENDIF() @@ -273,7 +271,7 @@ MACRO(MERGE_LIBRARIES) IF (ARG_SOVERSION) SET_TARGET_PROPERTIES(${TARGET} PROPERTIES SOVERSION ${ARG_VERSION}) ENDIF() - TARGET_LINK_LIBRARIES(${TARGET} ${LIBS}) + TARGET_LINK_LIBRARIES(${TARGET} LINK_PRIVATE ${LIBS}) IF(ARG_OUTPUT_NAME) SET_TARGET_PROPERTIES(${TARGET} PROPERTIES OUTPUT_NAME "${ARG_OUTPUT_NAME}") ENDIF() @@ -286,7 +284,6 @@ MACRO(MERGE_LIBRARIES) ENDIF() MYSQL_INSTALL_TARGETS(${TARGET} DESTINATION "${INSTALL_LIBDIR}" ${COMP}) ENDIF() - SET_TARGET_PROPERTIES(${TARGET} PROPERTIES LINK_INTERFACE_LIBRARIES "") 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) @@ -299,18 +296,11 @@ MACRO(MERGE_LIBRARIES) ENDMACRO() FUNCTION(GET_DEPENDEND_OS_LIBS target result) - SET(deps ${${target}_LIB_DEPENDS}) - IF(deps) - FOREACH(lib ${deps}) - # Filter out keywords for used for debug vs optimized builds - IF(NOT lib MATCHES "general" AND NOT lib MATCHES "debug" AND NOT lib MATCHES "optimized") - GET_TARGET_PROPERTY(lib_location ${lib} LOCATION) - IF(NOT lib_location) - SET(ret ${ret} ${lib}) - ENDIF() + FOREACH(lib ${${target}_LIB_DEPENDS}) + IF(NOT TARGET ${lib}) + SET(ret ${ret} ${lib}) ENDIF() - ENDFOREACH() - ENDIF() + ENDFOREACH() SET(${result} ${ret} PARENT_SCOPE) ENDFUNCTION() diff --git a/cmake/maintainer.cmake b/cmake/maintainer.cmake index 933b04fb7f0..8dbe7a6df47 100644 --- a/cmake/maintainer.cmake +++ b/cmake/maintainer.cmake @@ -31,6 +31,7 @@ SET(MY_WARNING_FLAGS -Wno-unused-parameter -Wno-unused-private-field -Woverloaded-virtual + -Wnon-virtual-dtor -Wvla -Wwrite-strings ) diff --git a/cmake/make_dist.cmake.in b/cmake/make_dist.cmake.in index 4bc68d5edf9..75691f944d6 100644 --- a/cmake/make_dist.cmake.in +++ b/cmake/make_dist.cmake.in @@ -59,6 +59,9 @@ IF(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) @@ -71,8 +74,8 @@ IF(NOT GIT_EXECUTABLE) # 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.h - ${CMAKE_BINARY_DIR}/sql_yacc.h COPYONLY) + CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.hh + ${CMAKE_BINARY_DIR}/sql_yacc.hh COPYONLY) IF(CMAKE_GENERATOR MATCHES "Makefiles") # make clean @@ -85,10 +88,10 @@ IF(NOT GIT_EXECUTABLE) # 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.h + 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.h) + FILE(REMOVE ${CMAKE_BINARY_DIR}/sql_yacc.hh) ENDIF() EXECUTE_PROCESS( @@ -106,10 +109,15 @@ IF(NOT GIT_EXECUTABLE) ENDIF() # Copy bison output -CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.h - ${PACKAGE_DIR}/sql/sql_yacc.h COPYONLY) +CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.hh + ${PACKAGE_DIR}/sql/sql_yacc.hh COPYONLY) CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.cc ${PACKAGE_DIR}/sql/sql_yacc.cc COPYONLY) +# Copy bison output +CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.hh + ${PACKAGE_DIR}/sql/sql_yacc_ora.hh COPYONLY) +CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc_ora.cc + ${PACKAGE_DIR}/sql/sql_yacc_ora.cc COPYONLY) # Add documentation, if user has specified where to find them IF(MYSQL_DOCS_LOCATION) diff --git a/cmake/mariadb_connector_c.cmake b/cmake/mariadb_connector_c.cmake index 0f08c3464c4..ca0e16c8518 100644 --- a/cmake/mariadb_connector_c.cmake +++ b/cmake/mariadb_connector_c.cmake @@ -42,3 +42,6 @@ ADD_SUBDIRECTORY(libmariadb) IF(TARGET caching_sha2_password AND CMAKE_C_FLAGS_DEBUG MATCHES "-Werror") SET_PROPERTY(TARGET caching_sha2_password APPEND_STRING PROPERTY COMPILE_FLAGS -Wno-unused-function) 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.in b/cmake/merge_archives_unix.cmake index 7bb5f54f411..09f4fbf2506 100644 --- a/cmake/merge_archives_unix.cmake.in +++ b/cmake/merge_archives_unix.cmake @@ -14,19 +14,12 @@ # 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 merges many static libraries into -# one big library on Unix. -SET(TARGET_LOCATION "@TARGET_LOCATION@") -SET(TARGET "@TARGET@") -SET(STATIC_LIBS "@STATIC_LIBS@") -SET(CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@") -SET(CMAKE_AR "@CMAKE_AR@") -SET(CMAKE_RANLIB "@CMAKE_RANLIB@") - +FILE(REMOVE "${TARGET_LOCATION}") SET(TEMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET}) MAKE_DIRECTORY(${TEMP_DIR}) # Extract each archive to its own subdirectory(avoid object filename clashes) +SEPARATE_ARGUMENTS(STATIC_LIBS UNIX_COMMAND "${STATIC_LIBS}") FOREACH(LIB ${STATIC_LIBS}) GET_FILENAME_COMPONENT(NAME_NO_EXT ${LIB} NAME_WE) SET(TEMP_SUBDIR ${TEMP_DIR}/${NAME_NO_EXT}) diff --git a/cmake/mysql_version.cmake b/cmake/mysql_version.cmake index 114af99f954..85273136a32 100644 --- a/cmake/mysql_version.cmake +++ b/cmake/mysql_version.cmake @@ -48,6 +48,7 @@ MACRO(GET_MYSQL_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 @@ -69,6 +70,10 @@ 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) @@ -93,7 +98,7 @@ MariaDB bug reports should be submitted through https://jira.mariadb.org ") SET(CPACK_SOURCE_GENERATOR "TGZ") -# Defintions for windows version resources +# Definitions for windows version resources SET(PRODUCTNAME "MariaDB Server") SET(COMPANYNAME ${CPACK_PACKAGE_VENDOR}) diff --git a/cmake/numa.cmake b/cmake/numa.cmake index a7b0c0a3392..0ccb560d378 100644 --- a/cmake/numa.cmake +++ b/cmake/numa.cmake @@ -1,16 +1,18 @@ MACRO (MYSQL_CHECK_NUMA) - IF(CMAKE_SYSTEM_NAME MATCHES "Linux") + 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) - OPTION(WITH_NUMA "Explicitly set NUMA memory allocation policy" ON) - ELSE() - OPTION(WITH_NUMA "Explicitly set NUMA memory allocation policy" OFF) - ENDIF() - - IF(WITH_NUMA AND 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( @@ -32,12 +34,19 @@ MACRO (MYSQL_CHECK_NUMA) ENDIF() ADD_FEATURE_INFO(NUMA HAVE_LIBNUMA "NUMA memory allocation policy") - IF(WITH_NUMA AND NOT HAVE_LIBNUMA) + 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 "Could not find numa headers/libraries") + MESSAGE(FATAL_ERROR "WITH_NUMA=ON: Could not find NUMA headers/libraries") ENDIF() + ENDIF() ENDMACRO() diff --git a/cmake/os/Linux.cmake b/cmake/os/Linux.cmake index 1575c16bb4c..6fde915165f 100644 --- a/cmake/os/Linux.cmake +++ b/cmake/os/Linux.cmake @@ -34,8 +34,8 @@ ENDFOREACH() # Ensure we have clean build for shared libraries # without unresolved symbols -# Not supported with AddressSanitizer -IF(NOT WITH_ASAN AND NOT WITH_UBSAN) +# 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() diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake index 75a0d71cc2d..dbb18a488c7 100644 --- a/cmake/os/Windows.cmake +++ b/cmake/os/Windows.cmake @@ -59,7 +59,41 @@ IF(MINGW AND CMAKE_SIZEOF_VOID_P EQUAL 4) ADD_DEFINITIONS(-march=i486) ENDIF() +FUNCTION(ENABLE_ASAN) + IF(NOT (MSVC AND CMAKE_CXX_COMPILER_ID MATCHES Clang)) + MESSAGE(FATAL_ERROR "clang-cl is necessary to enable asan") + ENDIF() + # currently, asan is broken with static CRT. + IF(NOT(MSVC_CRT_TYPE STREQUAL "/MD")) + MESSAGE(FATAL_ERROR "-DWITH_ASAN cmake parameter also requires -DMSVC_CRT_TYPE=/MD") + ENDIF() + IF(CMAKE_SIZEOF_VOID_P EQUAL 4) + MESSAGE(FATAL_ERROR "-DWITH_ASAN on Windows requires 64bit build") + ENDIF() + # After installation, clang lib directory should be added to PATH + # (e.g C:/Program Files/LLVM/lib/clang/5.0.1/lib/windows) + FIND_LIBRARY(CLANG_RT_ASAN_DYNAMIC clang_rt.asan_dynamic-x86_64.lib) + IF(NOT CLANG_RT_ASAN_DYNAMIC) + MESSAGE(FATAL_ERROR "Can't enable ASAN : missing clang_rt.asan_dynamic-x86_64.lib") + ENDIF() + + FIND_LIBRARY(CLANG_RT_ASAN_DYNAMIC_THUNK clang_rt.asan_dynamic_runtime_thunk-x86_64.lib) + IF(NOT CLANG_RT_ASAN_DYNAMIC_THUNK) + MESSAGE(FATAL_ERROR "Can't enable ASAN : missing clang_rt.asan_dynamic_runtime_thunk-x86_64.lib") + ENDIF() + + STRING(APPEND CMAKE_C_FLAGS " -fsanitize=address") + STRING(APPEND CMAKE_CXX_FLAGS " -fsanitize=address") + + LINK_LIBRARIES(${CLANG_RT_ASAN_DYNAMIC} ${CLANG_RT_ASAN_DYNAMIC_THUNK}) +ENDFUNCTION() + + IF(MSVC) + IF(WITH_ASAN) + ENABLE_ASAN() + ENDIF() + # Disable mingw based pkg-config found in Strawberry perl SET(PKG_CONFIG_EXECUTABLE 0 CACHE INTERNAL "") SET(MSVC_CRT_TYPE /MT CACHE STRING @@ -119,8 +153,16 @@ IF(MSVC) STRING(APPEND ${flag} " /Z7") ENDIF() ENDFOREACH() - - + + IF(CMAKE_CXX_COMPILER_ID MATCHES Clang) + SET(CLANG_CL_FLAGS +"-Wno-unused-parameter -Wno-unused-command-line-argument -Wno-pointer-sign -Wno-deprecated-register \ +-Wno-missing-braces -Wno-unused-function -msse4.2 " + ) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CLANG_CL_FLAGS}") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CLANG_CL_FLAGS}") + ENDIF() + # Fix CMake's predefined huge stack size FOREACH(type EXE SHARED MODULE) STRING(REGEX REPLACE "/STACK:([^ ]+)" "" CMAKE_${type}_LINKER_FLAGS "${CMAKE_${type}_LINKER_FLAGS}") @@ -139,19 +181,18 @@ IF(MSVC) ENDIF() # Speed up multiprocessor build - IF (MSVC_VERSION GREATER 1400) + IF (MSVC_VERSION GREATER 1400 AND (NOT CMAKE_CXX_COMPILER_ID MATCHES Clang)) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") ENDIF() #TODO: update the code and remove the disabled warnings - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4805 /wd4996 /we4700 /we4311 /we4477 /we4302 /we4090") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4805 /wd4291 /wd4996 /we4099 /we4700 /we4311 /we4477 /we4302 /we4090") - IF(CMAKE_SIZEOF_VOID_P EQUAL 8) - # Temporarily disable size_t warnings, due to their amount - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4267") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /we4700 /we4311 /we4477 /we4302 /we4090") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /we4099 /we4700 /we4311 /we4477 /we4302 /we4090") + IF(MSVC_VERSION GREATER 1910 AND (NOT CMAKE_CXX_COMPILER_ID MATCHES Clang)) + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive-") ENDIF() + ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_WARNINGS) IF(MYSQL_MAINTAINER_MODE MATCHES "ERR") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX") @@ -165,7 +206,7 @@ IF(MSVC) # Noisy warning C4800: 'type': forcing value to bool 'true' or 'false' (performance warning), # removed in VS2017 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800") - ELSE() + ELSEIF (NOT (CMAKE_CXX_COMPILER_ID MATCHES Clang)) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /d2OptimizeHugeFunctions") ENDIF() ENDIF() @@ -226,7 +267,6 @@ 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_SYMBOL_REPLACEMENT(finite _finite "math;float.h") CHECK_FUNCTION_REPLACEMENT(popen _popen) CHECK_FUNCTION_REPLACEMENT(pclose _pclose) CHECK_FUNCTION_REPLACEMENT(access _access) diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake index c6b334d10a3..7202740e51f 100644 --- a/cmake/os/WindowsCache.cmake +++ b/cmake/os/WindowsCache.cmake @@ -51,8 +51,6 @@ SET(HAVE_DECL_FDATASYNC CACHE INTERNAL "") SET(HAVE_FEDISABLEEXCEPT CACHE INTERNAL "") SET(HAVE_FENV_H CACHE INTERNAL "") SET(HAVE_FESETROUND CACHE INTERNAL "") -SET(HAVE_FINITE CACHE INTERNAL "") -SET(HAVE_FINITE_IN_MATH_H CACHE INTERNAL "") SET(HAVE_FLOAT_H 1 CACHE INTERNAL "") SET(HAVE_FNMATCH_H CACHE INTERNAL "") SET(HAVE_FPU_CONTROL_H CACHE INTERNAL "") @@ -83,13 +81,11 @@ 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_ISINF CACHE INTERNAL "") SET(HAVE_LANGINFO_H CACHE INTERNAL "") SET(HAVE_LDIV 1 CACHE INTERNAL "") SET(HAVE_LIMITS_H 1 CACHE INTERNAL "") SET(HAVE_LOCALE_H 1 CACHE INTERNAL "") SET(HAVE_LOCALTIME_R 1 CACHE INTERNAL "") -#SET(HAVE_LOG2 CACHE INTERNAL "") SET(HAVE_LRAND48 CACHE INTERNAL "") SET(HAVE_LSTAT CACHE INTERNAL "") SET(HAVE_MADVISE CACHE INTERNAL "") @@ -101,6 +97,7 @@ 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 "") @@ -142,7 +139,6 @@ 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_RINT CACHE INTERNAL "") SET(HAVE_RWLOCK_INIT CACHE INTERNAL "") SET(HAVE_SCHED_H CACHE INTERNAL "") SET(HAVE_SCHED_YIELD CACHE INTERNAL "") @@ -241,7 +237,6 @@ 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_TEMPNAM 1 CACHE INTERNAL "") SET(HAVE_TERMCAP_H CACHE INTERNAL "") SET(HAVE_TERMIOS_H CACHE INTERNAL "") SET(HAVE_TERMIO_H CACHE INTERNAL "") diff --git a/cmake/package_name.cmake b/cmake/package_name.cmake index b93641109c3..ce13a446fe6 100644 --- a/cmake/package_name.cmake +++ b/cmake/package_name.cmake @@ -139,7 +139,7 @@ IF(NOT VERSION) SET(package_name "mariadb${PRODUCT_TAG}-${VERSION}-${SYSTEM_NAME_AND_PROCESSOR}") - MESSAGE(STATUS "Packaging as: ${package_name}") + MESSAGE_ONCE(package_name "Packaging as: ${package_name}") # Sometimes package suffix is added (something like "-icc-glibc23") IF(PACKAGE_SUFFIX) diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index 8b050a808ab..e7e9d2a3642 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -1,6 +1,6 @@ # 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. @@ -12,7 +12,7 @@ # # 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 +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA INCLUDE(CMakeParseArguments) @@ -249,7 +249,6 @@ MACRO(MYSQL_ADD_PLUGIN) 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}) ENDIF() GET_FILENAME_COMPONENT(subpath ${CMAKE_CURRENT_SOURCE_DIR} NAME) diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake index 1b238826311..84de8162c1b 100644 --- a/cmake/ssl.cmake +++ b/cmake/ssl.cmake @@ -129,13 +129,14 @@ MACRO (MYSQL_CHECK_SSL) 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} ${LIBDL}) + SET(SSL_LIBRARIES ${SSL_LIBRARIES} ${CMAKE_DL_LIBS}) ENDIF() MESSAGE_ONCE(OPENSSL_INCLUDE_DIR "OPENSSL_INCLUDE_DIR = ${OPENSSL_INCLUDE_DIR}") @@ -147,6 +148,7 @@ MACRO (MYSQL_CHECK_SSL) 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" @@ -155,6 +157,8 @@ MACRO (MYSQL_CHECK_SSL) HAVE_EncryptAes128Ctr) CHECK_SYMBOL_EXISTS(EVP_aes_128_gcm "openssl/evp.h" HAVE_EncryptAes128Gcm) + 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") diff --git a/cmake/systemd.cmake b/cmake/systemd.cmake index df10d6396df..978be0b9f98 100644 --- a/cmake/systemd.cmake +++ b/cmake/systemd.cmake @@ -20,10 +20,12 @@ MACRO(CHECK_SYSTEMD) 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) + 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}) |