# 设置库的根目录
set(OPENSSL_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE PATH "openssl 根目录")

# 设置头文件目录
set(OPENSSL_INCLUDE_DIRS ${OPENSSL_ROOT_DIR}/include)

# 创建导入目标
add_library(openssl::libcrypto SHARED IMPORTED)
set_target_properties(openssl::libcrypto PROPERTIES
        IMPORTED_LOCATION ${OPENSSL_ROOT_DIR}/bin/libcrypto-1_1-x64.dll
        IMPORTED_LOCATION_DEBUG ${OPENSSL_ROOT_DIR}/bin/libcrypto-1_1-x64.dll
        IMPORTED_IMPLIB ${OPENSSL_ROOT_DIR}/lib/libcrypto-1_1-x64.lib
        IMPORTED_IMPLIB_DEBUG ${OPENSSL_ROOT_DIR}/lib/libcrypto-1_1-x64.lib
        INTERFACE_INCLUDE_DIRECTORIES ${OPENSSL_INCLUDE_DIRS}
)

add_library(openssl::libssl SHARED IMPORTED)
set_target_properties(openssl::libssl PROPERTIES
        IMPORTED_LOCATION ${OPENSSL_ROOT_DIR}/bin/libssl-1_1-x64.dll
        IMPORTED_LOCATION_DEBUG ${OPENSSL_ROOT_DIR}/bin/libssl-1_1-x64.dll
        IMPORTED_IMPLIB ${OPENSSL_ROOT_DIR}/lib/libssl-1_1-x64.lib
        IMPORTED_IMPLIB_DEBUG ${OPENSSL_ROOT_DIR}/lib/libssl-1_1-x64.lib
        INTERFACE_INCLUDE_DIRECTORIES ${OPENSSL_INCLUDE_DIRS}
)

file(COPY ${OPENSSL_ROOT_DIR}/bin/  DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)

# 导出变量
set(openssl_FOUND TRUE)

