更新时间:2022-06-25 03:48:39
The CMake documentation starting with version 3.4 on the FindOpenSSL page says:
将OPENSSL_USE_STATIC_LIBS设置为TRUE,以查找静态库.
Set OPENSSL_USE_STATIC_LIBS to TRUE to look for static libraries.
(假设找到它们,将使用它们)
(Assuming if they are found they will be used)
示例:
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)