I am using the following cmake commands
# Search OpenSSL
find_package(PkgConfig REQUIRED)
pkg_search_module(OPENSSL REQUIRED openssl)
if( OPENSSL_FOUND )
include_directories(${OPENSSL_INCLUDE_DIRS})
message(STATUS "Using OpenSSL ${OPENSSL_VERSION}")
else()
# Error; with REQUIRED, pkg_search_module() will throw an error by it's own
endif()
it works on Linux and on Mac, but on Mac it uses the osx-shipped libssl - which throws a a lot of deprecation warnings e.g. 'SSL_library_init' is deprecated: first deprecated in OS X 10.7"
using brew
I already installed a newer - openssl-offical - libssl - how can I tell the pkg_search_module
in cmake to find and use the brew version?
ok got it working :)
brew upgrade openssl
brew link --force openssl
pkg-config --modversion openssl
#1.0.2
removed the cmake build folder and rerun the cmake ..
and the above macro now finds the 1.0.2 libssl :)
As of late 2016 this works for me:
In CMakeLists.txt:
find_package(openssl REQUIRED)
Run cmake like this:
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl .
Jonathan is right. The MacOS system open ssl is considered insecure. Here is what works for me
Install or upgrade openssl via brew
Add these to your CMakefile. Instead of hard coding you might choose to use a command line parameter or environment variable
include_directories(BEFORE /usr/local/Cellar/openssl/1.0.2p/include) find_library(OPENSSL_LIB ssl PATHS /usr/local/Cellar/openssl/1.0.2p/lib NO_DEFAULT_PATH) find_library(CRYPTO_LIB crypto PATHS /usr/local/Cellar/openssl/1.0.2p/lib NO_DEFAULT_PATH)
To find the OpenSSL directory use the following command:
brew list openssl
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With