Skip to content

Commit e88f6f4

Browse files
committed
MDEV-12125 Use FIND_PACKAGE(OpenSSL) to find openssl
1 parent 29a980c commit e88f6f4

File tree

1 file changed

+12
-58
lines changed

1 file changed

+12
-58
lines changed

cmake/ssl.cmake

Lines changed: 12 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -119,55 +119,19 @@ MACRO (MYSQL_CHECK_SSL)
119119
WITH_SSL STREQUAL "yes" OR
120120
WITH_SSL_PATH
121121
)
122-
# First search in WITH_SSL_PATH.
123-
FIND_PATH(OPENSSL_ROOT_DIR
124-
NAMES include/openssl/ssl.h
125-
NO_CMAKE_PATH
126-
NO_CMAKE_ENVIRONMENT_PATH
127-
HINTS ${WITH_SSL_PATH}
128-
)
129-
# Then search in standard places (if not found above).
130-
FIND_PATH(OPENSSL_ROOT_DIR
131-
NAMES include/openssl/ssl.h
132-
)
133-
134-
FIND_PATH(OPENSSL_INCLUDE_DIR
135-
NAMES openssl/ssl.h
136-
HINTS ${OPENSSL_ROOT_DIR}/include
137-
)
138-
139-
IF (WIN32)
140-
FIND_FILE(OPENSSL_APPLINK_C
141-
NAMES openssl/applink.c
142-
HINTS ${OPENSSL_ROOT_DIR}/include
143-
)
144-
MESSAGE_ONCE(OPENSSL_APPLINK_C "OPENSSL_APPLINK_C ${OPENSSL_APPLINK_C}")
145-
ENDIF()
146-
147-
# On mac this list is <.dylib;.so;.a>
148-
# We prefer static libraries, so we revert it here.
149-
IF (WITH_SSL_PATH)
150-
LIST(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES)
151-
ENDIF()
152-
FIND_LIBRARY(OPENSSL_SSL_LIBRARY
153-
NAMES ssl ssleay32 ssleay32MD
154-
HINTS ${OPENSSL_ROOT_DIR}/lib)
155-
FIND_LIBRARY(OPENSSL_CRYPTO_LIBRARY
156-
NAMES crypto libeay32
157-
HINTS ${OPENSSL_ROOT_DIR}/lib)
158-
MARK_AS_ADVANCED(OPENSSL_CRYPTO_LIBRARY OPENSSL_SSL_LIBRARY OPENSSL_ROOT_DIR
159-
OPENSSL_INCLUDE_DIR)
160-
IF (WITH_SSL_PATH)
161-
LIST(REVERSE CMAKE_FIND_LIBRARY_SUFFIXES)
122+
IF(NOT OPENSSL_ROOT_DIR)
123+
IF(WITH_SSL_PATH)
124+
SET(OPENSSL_ROOT_DIR ${WITH_SSL_PATH})
125+
ENDIF()
162126
ENDIF()
163-
164-
INCLUDE(CheckSymbolExists)
165-
SET(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
166-
CHECK_SYMBOL_EXISTS(SHA512_DIGEST_LENGTH "openssl/sha.h"
167-
HAVE_SHA512_DIGEST_LENGTH)
168-
SET(CMAKE_REQUIRED_INCLUDES)
169-
IF(OPENSSL_INCLUDE_DIR AND OPENSSL_SSL_LIBRARY AND
170-
OPENSSL_CRYPTO_LIBRARY AND HAVE_SHA512_DIGEST_LENGTH)
127+
FIND_PACKAGE(OpenSSL)
128+
IF(OPENSSL_FOUND)
129+
SET(OPENSSL_LIBRARY ${OPENSSL_SSL_LIBRARY})
130+
INCLUDE(CheckSymbolExists)
131+
SET(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
132+
CHECK_SYMBOL_EXISTS(SHA512_DIGEST_LENGTH "openssl/sha.h"
133+
HAVE_SHA512_DIGEST_LENGTH)
134+
SET(CMAKE_REQUIRED_INCLUDES)
171135
SET(SSL_SOURCES "")
172136
SET(SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY})
173137
IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
@@ -177,16 +141,6 @@ MACRO (MYSQL_CHECK_SSL)
177141
SET(SSL_LIBRARIES ${SSL_LIBRARIES} ${LIBDL})
178142
ENDIF()
179143

180-
# Verify version number. Version information looks like:
181-
# #define OPENSSL_VERSION_NUMBER 0x1000103fL
182-
# Encoded as MNNFFPPS: major minor fix patch status
183-
FILE(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h"
184-
OPENSSL_VERSION_TEXT
185-
REGEX "^# *define[\t ]+OPENSSL_VERSION_TEXT[\t ]+")
186-
STRING(REGEX REPLACE
187-
"^.*OPENSSL_VERSION_TEXT[\t ]+\"OpenSSL ([-0-9a-z.]+).*$" "\\1"
188-
OPENSSL_VERSION "${OPENSSL_VERSION_TEXT}")
189-
190144
MESSAGE_ONCE(OPENSSL_INCLUDE_DIR "OPENSSL_INCLUDE_DIR = ${OPENSSL_INCLUDE_DIR}")
191145
MESSAGE_ONCE(OPENSSL_SSL_LIBRARY "OPENSSL_SSL_LIBRARY = ${OPENSSL_SSL_LIBRARY}")
192146
MESSAGE_ONCE(OPENSSL_CRYPTO_LIBRARY "OPENSSL_CRYPTO_LIBRARY = ${OPENSSL_CRYPTO_LIBRARY}")

0 commit comments

Comments
 (0)