diff options
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/abi_check.cmake | 2 | ||||
-rw-r--r-- | cmake/bison.cmake | 20 | ||||
-rw-r--r-- | cmake/build_configurations/mysql_release.cmake | 9 | ||||
-rw-r--r-- | cmake/character_sets.cmake | 4 | ||||
-rw-r--r-- | cmake/configure.pl | 20 | ||||
-rw-r--r-- | cmake/cpack_deb.cmake | 1 | ||||
-rw-r--r-- | cmake/cpack_rpm.cmake | 8 | ||||
-rw-r--r-- | cmake/cpu_info.cmake | 30 | ||||
-rw-r--r-- | cmake/create_initial_db.cmake.in | 7 | ||||
-rw-r--r-- | cmake/install_macros.cmake | 72 | ||||
-rw-r--r-- | cmake/jemalloc.cmake | 21 | ||||
-rw-r--r-- | cmake/libutils.cmake | 27 | ||||
-rw-r--r-- | cmake/maintainer.cmake | 6 | ||||
-rw-r--r-- | cmake/mysql_add_executable.cmake | 3 | ||||
-rw-r--r-- | cmake/mysql_version.cmake | 4 | ||||
-rw-r--r-- | cmake/os/Windows.cmake | 10 | ||||
-rw-r--r-- | cmake/os/WindowsCache.cmake | 5 | ||||
-rw-r--r-- | cmake/package_name.cmake | 4 | ||||
-rw-r--r-- | cmake/pcre.cmake | 28 | ||||
-rw-r--r-- | cmake/plugin.cmake | 44 | ||||
-rw-r--r-- | cmake/sign.cmake.in | 18 | ||||
-rw-r--r-- | cmake/ssl.cmake | 217 | ||||
-rw-r--r-- | cmake/zlib.cmake | 2 |
23 files changed, 420 insertions, 142 deletions
diff --git a/cmake/abi_check.cmake b/cmake/abi_check.cmake index cca595c5635..e8d2737f116 100644 --- a/cmake/abi_check.cmake +++ b/cmake/abi_check.cmake @@ -28,7 +28,7 @@ ELSE() SET(RUN_ABI_CHECK 0) ENDIF() -IF(CMAKE_COMPILER_IS_GNUCC AND RUN_ABI_CHECK) +IF(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang" AND RUN_ABI_CHECK) IF(CMAKE_C_COMPILER MATCHES "ccache$") SET(COMPILER ${CMAKE_C_COMPILER_ARG1}) STRING(REGEX REPLACE "^ " "" COMPILER ${COMPILER}) diff --git a/cmake/bison.cmake b/cmake/bison.cmake index d5c725fbbde..0892a213d04 100644 --- a/cmake/bison.cmake +++ b/cmake/bison.cmake @@ -47,6 +47,21 @@ MACRO (RUN_BISON input_yy output_cc output_h) 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} @@ -54,8 +69,9 @@ MACRO (RUN_BISON input_yy output_cc output_h) --output=${output_cc} --defines=${output_h} ${input_yy} - DEPENDS ${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}) diff --git a/cmake/build_configurations/mysql_release.cmake b/cmake/build_configurations/mysql_release.cmake index 39ad0e68d35..78314342426 100644 --- a/cmake/build_configurations/mysql_release.cmake +++ b/cmake/build_configurations/mysql_release.cmake @@ -47,6 +47,8 @@ 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}}) @@ -83,7 +85,7 @@ IF(FEATURE_SET) # Update cache with current values, remove engines we do not care about # from build. - FOREACH(eng ARCHIVE BLACKHOLE FEDERATED INNOBASE PARTITION EXAMPLE) + 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) @@ -104,7 +106,6 @@ ELSEIF(DEB) SET(WITH_SSL system CACHE STRING "") SET(WITH_ZLIB system CACHE STRING "") SET(WITH_LIBWRAP ON) - SET(WITH_MAX ON) SET(HAVE_EMBEDDED_PRIVILEGE_CONTROL ON) ELSE() SET(WITH_SSL bundled CACHE STRING "") @@ -145,12 +146,12 @@ IF(UNIX) ENDIF() # Remove libaio dependency from mysqld - SET(XTRADB_PREFER_STATIC_LIBAIO 1) + #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 - SET(LIBMYSQLD_SO_EXTRA_LIBS aio) + #SET(LIBMYSQLD_SO_EXTRA_LIBS aio) ENDIF() ENDIF() diff --git a/cmake/character_sets.cmake b/cmake/character_sets.cmake index 74a39e09cac..1c93441cbb1 100644 --- a/cmake/character_sets.cmake +++ b/cmake/character_sets.cmake @@ -25,14 +25,14 @@ ENDIF() SET(CHARSETS ${DEFAULT_CHARSET} latin1 utf8 utf8mb4) SET(CHARSETS_COMPLEX big5 cp1250 cp932 eucjpms euckr gb2312 gbk latin1 latin2 - sjis tis620 ucs2 ujis utf8 utf8mb4 utf16 utf32) + sjis tis620 ucs2 ujis utf8 utf8mb4 utf16 utf16le utf32) SET(CHARSETS_AVAILABLE binary armscii8 ascii big5 cp1250 cp1251 cp1256 cp1257 cp850 cp852 cp866 cp932 dec8 eucjpms euckr gb2312 gbk geostd8 greek hebrew hp8 keybcs2 koi8r koi8u latin1 latin2 latin5 latin7 macce macroman -sjis swe7 tis620 ucs2 ujis utf8 utf8mb4 utf16 utf32) +sjis swe7 tis620 ucs2 ujis utf8 utf8mb4 utf16 utf16le utf32) SET (EXTRA_CHARSETS "all") diff --git a/cmake/configure.pl b/cmake/configure.pl index d5c0b9b061a..a71795a3bc8 100644 --- a/cmake/configure.pl +++ b/cmake/configure.pl @@ -150,6 +150,16 @@ foreach my $option (@ARGV) $cmakeargs = $cmakeargs." -DWITH_ZLIB=system"; next; } + if($option =~ /with-libevent=/) + { + $cmakeargs = $cmakeargs." -DWITH_LIBEVENT=system"; + next; + } + if($option =~ /with-libevent/) + { + $cmakeargs = $cmakeargs." -DWITH_LIBEVENT=bundled"; + next; + } if($option =~ /with-ssl=/) { $cmakeargs = $cmakeargs." -DWITH_SSL=yes"; @@ -237,6 +247,16 @@ foreach my $option (@ARGV) print("configure.pl : ignoring $option\n"); next; } + if ($option =~ /with-client-ldflags/) + { + print("configure.pl : ignoring $option\n"); + next; + } + if ($option =~ /with-mysqld-ldflags=/) + { + print("configure.pl : ignoring $option\n"); + next; + } $option = uc($option); $option =~ s/-/_/g; diff --git a/cmake/cpack_deb.cmake b/cmake/cpack_deb.cmake index 5fb9db1f07f..22985e5ac56 100644 --- a/cmake/cpack_deb.cmake +++ b/cmake/cpack_deb.cmake @@ -5,5 +5,6 @@ IF(DEB) SET(CPACK_COMPONENT_SERVER_GROUP "server") SET(CPACK_COMPONENT_README_GROUP "server") +SET(CPACK_COMPONENTS_ALL Server Test SharedLibraries) ENDIF(DEB) diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index 4e9410306a8..e5206d9690c 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -21,11 +21,12 @@ SET(CPACK_COMPONENT_MANPAGESCLIENT_GROUP "client") SET(CPACK_COMPONENT_README_GROUP "server") SET(CPACK_COMPONENT_SHAREDLIBRARIES_GROUP "shared") SET(CPACK_COMPONENT_COMMON_GROUP "common") +SET(CPACK_COMPONENT_CLIENTPLUGINS_GROUP "common") SET(CPACK_COMPONENT_COMPAT_GROUP "compat") SET(CPACK_COMPONENTS_ALL Server ManPagesServer IniFiles Server_Scripts SupportFiles Development ManPagesDevelopment ManPagesTest Readme ManPagesClient Test - Common Client SharedLibraries) + Common Client SharedLibraries ClientPlugins) SET(CPACK_RPM_PACKAGE_NAME "MariaDB") IF(CMAKE_VERSION VERSION_LESS "3.6.0") @@ -38,6 +39,7 @@ ENDIF() SET(CPACK_RPM_PACKAGE_RELEASE "1%{?dist}") SET(CPACK_RPM_PACKAGE_LICENSE "GPLv2") SET(CPACK_RPM_PACKAGE_RELOCATABLE FALSE) +SET(CPACK_PACKAGE_RELOCATABLE FALSE) SET(CPACK_RPM_PACKAGE_GROUP "Applications/Databases") SET(CPACK_RPM_PACKAGE_URL "http://mariadb.org") SET(CPACK_RPM_PACKAGE_SUMMARY "MariaDB: a very fast and robust SQL database server") @@ -46,8 +48,8 @@ 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 conditions of the GNU General Public License Version 2 (http://www.gnu.org/licenses/). -MariaDB documentation can be found at http://kb.askmonty.org/ -MariaDB bug reports should be submitted through https://mariadb.atlassian.net/ +MariaDB documentation can be found at https://mariadb.com/kb +MariaDB bug reports should be submitted through https://jira.mariadb.org ") diff --git a/cmake/cpu_info.cmake b/cmake/cpu_info.cmake new file mode 100644 index 00000000000..32b98142ace --- /dev/null +++ b/cmake/cpu_info.cmake @@ -0,0 +1,30 @@ +# Copyright (c) 2009, 2011, 2012 Oracle and/or its affiliates. All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +# Symbols with information about the CPU. + +FIND_PROGRAM(GETCONF getconf) +MARK_AS_ADVANCED(GETCONF) + +IF(GETCONF) + EXECUTE_PROCESS( + COMMAND ${GETCONF} LEVEL1_DCACHE_LINESIZE + OUTPUT_VARIABLE CPU_LEVEL1_DCACHE_LINESIZE + ) +ENDIF() +IF(CPU_LEVEL1_DCACHE_LINESIZE AND CPU_LEVEL1_DCACHE_LINESIZE GREATER 0) +ELSE() + SET(CPU_LEVEL1_DCACHE_LINESIZE 64) +ENDIF() diff --git a/cmake/create_initial_db.cmake.in b/cmake/create_initial_db.cmake.in index ce638b14e39..c77e28d882c 100644 --- a/cmake/create_initial_db.cmake.in +++ b/cmake/create_initial_db.cmake.in @@ -40,10 +40,11 @@ FOREACH(FILENAME mysql_system_tables.sql mysql_system_tables_data.sql mysql_perf ENDFOREACH() ENDFOREACH() FILE(READ ${CMAKE_SOURCE_DIR}/scripts/fill_help_tables.sql CONTENTS) -FILE(APPEND bootstrap.sql ${CONTENTS}) +FILE(APPEND bootstrap.sql "${CONTENTS}") +FILE(REMOVE_RECURSE mysql performance_schema) +FILE(REMOVE ibdata1 ib_logfile0 ib_logfile1) -FILE(REMOVE_RECURSE mysql) MAKE_DIRECTORY(mysql) IF(WIN32) SET(CONSOLE --console) @@ -58,8 +59,6 @@ SET(BOOTSTRAP_COMMAND --basedir=. --datadir=. --default-storage-engine=MyISAM - --loose-skip-innodb - --loose-skip-ndbcluster --max_allowed_packet=8M --net_buffer_length=16K ) diff --git a/cmake/install_macros.cmake b/cmake/install_macros.cmake index 22a525d7344..ff4ba593415 100644 --- a/cmake/install_macros.cmake +++ b/cmake/install_macros.cmake @@ -32,17 +32,8 @@ FUNCTION (INSTALL_DEBUG_SYMBOLS) ENDIF() SET(targets ${ARG_DEFAULT_ARGS}) FOREACH(target ${targets}) - GET_TARGET_PROPERTY(type ${target} TYPE) - GET_TARGET_PROPERTY(location ${target} LOCATION) - STRING(REPLACE ".exe" ".pdb" pdb_location ${location}) - STRING(REPLACE ".dll" ".pdb" pdb_location ${pdb_location}) - STRING(REPLACE ".lib" ".pdb" pdb_location ${pdb_location}) - IF(CMAKE_GENERATOR MATCHES "Visual Studio") - STRING(REPLACE - "${CMAKE_CFG_INTDIR}" "\${CMAKE_INSTALL_CONFIG_NAME}" - pdb_location ${pdb_location}) - ENDIF() - + GET_TARGET_PROPERTY(target_type ${target} TYPE) + set(comp "") IF(ARG_COMPONENT STREQUAL "Server") IF(target MATCHES "mysqld" OR type MATCHES "MODULE") @@ -62,11 +53,9 @@ FUNCTION (INSTALL_DEBUG_SYMBOLS) IF(NOT comp) SET(comp Debuginfo_archive_only) # not in MSI ENDIF() - IF(type MATCHES "STATIC") - # PDB for static libraries might be unsupported http://public.kitware.com/Bug/view.php?id=14600 - SET(opt OPTIONAL) - ENDIF() - INSTALL(FILES ${pdb_location} DESTINATION ${ARG_INSTALL_LOCATION} COMPONENT ${comp} ${opt}) + IF(NOT target_type MATCHES "STATIC") + INSTALL(FILES $<TARGET_PDB_FILE:${target}> DESTINATION ${ARG_INSTALL_LOCATION} COMPONENT ${comp}) + ENDIF() ENDFOREACH() ENDIF() ENDFUNCTION() @@ -126,6 +115,10 @@ FUNCTION(INSTALL_SCRIPT) SET(COMP) ENDIF() + IF (COMP MATCHES ${SKIP_COMPONENTS}) + RETURN() + ENDIF() + INSTALL(FILES ${script} DESTINATION ${ARG_DESTINATION} @@ -149,6 +142,10 @@ FUNCTION(INSTALL_DOCUMENTATION) SET(destination ${INSTALL_DOCDIR}) ENDIF() + IF (ARG_COMPONENT MATCHES ${SKIP_COMPONENTS}) + RETURN() + ENDIF() + STRING(TOUPPER ${ARG_COMPONENT} COMPUP) IF(CPACK_COMPONENT_${COMPUP}_GROUP) SET(group ${CPACK_COMPONENT_${COMPUP}_GROUP}) @@ -218,37 +215,22 @@ IF(WIN32) ENDIF() ENDIF() -MACRO(SIGN_TARGET) - MYSQL_PARSE_ARGUMENTS(ARG "COMPONENT" "" ${ARGN}) - SET(target ${ARG_DEFAULT_ARGS}) - IF(ARG_COMPONENT) - SET(comp COMPONENT ${ARG_COMPONENT}) - ELSE() - SET(comp) - ENDIF() - GET_TARGET_PROPERTY(target_type ${target} TYPE) - IF(target_type AND NOT target_type MATCHES "STATIC") - GET_TARGET_PROPERTY(target_location ${target} LOCATION) - IF(CMAKE_GENERATOR MATCHES "Visual Studio") - STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${CMAKE_INSTALL_CONFIG_NAME}" - target_location ${target_location}) - ENDIF() - INSTALL(CODE - "EXECUTE_PROCESS(COMMAND - \"${SIGNTOOL_EXECUTABLE}\" verify /pa /q \"${target_location}\" - RESULT_VARIABLE ERR) - IF(NOT \${ERR} EQUAL 0) - EXECUTE_PROCESS(COMMAND - \"${SIGNTOOL_EXECUTABLE}\" sign ${SIGNTOOL_PARAMETERS} \"${target_location}\" - RESULT_VARIABLE ERR) + +FUNCTION(SIGN_TARGET target) + IF(NOT SIGNCODE) + RETURN() ENDIF() - IF(NOT \${ERR} EQUAL 0) - MESSAGE(FATAL_ERROR \"Error signing '${target_location}'\") + GET_TARGET_PROPERTY(target_type ${target} TYPE) + IF((NOT target_type) OR (target_type MATCHES "STATIC")) + RETURN() ENDIF() - " ${comp}) - ENDIF() -ENDMACRO() - + # Mark executable for signing by creating empty *.signme file + # The actual signing happens in preinstall step + # (which traverses + ADD_CUSTOM_COMMAND(TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E touch "$<TARGET_FILE:${target}>.signme" + ) +ENDFUNCTION() # Installs targets, also installs pdbs on Windows. # diff --git a/cmake/jemalloc.cmake b/cmake/jemalloc.cmake index 39a97334071..5a3c1bd935b 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', 'auto'") MACRO (CHECK_JEMALLOC) # compatibility with old WITH_JEMALLOC values @@ -18,17 +18,24 @@ MACRO (CHECK_JEMALLOC) IF(WITH_JEMALLOC STREQUAL "static") SET(libname jemalloc_pic) SET(CMAKE_REQUIRED_LIBRARIES pthread dl m) + SET(what bundled) ELSE() - SET(libname jemalloc) + SET(libname jemalloc c) + SET(what system) ENDIF() - CHECK_LIBRARY_EXISTS(${libname} malloc_stats_print "" HAVE_JEMALLOC) + FOREACH(lib ${libname}) + CHECK_LIBRARY_EXISTS(${lib} malloc_stats_print "" HAVE_JEMALLOC_IN_${lib}) + IF (HAVE_JEMALLOC_IN_${lib}) + SET(LIBJEMALLOC ${lib}) + SET(MALLOC_LIBRARY "${what} jemalloc") + BREAK() + ENDIF() + ENDFOREACH() SET(CMAKE_REQUIRED_LIBRARIES) - IF (HAVE_JEMALLOC) - SET(LIBJEMALLOC ${libname}) - ELSEIF (NOT WITH_JEMALLOC STREQUAL "auto") - MESSAGE(FATAL_ERROR "${libname} is not found") + IF (NOT LIBJEMALLOC AND NOT WITH_JEMALLOC STREQUAL "auto") + MESSAGE(FATAL_ERROR "jemalloc is not found") ENDIF() ENDIF() ENDMACRO() diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake index 67e222eefb0..2a218bc63b0 100644 --- a/cmake/libutils.cmake +++ b/cmake/libutils.cmake @@ -192,7 +192,7 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE) # binaries properly) ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD COMMAND rm ${TARGET_LOCATION} - COMMAND /usr/bin/libtool -static -o ${TARGET_LOCATION} + COMMAND libtool -static -o ${TARGET_LOCATION} ${STATIC_LIBS} ) ELSE() @@ -313,20 +313,22 @@ FUNCTION(GET_DEPENDEND_OS_LIBS target result) SET(${result} ${ret} PARENT_SCOPE) ENDFUNCTION() -MACRO(RESTRICT_SYMBOL_EXPORTS target) - SET(VISIBILITY_HIDDEN_FLAG) +INCLUDE(CheckCCompilerFlag) - IF(CMAKE_COMPILER_IS_GNUCXX AND UNIX) - CHECK_C_COMPILER_FLAG("-fvisibility=hidden" HAVE_VISIBILITY_HIDDEN) - IF(HAVE_VISIBILITY_HIDDEN) - SET(VISIBILITY_HIDDEN_FLAG "-fvisibility=hidden") - ENDIF() - ENDIF() +SET(VISIBILITY_HIDDEN_FLAG) - IF(CMAKE_C_COMPILER_ID MATCHES "SunPro") - SET(VISIBILITY_HIDDEN_FLAG "-xldscope=hidden") +IF(CMAKE_C_COMPILER_ID MATCHES "SunPro") + SET(VISIBILITY_HIDDEN_FLAG "-xldscope=hidden") +ELSEIF(UNIX) + CHECK_C_COMPILER_FLAG("-fvisibility=hidden" HAVE_VISIBILITY_HIDDEN) + IF(HAVE_VISIBILITY_HIDDEN) + SET(VISIBILITY_HIDDEN_FLAG "-fvisibility=hidden") ENDIF() +ENDIF() +# We try to hide the symbols in yassl/zlib to avoid name clashes with +# other libraries like openssl. +FUNCTION(RESTRICT_SYMBOL_EXPORTS target) IF(VISIBILITY_HIDDEN_FLAG) GET_TARGET_PROPERTY(COMPILE_FLAGS ${target} COMPILE_FLAGS) IF(NOT COMPILE_FLAGS) @@ -336,5 +338,4 @@ MACRO(RESTRICT_SYMBOL_EXPORTS target) SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} ${VISIBILITY_HIDDEN_FLAG}") ENDIF() - -ENDMACRO() +ENDFUNCTION() diff --git a/cmake/maintainer.cmake b/cmake/maintainer.cmake index 872d61d9aac..4fe2546d709 100644 --- a/cmake/maintainer.cmake +++ b/cmake/maintainer.cmake @@ -35,17 +35,17 @@ IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang") ENDIF() # Turn on Werror (warning => error) when using maintainer mode. -IF(MYSQL_MAINTAINER_MODE MATCHES "ON") +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() # Set warning flags for GCC/Clang -IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "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_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") +IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") SET(MY_MAINTAINER_CXX_WARNINGS "${MY_CXX_WARNING_FLAGS}") ENDIF() diff --git a/cmake/mysql_add_executable.cmake b/cmake/mysql_add_executable.cmake index 45575bdd536..c8a2e522d66 100644 --- a/cmake/mysql_add_executable.cmake +++ b/cmake/mysql_add_executable.cmake @@ -59,6 +59,9 @@ FUNCTION (MYSQL_ADD_EXECUTABLE) ELSE() SET(COMP COMPONENT Client) ENDIF() + IF (COMP MATCHES ${SKIP_COMPONENTS}) + RETURN() + ENDIF() MYSQL_INSTALL_TARGETS(${target} DESTINATION ${ARG_DESTINATION} ${COMP}) ENDIF() ENDFUNCTION() diff --git a/cmake/mysql_version.cmake b/cmake/mysql_version.cmake index 7fa5240e324..f147f6ef2bf 100644 --- a/cmake/mysql_version.cmake +++ b/cmake/mysql_version.cmake @@ -49,7 +49,9 @@ MACRO(GET_MYSQL_VERSION) MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_PATCH" PATCH_VERSION) MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_EXTRA" EXTRA_VERSION) - IF(NOT MAJOR_VERSION OR NOT MINOR_VERSION OR NOT PATCH_VERSION) +IF(NOT "${MAJOR_VERSION}" MATCHES "[0-9]+" OR + NOT "${MINOR_VERSION}" MATCHES "[0-9]+" OR + NOT "${PATCH_VERSION}" MATCHES "[0-9]+") MESSAGE(FATAL_ERROR "VERSION file cannot be parsed.") ENDIF() diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake index ea5084ebba6..2058a21f559 100644 --- a/cmake/os/Windows.cmake +++ b/cmake/os/Windows.cmake @@ -51,7 +51,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=0x0A00) # We do not want the windows.h macros min/max ADD_DEFINITIONS(-DNOMINMAX) # Speed up build process excluding unused header files @@ -90,10 +90,6 @@ IF(MSVC) STRING(REPLACE "/Zi" "/Z7" "${flag}" "${${flag}}") ENDFOREACH() - # Remove support for exceptions - FOREACH(flag CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_INIT) - STRING(REPLACE "/EHsc" "" "${flag}" "${${flag}}") - ENDFOREACH() # Fix CMake's predefined huge stack size FOREACH(type EXE SHARED MODULE) @@ -119,8 +115,8 @@ IF(MSVC) ENDIF() #TODO: update the code and remove the disabled warnings - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4800 /wd4805 /wd4996") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800 /wd4805 /wd4996 /wd4291 /wd4577 /we4099") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4800 /wd4805 /wd4996 /we4700") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800 /wd4805 /wd4996 /wd4291 /wd4577 /we4099 /we4700") IF(CMAKE_SIZEOF_VOID_P MATCHES 8) # _WIN64 is defined by the compiler itself. diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake index 1694b238e7b..2808a6f749f 100644 --- a/cmake/os/WindowsCache.cmake +++ b/cmake/os/WindowsCache.cmake @@ -347,7 +347,6 @@ SET(C_HAS___inline 1 CACHE INTERNAL "") SET(FIONREAD_IN_SYS_IOCTL CACHE INTERNAL "") SET(FIONREAD_IN_SYS_FILIO CACHE INTERNAL "") SET(GWINSZ_IN_SYS_IOCTL CACHE INTERNAL "") -SET(HAVE_CXXABI_H CACHE INTERNAL "") SET(HAVE_NDIR_H CACHE INTERNAL "") SET(HAVE_SYS_NDIR_H CACHE INTERNAL "") SET(HAVE_SYS_NDIR_H CACHE INTERNAL "") @@ -367,4 +366,8 @@ 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 "") +SET(HAVE_VISIBILITY_HIDDEN CACHE INTERNAL "") ENDIF(MSVC) diff --git a/cmake/package_name.cmake b/cmake/package_name.cmake index 4ba8fc18e3f..48ca3a4814d 100644 --- a/cmake/package_name.cmake +++ b/cmake/package_name.cmake @@ -30,6 +30,10 @@ IF(NOT VERSION) SET(64BIT 1) ENDIF() + IF(NOT 64BIT AND CMAKE_SYSTEM_PROCESSOR MATCHES "^mips64") + SET(DEFAULT_MACHINE "mips") + ENDIF() + IF(CMAKE_SYSTEM_NAME MATCHES "Windows") SET(NEED_DASH_BETWEEN_PLATFORM_AND_MACHINE 0) SET(DEFAULT_PLATFORM "win") diff --git a/cmake/pcre.cmake b/cmake/pcre.cmake new file mode 100644 index 00000000000..4c113929866 --- /dev/null +++ b/cmake/pcre.cmake @@ -0,0 +1,28 @@ +INCLUDE (CheckCSourceRuns) + +SET(WITH_PCRE "auto" CACHE STRING + "Which pcre to use (possible values are 'bundled', 'system', or 'auto')") + +MACRO (CHECK_PCRE) + IF(WITH_PCRE STREQUAL "system" OR WITH_PCRE STREQUAL "auto") + CHECK_LIBRARY_EXISTS(pcre pcre_stack_guard "" HAVE_PCRE_STACK_GUARD) + IF(NOT CMAKE_CROSSCOMPILING) + SET(CMAKE_REQUIRED_LIBRARIES "pcre") + CHECK_C_SOURCE_RUNS(" + #include <pcre.h> + int main() { + return -pcre_exec(NULL, NULL, NULL, -999, -999, 0, NULL, 0) < 256; + }" PCRE_STACK_SIZE_OK) + SET(CMAKE_REQUIRED_LIBRARIES) + ENDIF() + ENDIF() + IF(NOT HAVE_PCRE_STACK_GUARD OR NOT PCRE_STACK_SIZE_OK OR + WITH_PCRE STREQUAL "bundled") + IF (WITH_PCRE STREQUAL "system") + MESSAGE(FATAL_ERROR "system pcre is not found or unusable") + ENDIF() + SET(PCRE_INCLUDES ${CMAKE_BINARY_DIR}/pcre ${CMAKE_SOURCE_DIR}/pcre) + ADD_SUBDIRECTORY(pcre) + ENDIF() +ENDMACRO() + diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake index 321724f3b16..e348bf9ccda 100644 --- a/cmake/plugin.cmake +++ b/cmake/plugin.cmake @@ -30,7 +30,7 @@ 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" + "LINK_LIBRARIES;DEPENDENCIES;MODULE_OUTPUT_NAME;STATIC_OUTPUT_NAME;COMPONENT;CONFIG" "STORAGE_ENGINE;STATIC_ONLY;MODULE_ONLY;MANDATORY;DEFAULT;DISABLED;RECOMPILE_FOR_EMBEDDED" ${ARGN} ) @@ -38,7 +38,7 @@ MACRO(MYSQL_ADD_PLUGIN) # Add common include directories INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql - ${CMAKE_SOURCE_DIR}/regex + ${PCRE_INCLUDES} ${SSL_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}) @@ -74,7 +74,8 @@ MACRO(MYSQL_ADD_PLUGIN) AND NOT ARG_MODULE_ONLY) SET(WITH_${plugin} 1) - ELSEIF(WITHOUT_${plugin}_STORAGE_ENGINE OR WITH_NONE OR ${plugin}_DISABLED) + 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) @@ -127,6 +128,7 @@ MACRO(MYSQL_ADD_PLUGIN) IF(ARG_RECOMPILE_FOR_EMBEDDED OR NOT _SKIP_PIC) # Recompile some plugins for embedded ADD_CONVENIENCE_LIBRARY(${target}_embedded ${SOURCES}) + RESTRICT_SYMBOL_EXPORTS(${target}_embedded) DTRACE_INSTRUMENT(${target}_embedded) IF(ARG_RECOMPILE_FOR_EMBEDDED) SET_TARGET_PROPERTIES(${target}_embedded @@ -155,12 +157,12 @@ MACRO(MYSQL_ADD_PLUGIN) IF(ARG_MANDATORY) SET (mysql_mandatory_plugins - "${mysql_mandatory_plugins} builtin_maria_${target}_plugin," - PARENT_SCOPE) + "${mysql_mandatory_plugins} builtin_maria_${target}_plugin,") + SET (mysql_mandatory_plugins ${mysql_mandatory_plugins} PARENT_SCOPE) ELSE() SET (mysql_optional_plugins - "${mysql_optional_plugins} builtin_maria_${target}_plugin," - PARENT_SCOPE) + "${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) @@ -178,8 +180,15 @@ MACRO(MYSQL_ADD_PLUGIN) # 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(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") - TARGET_LINK_LIBRARIES (${target} mysqld ${ARG_LINK_LIBRARIES}) + 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() + + IF(ARG_LINK_LIBRARIES) + TARGET_LINK_LIBRARIES (${target} ${ARG_LINK_LIBRARIES}) ENDIF() ADD_DEPENDENCIES(${target} GenError ${ARG_DEPENDENCIES}) @@ -192,14 +201,25 @@ MACRO(MYSQL_ADD_PLUGIN) OUTPUT_NAME "${ARG_MODULE_OUTPUT_NAME}") # Install dynamic library IF(ARG_COMPONENT) - IF(RPM AND NOT CPACK_COMPONENTS_ALL MATCHES ${ARG_COMPONENT}) + IF(CPACK_COMPONENTS_ALL AND NOT CPACK_COMPONENTS_ALL MATCHES ${ARG_COMPONENT} + AND INSTALL_SYSCONF2DIR) + + IF (ARG_STORAGE_ENGINE) + SET(ver " = %{version}-%{release}") + ENDIF() SET(CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL} ${ARG_COMPONENT} PARENT_SCOPE) - SET(CPACK_RPM_${ARG_COMPONENT}_PACKAGE_REQUIRES "MariaDB-server" PARENT_SCOPE) + SET(CPACK_RPM_${ARG_COMPONENT}_PACKAGE_REQUIRES "MariaDB${ver}" 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") + ENDIF() + INSTALL(FILES ${ARG_CONFIG} COMPONENT ${ARG_COMPONENT} DESTINATION ${INSTALL_SYSCONF2DIR}) # workarounds for cmake issues #13248 and #12864: - SET(CPACK_RPM_${ARG_COMPONENT}_USER_FILELIST ${ignored} PARENT_SCOPE) 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) ENDIF() ELSE() SET(ARG_COMPONENT Server) diff --git a/cmake/sign.cmake.in b/cmake/sign.cmake.in new file mode 100644 index 00000000000..61ae38d152d --- /dev/null +++ b/cmake/sign.cmake.in @@ -0,0 +1,18 @@ +FILE(GLOB_RECURSE files "@CMAKE_BINARY_DIR@/*.signme") +MESSAGE(STATUS "signing files") +FOREACH(f ${files}) + STRING(REPLACE ".signme" "" exe_location "${f}") + + string (REPLACE ";" " " params "@SIGNTOOL_PARAMETERS@") + #MESSAGE("@SIGNTOOL_EXECUTABLE@" sign ${params} "${exe_location}") + + EXECUTE_PROCESS(COMMAND + "@SIGNTOOL_EXECUTABLE@" sign @SIGNTOOL_PARAMETERS@ "${exe_location}" + RESULT_VARIABLE ERR) + IF(NOT ${ERR} EQUAL 0) + MESSAGE( "Error ${ERR} signing ${exe_location}") + ELSE() + FILE(REMOVE ${f}) + ENDIF() + +ENDFOREACH() diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake index 0c6cde31299..c76e73927c0 100644 --- a/cmake/ssl.cmake +++ b/cmake/ssl.cmake @@ -14,86 +14,233 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# We support different versions of SSL: +# - "bundled" uses source code in <source dir>/extra/yassl +# - "system" (typically) uses headers/libraries in /usr/lib and /usr/lib64 +# - a custom installation of openssl can be used like this +# - cmake -DCMAKE_PREFIX_PATH=</path/to/custom/openssl> -DWITH_SSL="system" +# or +# - cmake -DWITH_SSL=</path/to/custom/openssl> +# +# The default value for WITH_SSL is "bundled" +# set in cmake/build_configurations/feature_set.cmake +# +# For custom build/install of openssl, see the accompanying README and +# INSTALL* files. When building with gcc, you must build the shared libraries +# (in addition to the static ones): +# ./config --prefix=</path/to/custom/openssl> --shared; make; make install +# On some platforms (mac) you need to choose 32/64 bit architecture. +# Build/Install of openssl on windows is slightly different: you need to run +# perl and nmake. You might also need to +# 'set path=</path/to/custom/openssl>\bin;%PATH% +# in order to find the .dll files at runtime. + +SET(WITH_SSL_DOC "bundled (use yassl)") +SET(WITH_SSL_DOC + "${WITH_SSL_DOC}, yes (prefer os library if present, otherwise use bundled)") +SET(WITH_SSL_DOC + "${WITH_SSL_DOC}, system (use os library)") +SET(WITH_SSL_DOC + "${WITH_SSL_DOC}, </path/to/custom/installation>") + MACRO (CHANGE_SSL_SETTINGS string) - SET(WITH_SSL ${string} CACHE STRING "Options are: no bundled yes(prefer os library if present otherwise use bundled) system(use os library)" FORCE) + SET(WITH_SSL ${string} CACHE STRING ${WITH_SSL_DOC} FORCE) ENDMACRO() MACRO (MYSQL_USE_BUNDLED_SSL) SET(INC_DIRS - ${CMAKE_SOURCE_DIR}/extra/yassl/include - ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/include + ${CMAKE_SOURCE_DIR}/extra/yassl/include + ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/include ) SET(SSL_LIBRARIES yassl taocrypt) SET(SSL_INCLUDE_DIRS ${INC_DIRS}) SET(SSL_INTERNAL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL) - SET(SSL_DEFINES "-DHAVE_YASSL -DYASSL_PURE_C -DYASSL_PREFIX -DHAVE_OPENSSL -DMULTI_THREADED") + 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") CHANGE_SSL_SETTINGS("bundled") - #Remove -fno-implicit-templates - #(yassl sources cannot be compiled with it) - SET(SAVE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) - IF(CMAKE_CXX_FLAGS) - STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS - ${CMAKE_CXX_FLAGS}) - ENDIF() ADD_SUBDIRECTORY(extra/yassl) ADD_SUBDIRECTORY(extra/yassl/taocrypt) - SET(CMAKE_CXX_FLAGS ${SAVE_CXX_FLAGS}) GET_TARGET_PROPERTY(src yassl SOURCES) FOREACH(file ${src}) SET(SSL_SOURCES ${SSL_SOURCES} ${CMAKE_SOURCE_DIR}/extra/yassl/${file}) ENDFOREACH() GET_TARGET_PROPERTY(src taocrypt SOURCES) FOREACH(file ${src}) - SET(SSL_SOURCES ${SSL_SOURCES} ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/${file}) + SET(SSL_SOURCES ${SSL_SOURCES} + ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/${file}) ENDFOREACH() ENDMACRO() # MYSQL_CHECK_SSL # # Provides the following configure options: -# WITH_SSL=[yes|no|bundled] +# WITH_SSL=[yes|bundled|system|<path/to/custom/installation>] MACRO (MYSQL_CHECK_SSL) IF(NOT WITH_SSL) IF(WIN32) CHANGE_SSL_SETTINGS("bundled") ELSE() - CHANGE_SSL_SETTINGS("no") + SET(WITH_SSL "yes") ENDIF() ENDIF() + # See if WITH_SSL is of the form </path/to/custom/installation> + FILE(GLOB WITH_SSL_HEADER ${WITH_SSL}/include/openssl/ssl.h) + IF (WITH_SSL_HEADER) + SET(WITH_SSL_PATH ${WITH_SSL} CACHE PATH "path to custom SSL installation") + ENDIF() + IF(WITH_SSL STREQUAL "bundled") MYSQL_USE_BUNDLED_SSL() - ELSEIF(WITH_SSL STREQUAL "system" OR WITH_SSL STREQUAL "yes") - # Check for system library - SET(OPENSSL_FIND_QUIETLY TRUE) - INCLUDE(FindOpenSSL) - FIND_LIBRARY(CRYPTO_LIBRARY crypto) - MARK_AS_ADVANCED(CRYPTO_LIBRARY) - INCLUDE(CheckSymbolExists) - SET(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR}) - SET(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_LIBRARIES}) - CHECK_SYMBOL_EXISTS(SHA512_DIGEST_LENGTH "openssl/sha.h" - HAVE_SHA512_DIGEST_LENGTH) - CHECK_SYMBOL_EXISTS(ERR_remove_thread_state "openssl/err.h" - HAVE_ERR_remove_thread_state) - SET(CMAKE_REQUIRED_INCLUDES) - SET(CMAKE_REQUIRED_LIBRARIES) - IF(OPENSSL_FOUND AND OPENSSL_VERSION VERSION_LESS "1.1.0" AND - CRYPTO_LIBRARY AND HAVE_SHA512_DIGEST_LENGTH) + # Reset some variables, in case we switch from /path/to/ssl to "bundled". + IF (WITH_SSL_PATH) + UNSET(WITH_SSL_PATH) + UNSET(WITH_SSL_PATH CACHE) + ENDIF() + IF (OPENSSL_ROOT_DIR) + UNSET(OPENSSL_ROOT_DIR) + UNSET(OPENSSL_ROOT_DIR CACHE) + ENDIF() + IF (OPENSSL_INCLUDE_DIR) + UNSET(OPENSSL_INCLUDE_DIR) + UNSET(OPENSSL_INCLUDE_DIR CACHE) + ENDIF() + IF (WIN32 AND OPENSSL_APPLINK_C) + UNSET(OPENSSL_APPLINK_C) + UNSET(OPENSSL_APPLINK_C CACHE) + ENDIF() + IF (OPENSSL_LIBRARIES) + UNSET(OPENSSL_LIBRARIES) + UNSET(OPENSSL_LIBRARIES CACHE) + ENDIF() + ELSEIF(WITH_SSL STREQUAL "system" OR + WITH_SSL STREQUAL "yes" OR + WITH_SSL_PATH + ) + # First search in WITH_SSL_PATH. + FIND_PATH(OPENSSL_ROOT_DIR + NAMES include/openssl/ssl.h + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH + HINTS ${WITH_SSL_PATH} + ) + # Then search in standard places (if not found above). + FIND_PATH(OPENSSL_ROOT_DIR + NAMES include/openssl/ssl.h + ) + + FIND_PATH(OPENSSL_INCLUDE_DIR + NAMES openssl/ssl.h + HINTS ${OPENSSL_ROOT_DIR}/include + ) + + IF (WIN32) + FIND_FILE(OPENSSL_APPLINK_C + NAMES openssl/applink.c + HINTS ${OPENSSL_ROOT_DIR}/include + ) + MESSAGE(STATUS "OPENSSL_APPLINK_C ${OPENSSL_APPLINK_C}") + ENDIF() + + # On mac this list is <.dylib;.so;.a> + # We prefer static libraries, so we revert it here. + 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) + IF (WITH_SSL_PATH) + LIST(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES) + ENDIF() + + IF(OPENSSL_INCLUDE_DIR AND + OPENSSL_LIBRARIES AND + CRYPTO_LIBRARY + ) + # 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].*" + ) + STRING(REGEX REPLACE + "^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9][0-9][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 OPENSSL_MAJOR_VERSION STRLESS "101" 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}") + + SET(SSL_SOURCES "") SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES} ${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}) + ENDIF() + MESSAGE(STATUS "SSL_LIBRARIES = ${SSL_LIBRARIES}") SET(SSL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR}) SET(SSL_INTERNAL_INCLUDE_DIRS "") SET(SSL_DEFINES "-DHAVE_OPENSSL") - CHANGE_SSL_SETTINGS("system") + + SET(CMAKE_REQUIRED_LIBRARIES ${SSL_LIBRARIES}) + CHECK_SYMBOL_EXISTS(ERR_remove_thread_state "openssl/err.h" + HAVE_ERR_remove_thread_state) ELSE() IF(WITH_SSL STREQUAL "system") MESSAGE(SEND_ERROR "Cannot find appropriate system libraries for SSL. Use WITH_SSL=bundled to enable SSL support") ENDIF() MYSQL_USE_BUNDLED_SSL() ENDIF() - ELSEIF(NOT WITH_SSL STREQUAL "no") - MESSAGE(SEND_ERROR "Wrong option for WITH_SSL. Valid values are : yes, no, bundled") + ELSE() + MESSAGE(SEND_ERROR + "Wrong option for WITH_SSL. Valid values are: ${WITH_SSL_DOC}") + ENDIF() +ENDMACRO() + + +# Many executables will depend on libeay32.dll and ssleay32.dll at runtime. +# In order to ensure we find the right version(s), we copy them into +# the same directory as the executables. +# NOTE: Using dlls will likely crash in malloc/free, +# see INSTALL.W32 which comes with the openssl sources. +# So we should be linking static versions of the libraries. +MACRO (COPY_OPENSSL_DLLS target_name) + IF (WIN32 AND WITH_SSL_PATH) + GET_FILENAME_COMPONENT(CRYPTO_NAME "${CRYPTO_LIBRARY}" NAME_WE) + GET_FILENAME_COMPONENT(OPENSSL_NAME "${OPENSSL_LIBRARIES}" NAME_WE) + FILE(GLOB HAVE_CRYPTO_DLL "${WITH_SSL_PATH}/bin/${CRYPTO_NAME}.dll") + FILE(GLOB HAVE_OPENSSL_DLL "${WITH_SSL_PATH}/bin/${OPENSSL_NAME}.dll") + IF (HAVE_CRYPTO_DLL AND HAVE_OPENSSL_DLL) + ADD_CUSTOM_COMMAND(OUTPUT ${target_name} + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${WITH_SSL_PATH}/bin/${CRYPTO_NAME}.dll" + "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${CRYPTO_NAME}.dll" + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${WITH_SSL_PATH}/bin/${OPENSSL_NAME}.dll" + "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${OPENSSL_NAME}.dll" + ) + ADD_CUSTOM_TARGET(${target_name} ALL) + ENDIF() ENDIF() ENDMACRO() diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake index bfb2b70be74..e269c473f36 100644 --- a/cmake/zlib.cmake +++ b/cmake/zlib.cmake @@ -37,7 +37,6 @@ MACRO (MYSQL_CHECK_ZLIB_WITH_COMPRESS) IF(WITH_ZLIB STREQUAL "bundled") MYSQL_USE_BUNDLED_ZLIB() ELSE() - SET(ZLIB_FIND_QUIETLY TRUE) INCLUDE(FindZLIB) IF(ZLIB_FOUND) INCLUDE(CheckFunctionExists) @@ -47,7 +46,6 @@ MACRO (MYSQL_CHECK_ZLIB_WITH_COMPRESS) CHECK_FUNCTION_EXISTS(deflateBound HAVE_DEFLATEBOUND) SET(CMAKE_REQUIRED_LIBRARIES) IF(HAVE_CRC32 AND HAVE_COMPRESSBOUND AND HAVE_DEFLATEBOUND) - SET(ZLIB_LIBRARY z CACHE INTERNAL "System zlib library") SET(WITH_ZLIB "system" CACHE STRING "Which zlib to use (possible values are 'bundled' or 'system')") SET(ZLIB_SOURCES "") |