I have installed OpenSSL from brew, and find_package
seems to detect the brew version, but it tries to link link the project with the OpenSSL installed in the system, which is LibreSSL.
I tried to force the find_package
to set the exact path of the library, but it does nothing:
if(APPLE)
set(OPENSSL_ROOT_DIR /usr/local/Cellar/[email protected]/1.1.1d/)
endif()
So I ended up by setting the dependencies manually, which it is not ideal but it works in the meantime for development.
# OpenSSL
find_package(OpenSSL REQUIRED)
if(OPENSSL_FOUND)
if(APPLE)
include_directories(/usr/local/Cellar/[email protected]/1.1.1d/include)
list(APPEND LIB_LIST /usr/local/Cellar/[email protected]/1.1.1d/lib/libssl.dylib)
list(APPEND LIB_LIST /usr/local/Cellar/[email protected]/1.1.1d/lib/libcrypto.dylib)
message(STATUS "OpenSSL Version: ${OPENSSL_VERSION} ${OPENSSL_INCLUDE_DIR} ${OPENSSL_LIBRARIES}")
else()
include_directories(${OPENSSL_INCLUDE_DIR})
list(APPEND LIB_LIST ${OPENSSL_LIBRARIES})
message(STATUS "OpenSSL Version: ${OPENSSL_VERSION} ${OPENSSL_INCLUDE_DIR} ${OPENSSL_LIBRARIES}")
endif()
endif()
The Cmake Output provides this information, where it detects the OpenSSL library from brew, but links with the system library. Not sure why.
-- OpenSSL Version: 1.1.1d /usr/local/Cellar/[email protected]/1.1.1d/include /usr/lib/libssl.dylib;/usr/lib/libcrypto.dylib
Hope this help!