Skip to content

Instantly share code, notes, and snippets.

@sighingnow
Created October 9, 2021 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sighingnow/e158d713b4b6aa189d35bb87519c5de4 to your computer and use it in GitHub Desktop.
Save sighingnow/e158d713b4b6aa189d35bb87519c5de4 to your computer and use it in GitHub Desktop.
CMake: find brew-installed openssl on Mac
macro(find_openssl_libraries)
if (APPLE)
# If we're on OS X check for Homebrew's copy of OpenSSL instead of Apple's
if (NOT OpenSSL_DIR)
find_program(HOMEBREW brew)
if (HOMEBREW STREQUAL "HOMEBREW-NOTFOUND")
message(WARNING "Homebrew not found: not using Homebrew's OpenSSL")
if (NOT OPENSSL_ROOT_DIR)
message(WARNING "Use -DOPENSSL_ROOT_DIR for non-Apple OpenSSL")
endif()
else()
execute_process(COMMAND brew --prefix openssl
OUTPUT_VARIABLE OPENSSL_ROOT_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
endif()
endif()
find_package(OpenSSL ${ARGN})
if (OPENSSL_FOUND)
include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR})
endif()
endmacro(find_openssl_libraries)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment