CMake not able to find OpenSSL library

前端 未结 13 1997
一生所求
一生所求 2020-11-27 09:53

I am trying to install a software, which uses cmake to install itself, when i give at commandlin cmake ..
it gives me following error in this file, CMakeLists.txt -----

13条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-27 10:30

    If you can use pkg-config: pkg_search_module() can find OpenSSL for you.

    # 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()
    
    target_link_libraries(${YOUR_TARGET_HERE} ${OPENSSL_LIBRARIES})
    

提交回复
热议问题