1# Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved. 2# 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation; version 2 of the License. 6# 7# This program is distributed in the hope that it will be useful, 8# but WITHOUT ANY WARRANTY; without even the implied warranty of 9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10# GNU General Public License for more details. 11# 12# You should have received a copy of the GNU General Public License 13# along with this program; if not, write to the Free Software 14# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 15 16SET(WITH_SSL_DOC "bundled (use yassl)") 17SET(WITH_SSL_DOC 18 "${WITH_SSL_DOC}, yes (prefer os library if present, otherwise use bundled)") 19SET(WITH_SSL_DOC 20 "${WITH_SSL_DOC}, system (use os library)") 21 22MACRO (CHANGE_SSL_SETTINGS string) 23 SET(WITH_SSL ${string} CACHE STRING ${WITH_SSL_DOC} FORCE) 24ENDMACRO() 25 26MACRO (MYSQL_USE_BUNDLED_SSL) 27 SET(INC_DIRS 28 ${CMAKE_SOURCE_DIR}/extra/yassl/include 29 ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/include 30 ) 31 SET(SSL_LIBRARIES yassl taocrypt) 32 SET(SSL_INCLUDE_DIRS ${INC_DIRS}) 33 SET(SSL_INTERNAL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL) 34 SET(SSL_DEFINES "-DHAVE_YASSL -DYASSL_PURE_C -DYASSL_PREFIX -DHAVE_OPENSSL -DMULTI_THREADED") 35 CHANGE_SSL_SETTINGS("bundled") 36 #Remove -fno-implicit-templates 37 #(yassl sources cannot be compiled with it) 38 SET(SAVE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) 39 IF(CMAKE_CXX_FLAGS) 40 STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS 41 ${CMAKE_CXX_FLAGS}) 42 ENDIF() 43 ADD_SUBDIRECTORY(extra/yassl) 44 ADD_SUBDIRECTORY(extra/yassl/taocrypt) 45 SET(CMAKE_CXX_FLAGS ${SAVE_CXX_FLAGS}) 46 GET_TARGET_PROPERTY(src yassl SOURCES) 47 FOREACH(file ${src}) 48 SET(SSL_SOURCES ${SSL_SOURCES} ${CMAKE_SOURCE_DIR}/extra/yassl/${file}) 49 ENDFOREACH() 50 GET_TARGET_PROPERTY(src taocrypt SOURCES) 51 FOREACH(file ${src}) 52 SET(SSL_SOURCES ${SSL_SOURCES} ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/${file}) 53 ENDFOREACH() 54ENDMACRO() 55 56# MYSQL_CHECK_SSL 57# 58# Provides the following configure options: 59# WITH_SSL=[bundled|yes|system] 60MACRO (MYSQL_CHECK_SSL) 61 IF(NOT WITH_SSL) 62 CHANGE_SSL_SETTINGS("bundled") 63 MESSAGE(STATUS "Found WITH_SSL set to no. " 64 "Changing it to bundled") 65 ENDIF() 66 67 IF(WITH_SSL STREQUAL "bundled") 68 MYSQL_USE_BUNDLED_SSL() 69 ELSEIF(WITH_SSL STREQUAL "system" OR WITH_SSL STREQUAL "yes") 70 # Check for system library 71 SET(OPENSSL_FIND_QUIETLY TRUE) 72 INCLUDE(FindOpenSSL) 73 FIND_LIBRARY(CRYPTO_LIBRARY crypto) 74 MARK_AS_ADVANCED(CRYPTO_LIBRARY) 75 INCLUDE(CheckSymbolExists) 76 CHECK_SYMBOL_EXISTS(SHA512_DIGEST_LENGTH "openssl/sha.h" 77 HAVE_SHA512_DIGEST_LENGTH) 78 IF(OPENSSL_FOUND AND CRYPTO_LIBRARY AND HAVE_SHA512_DIGEST_LENGTH) 79 SET(SSL_SOURCES "") 80 SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES} ${CRYPTO_LIBRARY}) 81 SET(SSL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR}) 82 SET(SSL_INTERNAL_INCLUDE_DIRS "") 83 SET(SSL_DEFINES "-DHAVE_OPENSSL") 84 CHANGE_SSL_SETTINGS("system") 85 ELSE() 86 IF(WITH_SSL STREQUAL "system") 87 MESSAGE(SEND_ERROR "Cannot find appropriate system libraries for SSL. Use WITH_SSL=bundled to enable SSL support") 88 ENDIF() 89 MYSQL_USE_BUNDLED_SSL() 90 ENDIF() 91 ELSE() 92 MESSAGE(SEND_ERROR "Wrong option for WITH_SSL. " 93 "Valid options are : ${WITH_SSL_DOC}") 94 ENDIF() 95ENDMACRO() 96