Cmake - osx / mac - openssl brew

I use 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 own endif() 

it works on linux and on Mac, but on Mac it uses an osx-sent libssl - which generates a lot of obsolescence warnings, for example. 'SSL_library_init' is deprecated: first deprecated in OS X 10.7"

using brew I have already installed a new one - openssl-offical - libssl - how can I tell pkg_search_module in cmake to find and use the brew version?

considers

+6
source share
2 answers

ok got the job :)

 brew upgrade openssl brew link --force openssl pkg-config --modversion openssl #1.0.2 

deleted the cmake build folder and restarted cmake .. and the above macro now finds 1.0.2 libssl :)

+6
source

As of the end of 2016, this works for me:

In CMakeLists.txt:

 find_package(openssl REQUIRED) 

Run cmake as follows:

 cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl . 
+7
source

Source: https://habr.com/ru/post/985661/


All Articles