From 185e2f009bbffff9bfa2f4d633ddbea777ab111b Mon Sep 17 00:00:00 2001 From: Michael Ford Date: Sun, 5 Mar 2023 23:58:22 +0800 Subject: 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. --- CMakeLists.txt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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) -- cgit v1.2.1