Skip to content

Commit

Permalink
MDEV-33519 Remove WITH_SSL=<custom_location_of_openssl> option
Browse files Browse the repository at this point in the history
This commit removes the WITH_SSL=<custom_location_of_openssl> option,
leaving only -DWITH_SSL=bundled/system.

The rationale behind this removal is as follows:

1. The WITH_SSL=<custom_location_of_openssl> option is obscure
and not widely used.

2. There is no added value in this option compared to using
OPENSSL_ROOT_DIR. In fact, the availability of "helpful" MySQL options
might discourage users from exploring proper CMake options independently.

3. Users may incorrectly assume full MySQL compatibility even with this
option, including undocumented behaviors such as MySQL's preference for static libraries
with WITH_SSL=<custom_location_of_openssl>.

This change simplifies the configuration options and encourages users to
adopt more standardized and documented practices.
  • Loading branch information
vaintroub committed Mar 18, 2024
1 parent 1e889a6 commit 14ec153
Showing 1 changed file with 6 additions and 29 deletions.
35 changes: 6 additions & 29 deletions cmake/ssl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ 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 ${WITH_SSL_DOC} FORCE)
Expand Down Expand Up @@ -78,19 +76,9 @@ MACRO (MYSQL_CHECK_SSL)
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()
# 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)
Expand All @@ -108,28 +96,14 @@ MACRO (MYSQL_CHECK_SSL)
UNSET(OPENSSL_SSL_LIBRARY CACHE)
ENDIF()
ELSEIF(WITH_SSL STREQUAL "system" OR
WITH_SSL STREQUAL "yes" OR
WITH_SSL_PATH
WITH_SSL STREQUAL "yes"
)
IF(NOT OPENSSL_ROOT_DIR)
IF(WITH_SSL_PATH)
# workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/22945
SET(OPENSSL_ROOT_DIR ${WITH_SSL_PATH} ${WITH_SSL_PATH}/lib64)
ENDIF()
ENDIF()
FIND_PACKAGE(OpenSSL)
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} ${CMAKE_DL_LIBS})
ENDIF()
SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES})

MESSAGE_ONCE(OPENSSL_INCLUDE_DIR "OPENSSL_INCLUDE_DIR = ${OPENSSL_INCLUDE_DIR}")
MESSAGE_ONCE(OPENSSL_SSL_LIBRARY "OPENSSL_SSL_LIBRARY = ${OPENSSL_SSL_LIBRARY}")
Expand All @@ -150,6 +124,7 @@ MACRO (MYSQL_CHECK_SSL)
SET(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
SET(CMAKE_REQUIRED_LIBRARIES ${SSL_LIBRARIES})
SET(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
INCLUDE(CheckSymbolExists)
CHECK_SYMBOL_EXISTS(ERR_remove_thread_state "openssl/err.h"
HAVE_ERR_remove_thread_state)
CHECK_SYMBOL_EXISTS(EVP_aes_128_ctr "openssl/evp.h"
Expand All @@ -169,7 +144,9 @@ MACRO (MYSQL_CHECK_SSL)
ENDIF()
ELSE()
MESSAGE(FATAL_ERROR
"Wrong option for WITH_SSL. Valid values are: ${WITH_SSL_DOC}")
"Wrong option for WITH_SSL. Valid values are: ${WITH_SSL_DOC}."
"For custom location of OpenSSL library, use WITH_SSL=system and OPENSSL_ROOT_DIR pointing to the library."
)
ENDIF()
ENDMACRO()

Expand Down

0 comments on commit 14ec153

Please sign in to comment.