3 # Finds the Openssl libraries
5 # This will define the following target:
7 # ${APP_NAME_LC}::OpenSSL - Alias of OpenSSL::SSL target
8 # OpenSSL::SSL - standard Openssl SSL target from system find package
9 # OpenSSL::Crypto - standard Openssl Crypto target from system find package
11 if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME})
13 # We do this dance to utilise cmake system FindOpenssl. Saves us dealing with it
14 set(_temp_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
15 unset(CMAKE_MODULE_PATH)
17 if(OpenSSL_FIND_REQUIRED)
21 # Only aim for static libs on windows or depends builds
22 if(KODI_DEPENDSBUILD OR (WIN32 OR WINDOWS_STORE))
23 set(OPENSSL_USE_STATIC_LIBS ON)
24 set(OPENSSL_ROOT_DIR ${DEPENDS_PATH})
27 find_package(OpenSSL ${REQ})
28 unset(OPENSSL_USE_STATIC_LIBS)
30 # Back to our normal module paths
31 set(CMAKE_MODULE_PATH ${_temp_CMAKE_MODULE_PATH})
34 add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} ALIAS OpenSSL::SSL)
36 # Add Crypto as a link library to easily propagate both targets to our custom target
37 set_target_properties(OpenSSL::SSL PROPERTIES
38 INTERFACE_LINK_LIBRARIES "OpenSSL::Crypto")
40 if(OpenSSL_FIND_REQUIRED)
41 message(FATAL_ERROR "OpenSSL libraries were not found.")