2020-11-16 14:47:43 +08:00
|
|
|
|
|
|
|
set(lib_name openssl)
|
|
|
|
|
|
|
|
project(${lib_name})
|
|
|
|
|
2022-07-08 14:20:41 +08:00
|
|
|
include(../cmake/AxisThirdpartyConfig.cmake)
|
2020-11-16 14:47:43 +08:00
|
|
|
|
2021-06-06 00:28:29 +08:00
|
|
|
set(OPENSSL_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include" CACHE STRING "OpenSSL include dir" FORCE)
|
2021-04-28 15:10:28 +08:00
|
|
|
|
2020-11-16 14:47:43 +08:00
|
|
|
# -----macro: set openssl sub target-----
|
2021-04-28 15:10:28 +08:00
|
|
|
macro(set_openssl_sub_target sub_target_name sub_lib_name)
|
2020-11-16 14:47:43 +08:00
|
|
|
|
|
|
|
if(WINDOWS)
|
|
|
|
add_library(${sub_target_name} SHARED IMPORTED GLOBAL)
|
|
|
|
else()
|
|
|
|
add_library(${sub_target_name} STATIC IMPORTED GLOBAL)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set_target_properties(${sub_target_name} PROPERTIES
|
2021-06-06 00:28:29 +08:00
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR}/include"
|
2020-11-16 14:47:43 +08:00
|
|
|
)
|
2021-04-28 15:10:28 +08:00
|
|
|
|
|
|
|
set(imp_lib_name "")
|
2020-11-16 14:47:43 +08:00
|
|
|
if(WINDOWS)
|
2021-08-27 01:14:47 +08:00
|
|
|
set(impl_lib_suffix "")
|
|
|
|
if(WIN64)
|
2021-08-27 08:33:17 +08:00
|
|
|
set(impl_lib_suffix "-${ARCH_ALIAS}")
|
2021-08-27 01:14:47 +08:00
|
|
|
endif()
|
2021-04-28 15:10:28 +08:00
|
|
|
set(imp_lib_name "${platform_spec_path}/lib${sub_lib_name}.lib")
|
2020-11-16 14:47:43 +08:00
|
|
|
set_target_properties(${sub_target_name} PROPERTIES
|
2021-09-27 20:30:38 +08:00
|
|
|
IMPORTED_LOCATION "${platform_spec_path}/lib${sub_lib_name}-3${impl_lib_suffix}.dll"
|
2020-11-16 14:47:43 +08:00
|
|
|
IMPORTED_IMPLIB "${platform_spec_path}/lib${sub_lib_name}.lib"
|
|
|
|
)
|
|
|
|
else()
|
2021-04-28 15:10:28 +08:00
|
|
|
set(imp_lib_name "${platform_spec_path}/lib${sub_lib_name}.a")
|
2020-11-16 14:47:43 +08:00
|
|
|
set_target_properties(${sub_target_name} PROPERTIES
|
|
|
|
IMPORTED_LOCATION "${platform_spec_path}/lib${sub_lib_name}.a"
|
|
|
|
)
|
|
|
|
endif()
|
2021-04-28 15:10:28 +08:00
|
|
|
if(${sub_lib_name} STREQUAL "ssl")
|
2021-07-16 13:42:06 +08:00
|
|
|
set(OPENSSL_ROOT_DIR "${platform_spec_path}" CACHE STRING "" FORCE)
|
2021-04-28 15:10:28 +08:00
|
|
|
set(OPENSSL_SSL_LIBRARY "${imp_lib_name}" CACHE STRING "" FORCE)
|
|
|
|
else()
|
|
|
|
set(OPENSSL_CRYPTO_LIBRARY "${imp_lib_name}" CACHE STRING "" FORCE)
|
|
|
|
endif()
|
2020-11-16 14:47:43 +08:00
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# -----sub target 1: ssl-----
|
2021-04-28 15:10:28 +08:00
|
|
|
set(target_name OpenSSL::SSL ssl)
|
2020-11-16 14:47:43 +08:00
|
|
|
set_openssl_sub_target(${target_name})
|
|
|
|
|
|
|
|
# -----sub target 2: crypto-----
|
2021-04-28 15:10:28 +08:00
|
|
|
set(target_name OpenSSL::Crypto crypto)
|
2020-11-16 14:47:43 +08:00
|
|
|
set_openssl_sub_target(${target_name})
|
|
|
|
|