Skip to content

Commit

Permalink
If WITH_SSL is specified to cmake, do not bind in a copy of the SSL l…
Browse files Browse the repository at this point in the history
…ibraries

to the MySQL static library as this will produce symbol collisions in anything
consuming the MySQL library and the SSL libraries.

Also fix a build failure in debug builds if WITH_SSL is specified.
  • Loading branch information
ned14 committed May 12, 2022
1 parent c191af2 commit 51c9987
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
11 changes: 10 additions & 1 deletion cmake/libutils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE)

IF(OSLIBS)
LIST(REMOVE_DUPLICATES OSLIBS)
TARGET_LINK_LIBRARIES(${TARGET} ${OSLIBS})
TARGET_LINK_LIBRARIES(${TARGET} PUBLIC ${OSLIBS})
MESSAGE(STATUS "Library ${TARGET} depends on OSLIBS ${OSLIBS}")
ENDIF()

Expand Down Expand Up @@ -255,10 +255,19 @@ MACRO(MERGE_LIBRARIES)
SET(LIBS ${ARG_DEFAULT_ARGS})
LIST(REMOVE_AT LIBS 0)
IF(ARG_STATIC)
IF(WITH_SSL)
list(REMOVE_ITEM LIBS ${SSL_LIBRARIES})
endif()
IF (NOT ARG_OUTPUT_NAME)
SET(ARG_OUTPUT_NAME ${TARGET})
ENDIF()
MERGE_STATIC_LIBS(${TARGET} ${ARG_OUTPUT_NAME} "${LIBS}")
if(WITH_SSL)
target_link_libraries(${TARGET} PUBLIC ${SSL_LIBRARIES})
if(NOT WIN32)
target_link_libraries(${TARGET} PUBLIC pthread)
endif()
endif()
ELSEIF(ARG_SHARED OR ARG_MODULE)
IF(ARG_SHARED)
SET(LIBTYPE SHARED)
Expand Down
5 changes: 3 additions & 2 deletions cmake/ssl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ MACRO (MYSQL_CHECK_SSL)
MESSAGE(STATUS "suffixes <${CMAKE_FIND_LIBRARY_SUFFIXES}>")
ENDIF()
FIND_LIBRARY(OPENSSL_LIBRARY
NAMES ssl ssleay32 ssleay32MD
NAMES ssl ssleay32 ssleay32MD libssl
HINTS ${OPENSSL_ROOT_DIR}/lib)
FIND_LIBRARY(CRYPTO_LIBRARY
NAMES crypto libeay32
NAMES crypto libeay32 libcrypto
HINTS ${OPENSSL_ROOT_DIR}/lib)
IF (WITH_SSL_PATH)
LIST(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES)
Expand Down Expand Up @@ -207,6 +207,7 @@ MACRO (MYSQL_CHECK_SSL)
ENDIF()
ENDIF()

MESSAGE(STATUS "OPENSSL_ROOT_DIR = ${OPENSSL_ROOT_DIR}")
MESSAGE(STATUS "OPENSSL_INCLUDE_DIR = ${OPENSSL_INCLUDE_DIR}")
MESSAGE(STATUS "OPENSSL_LIBRARY = ${OPENSSL_LIBRARY}")
MESSAGE(STATUS "CRYPTO_LIBRARY = ${CRYPTO_LIBRARY}")
Expand Down
2 changes: 1 addition & 1 deletion vio/viossl.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ static int ssl_do(struct st_VioSSLFd *ptr, Vio *vio, long timeout,
sk_SSL_COMP_zero(SSL_COMP_get_compression_methods());
#endif

#if !defined(HAVE_YASSL) && !defined(DBUG_OFF)
#if 0 // !defined(HAVE_YASSL) && !defined(DBUG_OFF)
{
STACK_OF(SSL_COMP) *ssl_comp_methods = NULL;
ssl_comp_methods = SSL_COMP_get_compression_methods();
Expand Down

0 comments on commit 51c9987

Please sign in to comment.