diff options
author | Michael Ford <fanquake@gmail.com> | 2023-03-05 23:58:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-05 16:58:22 +0100 |
commit | 185e2f009bbffff9bfa2f4d633ddbea777ab111b (patch) | |
tree | d55d6a4e8d5edf44e3dca37f17c0d2c83530ac37 | |
parent | 4e6375e84c5215c4f67b1698fc9cd666a5163525 (diff) | |
download | libevent-185e2f009bbffff9bfa2f4d633ddbea777ab111b.tar.gz |
build: improve mbedtls searching on macOS with brew for cmake (#1419)
This just copies the same logic used to find OpenSSL on macOS using homebrew, for finding mbedtls via brew. Without it, the build will fail out the box with a brew installed mbedtls.
-rw-r--r-- | CMakeLists.txt | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 18bab88a..721eb9b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -955,6 +955,20 @@ if (NOT EVENT__DISABLE_OPENSSL) endif() if (NOT EVENT__DISABLE_MBEDTLS) + # only if MBEDTLS_ROOT_DIR is not set yet + if (BREW AND NOT MBEDTLS_ROOT_DIR AND NOT "$ENV{MBEDTLS_ROOT_DIR}") + execute_process(COMMAND ${BREW} --prefix mbedtls + OUTPUT_VARIABLE BREW_MBEDTLS_PREFIX + RESULT_VARIABLE BREW_MBEDTLS_RESULT + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if (BREW_MBEDTLS_RESULT EQUAL 0) + message(STATUS "Set MBEDTLS_ROOT_DIR=${BREW_MBEDTLS_PREFIX} (from brew)") + set(MBEDTLS_ROOT_DIR "${BREW_MBEDTLS_PREFIX}" CACHE PATH "") + endif() + endif() + find_package(MbedTLS REQUIRED) set(EVENT__HAVE_MBEDTLS 1) |