Linking statically OpenSSL crypto library in CMake

后端 未结 1 1209
不思量自难忘°
不思量自难忘° 2021-01-02 01:42

I want to statically link the libraries listed below:

set_target_properties(exec PROPERTIES LINK_SEARCH_START_STATIC 1)
set_target_properties(exec PROPER         


        
相关标签:
1条回答
  • 2021-01-02 02:11

    The CMake documentation starting with version 3.4 on the FindOpenSSL page says:

    Set OPENSSL_USE_STATIC_LIBS to TRUE to look for static libraries.

    (Assuming if they are found they will be used)

    Example:

    cmake_minimum_required(VERSION 3.4)
    project(Foo)
    
    set(SOURCE_FILES main.cpp)
    
    set(OPENSSL_USE_STATIC_LIBS TRUE)
    find_package(OpenSSL REQUIRED)
    
    add_executable(${PROJECT_NAME} ${SOURCE_FILES})
    target_link_libraries(${PROJECT_NAME} OpenSSL::Crypto)
    
    0 讨论(0)
提交回复
热议问题