diff options
author | Michael Widenius <monty@askmonty.org> | 2013-03-26 00:03:13 +0200 |
---|---|---|
committer | Michael Widenius <monty@askmonty.org> | 2013-03-26 00:03:13 +0200 |
commit | 068c61978e3a81836d52b8caf11e044290159ad1 (patch) | |
tree | 2cbca861ab2cebe3bd99379ca9668bb483ca0d2a /cmake | |
parent | 35bc8f9f4353b64da215e52ff6f1612a8ce66f43 (diff) | |
download | mariadb-git-068c61978e3a81836d52b8caf11e044290159ad1.tar.gz |
Temporary commit of 10.0-merge
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/configure.pl | 20 | ||||
-rw-r--r-- | cmake/cpu_info.cmake | 30 | ||||
-rw-r--r-- | cmake/libevent.cmake | 89 | ||||
-rw-r--r-- | cmake/libutils.cmake | 8 | ||||
-rw-r--r-- | cmake/ssl.cmake | 198 |
5 files changed, 314 insertions, 31 deletions
diff --git a/cmake/configure.pl b/cmake/configure.pl index 51e83c2815c..d8e09a1bad9 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/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/libevent.cmake b/cmake/libevent.cmake new file mode 100644 index 00000000000..54498e1bb15 --- /dev/null +++ b/cmake/libevent.cmake @@ -0,0 +1,89 @@ +# Copyright (C) 2011 Oracle and/or its affiliates. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +MACRO (MYSQL_USE_BUNDLED_LIBEVENT) + SET(LIBEVENT_LIBRARY event) + SET(LIBEVENT_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/libevent) + SET(LIBEVENT_FOUND TRUE) + SET(WITH_LIBEVENT "bundled" CACHE STRING "Use bundled libevent") + ADD_SUBDIRECTORY(libevent) + GET_TARGET_PROPERTY(src libevent SOURCES) + FOREACH(file ${src}) + SET(LIBEVENT_SOURCES ${LIBEVENT_SOURCES} ${CMAKE_SOURCE_DIR}/libevent/${file}) + ENDFOREACH() +ENDMACRO() + +# MYSQL_CHECK_LIBEVENT +# +# Provides the following configure options: +# WITH_LIBEVENT_BUNDLED +# If this is set,we use bindled libevent +# If this is not set,search for system libevent. +# if system libevent is not found, use bundled copy +# LIBEVENT_LIBRARIES, LIBEVENT_INCLUDE_DIR and LIBEVENT_SOURCES +# are set after this macro has run + +MACRO (MYSQL_CHECK_LIBEVENT) + + IF (NOT WITH_LIBEVENT) + SET(WITH_LIBEVENT "bundled" CACHE STRING "By default use bundled libevent on this platform") + ENDIF() + + IF(WITH_LIBEVENT STREQUAL "bundled") + MYSQL_USE_BUNDLED_LIBEVENT() + ELSEIF(WITH_LIBEVENT STREQUAL "system" OR WITH_LIBEVENT STREQUAL "yes") + SET(LIBEVENT_FIND_QUIETLY TRUE) + + IF (NOT LIBEVENT_INCLUDE_PATH) + set(LIBEVENT_INCLUDE_PATH /usr/local/include /opt/local/include) + ENDIF() + + find_path(LIBEVENT_INCLUDE_DIR event.h PATHS ${LIBEVENT_INCLUDE_PATH}) + + if (NOT LIBEVENT_INCLUDE_DIR) + MESSAGE(SEND_ERROR "Cannot find appropriate event.h in /usr/local/include or /opt/local/include. Use bundled libevent") + endif() + + IF (NOT LIBEVENT_LIB_PATHS) + set(LIBEVENT_LIB_PATHS /usr/local/lib /opt/local/lib) + ENDIF() + + find_library(LIBEVENT_LIB event PATHS ${LIBEVENT_LIB_PATHS}) + + if (NOT LIBEVENT_LIB) + MESSAGE(SEND_ERROR "Cannot find appropriate event lib in /usr/local/lib or /opt/local/lib. Use bundled libevent") + endif() + + IF (LIBEVENT_LIB AND LIBEVENT_INCLUDE_DIR) + set(LIBEVENT_FOUND TRUE) + set(LIBEVENT_LIBS ${LIBEVENT_LIB}) + ELSE() + set(LIBEVENT_FOUND FALSE) + ENDIF() + + IF(LIBEVENT_FOUND) + SET(LIBEVENT_SOURCES "") + SET(LIBEVENT_LIBRARIES ${LIBEVENT_LIBS}) + SET(LIBEVENT_INCLUDE_DIRS ${LIBEVENT_INCLUDE_DIR}) + SET(LIBEVENT_DEFINES "-DHAVE_LIBEVENT") + ELSE() + IF(WITH_LIBEVENT STREQUAL "system") + MESSAGE(SEND_ERROR "Cannot find appropriate system libraries for libevent. Use bundled libevent") + ENDIF() + MYSQL_USE_BUNDLED_LIBEVENT() + ENDIF() + + ENDIF() +ENDMACRO() diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake index 7c13df05ca4..e161b67d25f 100644 --- a/cmake/libutils.cmake +++ b/cmake/libutils.cmake @@ -304,12 +304,15 @@ FUNCTION(GET_DEPENDEND_OS_LIBS target result) SET(${result} ${ret} PARENT_SCOPE) ENDFUNCTION() -MACRO(RESTRICT_SYMBOL_EXPORTS target) +# We try to hide the symbols in yassl/zlib to avoid name clashes with +# other libraries like openssl. +FUNCTION(RESTRICT_SYMBOL_EXPORTS target) SET(VISIBILITY_HIDDEN_FLAG) IF(CMAKE_COMPILER_IS_GNUCXX AND UNIX) CHECK_C_COMPILER_FLAG("-fvisibility=hidden" HAVE_VISIBILITY_HIDDEN) IF(HAVE_VISIBILITY_HIDDEN) + MESSAGE(STATUS "HAVE_VISIBILITY_HIDDEN") SET(VISIBILITY_HIDDEN_FLAG "-fvisibility=hidden") ENDIF() ENDIF() @@ -327,5 +330,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/ssl.cmake b/cmake/ssl.cmake index cabff530b47..a74ebc219e9 100644 --- a/cmake/ssl.cmake +++ b/cmake/ssl.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -13,80 +13,222 @@ # 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") 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") 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) + # 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. + LIST(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES) + 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) + LIST(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES) + + # 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]).*$" "\\1" + OPENSSL_MAJOR_VERSION "${OPENSSL_VERSION_NUMBER}" + ) + + IF(OPENSSL_INCLUDE_DIR AND + OPENSSL_LIBRARIES AND + CRYPTO_LIBRARY AND + OPENSSL_MAJOR_VERSION STREQUAL "1" + ) + SET(OPENSSL_FOUND TRUE) + ELSE() + SET(OPENSSL_FOUND FALSE) + ENDIF() + + 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}") + 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_FOUND AND CRYPTO_LIBRARY AND HAVE_SHA512_DIGEST_LENGTH) + IF(OPENSSL_FOUND AND HAVE_SHA512_DIGEST_LENGTH) 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") 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() |