cmake - osx/mac - openssl brew

后端 未结 4 1404
独厮守ぢ
独厮守ぢ 2021-02-06 00:24

I am using the following cmake commands

# Search OpenSSL
find_package(PkgConfig REQUIRED)
pkg_search_module(OPENSSL REQUIRED openssl)

if( OPENSSL_FOUND )

    in         


        
相关标签:
4条回答
  • 2021-02-06 00:44

    Jonathan is right. The MacOS system open ssl is considered insecure. Here is what works for me

    1. Install or upgrade openssl via brew

    2. 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
    
    0 讨论(0)
  • 2021-02-06 00:54

    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 :)

    0 讨论(0)
  • 2021-02-06 01:00

    The cause of this issue is a bug in CMake -- it does not use alternate pkg-config paths correctly.

    According to the merge request attached to the bug, the fix should be in cmake 3.17.0 (to be released in Feb 2020).

    Otherwise, use this work-around. Hard coding it in your CMakeLists.txt will make things bad for people who use MacPorts instead of Homebrew.

    0 讨论(0)
  • 2021-02-06 01:03

    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 .
    
    0 讨论(0)
提交回复
热议问题