Add BoringSSL support for CMake.

`FindBoringSSL.cmake` is come from: https://github.com/yandex/odyssey/blob/master/cmake/FindBoringSSL.cmake
This commit is contained in:
Lvv.me 2022-04-27 09:32:27 +08:00
parent f5757aa18d
commit a9d4f5d026
No known key found for this signature in database
GPG Key ID: 8843A4C0FE54B152
2 changed files with 63 additions and 1 deletions

View File

@ -57,7 +57,16 @@ include(GNUInstallDirs)
find_package(PythonInterp)
# Auto-detection of features that can be toggled
find_package(OpenSSL 1.0.1)
if(OPENSSL_IS_BORINGSSL)
find_package(BoringSSL)
set(OPENSSL_FOUND ${BORINGSSL_FOUND})
set(OPENSSL_INCLUDE_DIR ${BORINGSSL_INCLUDE_DIR})
set(OPENSSL_CRYPTO_LIBRARY ${BORINGSSL_CRYPTO_LIBRARY})
set(OPENSSL_SSL_LIBRARY ${BORINGSSL_SSL_LIBRARY})
set(OPENSSL_OPENSSL_LIBRARIES ${BORINGSSL_OPENSSL_LIBRARIES})
else()
find_package(OpenSSL 1.0.1)
endif()
find_package(Libev 4.11)
find_package(Libcares 1.7.5)
find_package(ZLIB 1.2.3)

53
cmake/FindBoringSSL.cmake Normal file
View File

@ -0,0 +1,53 @@
# - Try to find BoringSSL include dirs and libraries
#
# Usage of this module as follows:
#
# find_package(BoringSSL)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# BORINGSSL_ROOT_DIR Set this variable to the root installation of
# boringssl if the module has problems finding the
# proper installation path.
#
# Variables defined by this module:
#
# BORINGSSL_FOUND System has boringssl, include and library dirs found
# BORINGSSL_INCLUDE_DIR The boringssl include directories.
# BORINGSSL_LIBRARIES The boringssl libraries.
# BORINGSSL_CRYPTO_LIBRARY The boringssl crypto library.
# BORINGSSL_SSL_LIBRARY The boringssl ssl library.
find_path(BORINGSSL_ROOT_DIR
NAMES include/openssl/ssl.h include/openssl/base.h include/openssl/hkdf.h
HINTS ${BORINGSSL_ROOT_DIR})
find_path(BORINGSSL_INCLUDE_DIR
NAMES openssl/ssl.h openssl/base.h openssl/hkdf.h
HINTS ${BORINGSSL_ROOT_DIR}/include)
find_library(BORINGSSL_SSL_LIBRARY
NAMES libssl.a
HINTS ${BORINGSSL_ROOT_DIR}/lib)
find_library(BORINGSSL_CRYPTO_LIBRARY
NAMES libcrypto.a
HINTS ${BORINGSSL_ROOT_DIR}/lib)
set(BORINGSSL_LIBRARIES ${BORINGSSL_SSL_LIBRARY} ${BORINGSSL_CRYPTO_LIBRARY}
CACHE STRING "BoringSSL SSL and crypto libraries." FORCE)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(BoringSSL DEFAULT_MSG
BORINGSSL_LIBRARIES
BORINGSSL_INCLUDE_DIR)
mark_as_advanced(
BORINGSSL_ROOT_DIR
BORINGSSL_INCLUDE_DIR
BORINGSSL_LIBRARIES
BORINGSSL_CRYPTO_LIBRARY
BORINGSSL_SSL_LIBRARY
)