CMake not able to find OpenSSL library

前端 未结 13 1926
一生所求
一生所求 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:20

    This is what I added in the CMakeList.txt (which worked):

    
    # https://cmake.org/cmake/help/latest/command/find_package.html
    # in the above link, it states:
    # "In Module mode, CMake searches for a file called Find.cmake. 
    #  The file is first searched in the CMAKE_MODULE_PATH, then among the Find 
    #  Modules provided by the CMake installation. If the file is found, it is
    #  read and processed by CMake. It is responsible for finding the package,
    #  checking the version, and producing any needed messages. Some find-modules
    #  provide limited or no support for versioning; check the module documentation."
    #
    # FindOpenSSL.cmake can be found in path/to/cmake/Modules
    #
    # https://cmake.org/cmake/help/latest/module/FindOpenSSL.html
    #
    
    find_package(OpenSSL REQUIRED)
    if (OPENSSL_FOUND)
      # Add the include directories for compiling
      target_include_directories(${PROJECT_NAME} PUBLIC ${OPENSSL_INCLUDE_DIR})
    
      # Add the static lib for linking
      target_link_libraries(${PROJECT_NAME} OpenSSL::SSL OpenSSL::Crypto)
    
      message(STATUS "Found OpenSSL ${OPENSSL_VERSION}")
    
    else()
    
      message(STATUS "OpenSSL Not Found")
    
    endif()
    

提交回复
热议问题