mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
Merge branch 'macos-brew-openssl-v2'
By Azat Khuzhin (2) and fanquake (1) * macos-brew-openssl-v2: Add autodetection of openssl via brew into build matrix cmake: find openssl prefix via brew autotools: attempt to find OpenSSL via homebrew on macOS Closes: #1050 (cherry picked one patch from it)
This commit is contained in:
commit
4f8a6320ca
12
.github/workflows/macos.yml
vendored
12
.github/workflows/macos.yml
vendored
@ -36,6 +36,7 @@ jobs:
|
|||||||
- TEST_EXPORT_STATIC
|
- TEST_EXPORT_STATIC
|
||||||
- TEST_EXPORT_SHARED
|
- TEST_EXPORT_SHARED
|
||||||
- OPENSSL_1_1
|
- OPENSSL_1_1
|
||||||
|
- BREW_AUTODETECT_OPENSSL
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2.0.0
|
- uses: actions/checkout@v2.0.0
|
||||||
@ -52,7 +53,10 @@ jobs:
|
|||||||
- name: Build And Test
|
- name: Build And Test
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ matrix.EVENT_MATRIX }}" == "OPENSSL_1_1" ]; then
|
if [ "${{ matrix.EVENT_MATRIX }}" == "BREW_AUTODETECT_OPENSSL" ]; then
|
||||||
|
# use autodetection via brew
|
||||||
|
:
|
||||||
|
elif [ "${{ matrix.EVENT_MATRIX }}" == "OPENSSL_1_1" ]; then
|
||||||
export OPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1
|
export OPENSSL_ROOT_DIR=/usr/local/opt/openssl@1.1
|
||||||
else
|
else
|
||||||
export OPENSSL_ROOT_DIR=/usr/local/opt/openssl
|
export OPENSSL_ROOT_DIR=/usr/local/opt/openssl
|
||||||
@ -121,6 +125,7 @@ jobs:
|
|||||||
- DISABLE_DEBUG_MODE
|
- DISABLE_DEBUG_MODE
|
||||||
- DISABLE_MM_REPLACEMENT
|
- DISABLE_MM_REPLACEMENT
|
||||||
- OPENSSL_1_1
|
- OPENSSL_1_1
|
||||||
|
- BREW_AUTODETECT_OPENSSL
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2.0.0
|
- uses: actions/checkout@v2.0.0
|
||||||
@ -137,7 +142,10 @@ jobs:
|
|||||||
- name: Build And Test
|
- name: Build And Test
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
if [ "${{ matrix.EVENT_MATRIX }}" == "OPENSSL_1_1" ]; then
|
if [ "${{ matrix.EVENT_MATRIX }}" == "BREW_AUTODETECT_OPENSSL" ]; then
|
||||||
|
# use autodetection via brew
|
||||||
|
:
|
||||||
|
elif [ "${{ matrix.EVENT_MATRIX }}" == "OPENSSL_1_1" ]; then
|
||||||
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig:$PKG_CONFIG_PATH"
|
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||||
else
|
else
|
||||||
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig:$PKG_CONFIG_PATH"
|
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig:$PKG_CONFIG_PATH"
|
||||||
|
@ -238,6 +238,11 @@ else()
|
|||||||
message(FATAL_ERROR "${EVENT_LIBRARY_TYPE} is not supported")
|
message(FATAL_ERROR "${EVENT_LIBRARY_TYPE} is not supported")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# brew support
|
||||||
|
if (APPLE)
|
||||||
|
find_program(BREW brew)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (${MSVC})
|
if (${MSVC})
|
||||||
set(msvc_static_runtime OFF)
|
set(msvc_static_runtime OFF)
|
||||||
if ("${EVENT_LIBRARY_TYPE}" STREQUAL "STATIC")
|
if ("${EVENT_LIBRARY_TYPE}" STREQUAL "STATIC")
|
||||||
@ -881,6 +886,20 @@ if(EVENT__HAVE_EVENT_PORTS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (NOT EVENT__DISABLE_OPENSSL)
|
if (NOT EVENT__DISABLE_OPENSSL)
|
||||||
|
# only if OPENSSL_ROOT_DIR is not set yet
|
||||||
|
if (BREW AND NOT OPENSSL_ROOT_DIR AND NOT "$ENV{OPENSSL_ROOT_DIR}")
|
||||||
|
execute_process(COMMAND ${BREW} --prefix openssl
|
||||||
|
OUTPUT_VARIABLE BREW_OPENSSL_PREFIX
|
||||||
|
RESULT_VARIABLE BREW_OPENSSL_RESULT
|
||||||
|
ERROR_QUIET
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
if (BREW_OPENSSL_RESULT EQUAL 0)
|
||||||
|
message(STATUS "Set OPENSSL_ROOT_DIR=${BREW_OPENSSL_PREFIX} (from brew)")
|
||||||
|
set(OPENSSL_ROOT_DIR "${BREW_OPENSSL_PREFIX}" CACHE PATH "")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(OpenSSL REQUIRED)
|
find_package(OpenSSL REQUIRED)
|
||||||
|
|
||||||
set(EVENT__HAVE_OPENSSL 1)
|
set(EVENT__HAVE_OPENSSL 1)
|
||||||
|
@ -3,6 +3,33 @@ dnl OpenSSL support
|
|||||||
AC_DEFUN([LIBEVENT_OPENSSL], [
|
AC_DEFUN([LIBEVENT_OPENSSL], [
|
||||||
AC_REQUIRE([NTP_PKG_CONFIG])dnl
|
AC_REQUIRE([NTP_PKG_CONFIG])dnl
|
||||||
|
|
||||||
|
case "$host_os" in
|
||||||
|
darwin*)
|
||||||
|
dnl when compiling for Darwin, attempt to find OpenSSL using brew.
|
||||||
|
dnl We append the location given by brew to PKG_CONFIG_PATH path
|
||||||
|
dnl and then export it, so that it can be used in detection below.
|
||||||
|
AC_CHECK_PROG([BREW],brew, brew)
|
||||||
|
if test x$BREW = xbrew; then
|
||||||
|
openssl_prefix=$($BREW --prefix openssl 2>/dev/null)
|
||||||
|
if test x$openssl_prefix != x; then
|
||||||
|
OPENSSL_LIBS=`$PKG_CONFIG --libs openssl 2>/dev/null`
|
||||||
|
case "$OPENSSL_LIBS" in
|
||||||
|
dnl only if openssl is not in PKG_CONFIG_PATH already
|
||||||
|
'')
|
||||||
|
if test x$PKG_CONFIG_PATH != x; then
|
||||||
|
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:"
|
||||||
|
fi
|
||||||
|
OPENSSL_PKG_CONFIG="$openssl_prefix/lib/pkgconfig"
|
||||||
|
PKG_CONFIG_PATH="$PKG_CONFIG_PATH$OPENSSL_PKG_CONFIG"
|
||||||
|
export PKG_CONFIG_PATH
|
||||||
|
AC_MSG_NOTICE([PKG_CONFIG_PATH has been set to $PKG_CONFIG_PATH (added openssl from brew)])
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
case "$enable_openssl" in
|
case "$enable_openssl" in
|
||||||
yes)
|
yes)
|
||||||
have_openssl=no
|
have_openssl=no
|
||||||
@ -27,7 +54,7 @@ case "$enable_openssl" in
|
|||||||
LIBS=""
|
LIBS=""
|
||||||
OPENSSL_LIBS=""
|
OPENSSL_LIBS=""
|
||||||
for lib in crypto eay32; do
|
for lib in crypto eay32; do
|
||||||
# clear cache
|
dnl clear cache
|
||||||
unset ac_cv_search_SSL_new
|
unset ac_cv_search_SSL_new
|
||||||
AC_SEARCH_LIBS([SSL_new], [ssl ssl32],
|
AC_SEARCH_LIBS([SSL_new], [ssl ssl32],
|
||||||
[have_openssl=yes
|
[have_openssl=yes
|
||||||
@ -47,15 +74,15 @@ case "$enable_openssl" in
|
|||||||
AC_SUBST(OPENSSL_LIBS)
|
AC_SUBST(OPENSSL_LIBS)
|
||||||
case "$have_openssl" in
|
case "$have_openssl" in
|
||||||
yes) AC_DEFINE(HAVE_OPENSSL, 1, [Define if the system has openssl]) ;;
|
yes) AC_DEFINE(HAVE_OPENSSL, 1, [Define if the system has openssl]) ;;
|
||||||
*) AC_MSG_ERROR([openssl is a must but can not be found. You should add the \
|
*) AC_MSG_ERROR([OpenSSL could not be found. You should add the directory \
|
||||||
directory containing `openssl.pc' to the `PKG_CONFIG_PATH' environment variable, \
|
containing 'openssl.pc' to the 'PKG_CONFIG_PATH' environment variable, set \
|
||||||
or set `CFLAGS' and `LDFLAGS' directly for openssl, or use `--disable-openssl' \
|
'CFLAGS' and 'LDFLAGS' directly, or use '--disable-openssl' to disable \
|
||||||
to disable support for openssl encryption])
|
support for OpenSSL encryption])
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# check if we have and should use openssl
|
dnl check if we have and should use OpenSSL
|
||||||
AM_CONDITIONAL(OPENSSL, [test "$enable_openssl" != "no" && test "$have_openssl" = "yes"])
|
AM_CONDITIONAL(OPENSSL, [test "$enable_openssl" != "no" && test "$have_openssl" = "yes"])
|
||||||
])
|
])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user