FindOpenSSL.cmake 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. FindOpenSSL
  5. -----------
  6. Find the OpenSSL encryption library.
  7. Optional COMPONENTS
  8. ^^^^^^^^^^^^^^^^^^^
  9. This module supports two optional COMPONENTS: ``Crypto`` and ``SSL``. Both
  10. components have associated imported targets, as described below.
  11. Imported Targets
  12. ^^^^^^^^^^^^^^^^
  13. This module defines the following :prop_tgt:`IMPORTED` targets:
  14. ``OpenSSL::SSL``
  15. The OpenSSL ``ssl`` library, if found.
  16. ``OpenSSL::Crypto``
  17. The OpenSSL ``crypto`` library, if found.
  18. Result Variables
  19. ^^^^^^^^^^^^^^^^
  20. This module will set the following variables in your project:
  21. ``OPENSSL_FOUND``
  22. System has the OpenSSL library. If no components are requested it only
  23. requires the crypto library.
  24. ``OPENSSL_INCLUDE_DIR``
  25. The OpenSSL include directory.
  26. ``OPENSSL_CRYPTO_LIBRARY``
  27. The OpenSSL crypto library.
  28. ``OPENSSL_CRYPTO_LIBRARIES``
  29. The OpenSSL crypto library and its dependencies.
  30. ``OPENSSL_SSL_LIBRARY``
  31. The OpenSSL SSL library.
  32. ``OPENSSL_SSL_LIBRARIES``
  33. The OpenSSL SSL library and its dependencies.
  34. ``OPENSSL_LIBRARIES``
  35. All OpenSSL libraries and their dependencies.
  36. ``OPENSSL_VERSION``
  37. This is set to ``$major.$minor.$revision$patch`` (e.g. ``0.9.8s``).
  38. Hints
  39. ^^^^^
  40. Set ``OPENSSL_ROOT_DIR`` to the root directory of an OpenSSL installation.
  41. Set ``OPENSSL_USE_STATIC_LIBS`` to ``TRUE`` to look for static libraries.
  42. Set ``OPENSSL_MSVC_STATIC_RT`` set ``TRUE`` to choose the MT version of the lib.
  43. #]=======================================================================]
  44. macro(_OpenSSL_test_and_find_dependencies ssl_library crypto_library)
  45. if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND
  46. (("${ssl_library}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$") OR
  47. ("${crypto_library}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$")))
  48. set(_OpenSSL_has_dependencies TRUE)
  49. find_package(Threads)
  50. else()
  51. set(_OpenSSL_has_dependencies FALSE)
  52. endif()
  53. endmacro()
  54. function(_OpenSSL_add_dependencies libraries_var)
  55. if(CMAKE_THREAD_LIBS_INIT)
  56. list(APPEND ${libraries_var} ${CMAKE_THREAD_LIBS_INIT})
  57. endif()
  58. list(APPEND ${libraries_var} ${CMAKE_DL_LIBS})
  59. set(${libraries_var} ${${libraries_var}} PARENT_SCOPE)
  60. endfunction()
  61. function(_OpenSSL_target_add_dependencies target)
  62. if(_OpenSSL_has_dependencies)
  63. set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads )
  64. set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS} )
  65. endif()
  66. endfunction()
  67. if (UNIX)
  68. find_package(PkgConfig QUIET)
  69. pkg_check_modules(_OPENSSL QUIET openssl)
  70. endif ()
  71. # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
  72. if(OPENSSL_USE_STATIC_LIBS)
  73. set(_openssl_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
  74. if(WIN32)
  75. set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
  76. else()
  77. set(CMAKE_FIND_LIBRARY_SUFFIXES .a )
  78. endif()
  79. endif()
  80. if (WIN32)
  81. # http://www.slproweb.com/products/Win32OpenSSL.html
  82. set(_OPENSSL_ROOT_HINTS
  83. ${OPENSSL_ROOT_DIR}
  84. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]"
  85. "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]"
  86. ENV OPENSSL_ROOT_DIR
  87. )
  88. file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _programfiles)
  89. set(_OPENSSL_ROOT_PATHS
  90. "${_programfiles}/OpenSSL"
  91. "${_programfiles}/OpenSSL-Win32"
  92. "${_programfiles}/OpenSSL-Win64"
  93. "C:/OpenSSL/"
  94. "C:/OpenSSL-Win32/"
  95. "C:/OpenSSL-Win64/"
  96. )
  97. unset(_programfiles)
  98. else ()
  99. set(_OPENSSL_ROOT_HINTS
  100. ${OPENSSL_ROOT_DIR}
  101. ENV OPENSSL_ROOT_DIR
  102. )
  103. endif ()
  104. set(_OPENSSL_ROOT_HINTS_AND_PATHS
  105. HINTS ${_OPENSSL_ROOT_HINTS}
  106. PATHS ${_OPENSSL_ROOT_PATHS}
  107. )
  108. find_path(OPENSSL_INCLUDE_DIR
  109. NAMES
  110. openssl/ssl.h
  111. ${_OPENSSL_ROOT_HINTS_AND_PATHS}
  112. HINTS
  113. ${_OPENSSL_INCLUDEDIR}
  114. PATH_SUFFIXES
  115. include
  116. )
  117. if(WIN32 AND NOT CYGWIN)
  118. if(MSVC)
  119. # /MD and /MDd are the standard values - if someone wants to use
  120. # others, the libnames have to change here too
  121. # use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b
  122. # enable OPENSSL_MSVC_STATIC_RT to get the libs build /MT (Multithreaded no-DLL)
  123. # In Visual C++ naming convention each of these four kinds of Windows libraries has it's standard suffix:
  124. # * MD for dynamic-release
  125. # * MDd for dynamic-debug
  126. # * MT for static-release
  127. # * MTd for static-debug
  128. # Implementation details:
  129. # We are using the libraries located in the VC subdir instead of the parent directory even though :
  130. # libeay32MD.lib is identical to ../libeay32.lib, and
  131. # ssleay32MD.lib is identical to ../ssleay32.lib
  132. # enable OPENSSL_USE_STATIC_LIBS to use the static libs located in lib/VC/static
  133. if (OPENSSL_MSVC_STATIC_RT)
  134. set(_OPENSSL_MSVC_RT_MODE "MT")
  135. else ()
  136. set(_OPENSSL_MSVC_RT_MODE "MD")
  137. endif ()
  138. # Since OpenSSL 1.1, lib names are like libcrypto32MTd.lib and libssl32MTd.lib
  139. if( "${CMAKE_SIZEOF_VOID_P}" STREQUAL "8" )
  140. set(_OPENSSL_MSVC_ARCH_SUFFIX "64")
  141. else()
  142. set(_OPENSSL_MSVC_ARCH_SUFFIX "32")
  143. endif()
  144. if(OPENSSL_USE_STATIC_LIBS)
  145. set(_OPENSSL_PATH_SUFFIXES
  146. "lib/VC/static"
  147. "VC/static"
  148. "lib"
  149. )
  150. else()
  151. set(_OPENSSL_PATH_SUFFIXES
  152. "lib/VC"
  153. "VC"
  154. "lib"
  155. )
  156. endif ()
  157. find_library(LIB_EAY_DEBUG
  158. NAMES
  159. libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
  160. libcrypto${_OPENSSL_MSVC_RT_MODE}d
  161. libcryptod
  162. libeay32${_OPENSSL_MSVC_RT_MODE}d
  163. libeay32d
  164. cryptod
  165. NAMES_PER_DIR
  166. ${_OPENSSL_ROOT_HINTS_AND_PATHS}
  167. PATH_SUFFIXES
  168. ${_OPENSSL_PATH_SUFFIXES}
  169. )
  170. find_library(LIB_EAY_RELEASE
  171. NAMES
  172. libcrypto${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
  173. libcrypto${_OPENSSL_MSVC_RT_MODE}
  174. libcrypto
  175. libeay32${_OPENSSL_MSVC_RT_MODE}
  176. libeay32
  177. crypto
  178. NAMES_PER_DIR
  179. ${_OPENSSL_ROOT_HINTS_AND_PATHS}
  180. PATH_SUFFIXES
  181. ${_OPENSSL_PATH_SUFFIXES}
  182. )
  183. find_library(SSL_EAY_DEBUG
  184. NAMES
  185. libssl${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}d
  186. libssl${_OPENSSL_MSVC_RT_MODE}d
  187. libssld
  188. ssleay32${_OPENSSL_MSVC_RT_MODE}d
  189. ssleay32d
  190. ssld
  191. NAMES_PER_DIR
  192. ${_OPENSSL_ROOT_HINTS_AND_PATHS}
  193. PATH_SUFFIXES
  194. ${_OPENSSL_PATH_SUFFIXES}
  195. )
  196. find_library(SSL_EAY_RELEASE
  197. NAMES
  198. libssl${_OPENSSL_MSVC_ARCH_SUFFIX}${_OPENSSL_MSVC_RT_MODE}
  199. libssl${_OPENSSL_MSVC_RT_MODE}
  200. libssl
  201. ssleay32${_OPENSSL_MSVC_RT_MODE}
  202. ssleay32
  203. ssl
  204. NAMES_PER_DIR
  205. ${_OPENSSL_ROOT_HINTS_AND_PATHS}
  206. PATH_SUFFIXES
  207. ${_OPENSSL_PATH_SUFFIXES}
  208. )
  209. set(LIB_EAY_LIBRARY_DEBUG "${LIB_EAY_DEBUG}")
  210. set(LIB_EAY_LIBRARY_RELEASE "${LIB_EAY_RELEASE}")
  211. set(SSL_EAY_LIBRARY_DEBUG "${SSL_EAY_DEBUG}")
  212. set(SSL_EAY_LIBRARY_RELEASE "${SSL_EAY_RELEASE}")
  213. include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
  214. select_library_configurations(LIB_EAY)
  215. select_library_configurations(SSL_EAY)
  216. mark_as_advanced(LIB_EAY_LIBRARY_DEBUG LIB_EAY_LIBRARY_RELEASE
  217. SSL_EAY_LIBRARY_DEBUG SSL_EAY_LIBRARY_RELEASE)
  218. set(OPENSSL_SSL_LIBRARY ${SSL_EAY_LIBRARY} )
  219. set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY_LIBRARY} )
  220. elseif(MINGW)
  221. # same player, for MinGW
  222. set(LIB_EAY_NAMES crypto libeay32)
  223. set(SSL_EAY_NAMES ssl ssleay32)
  224. find_library(LIB_EAY
  225. NAMES
  226. ${LIB_EAY_NAMES}
  227. NAMES_PER_DIR
  228. ${_OPENSSL_ROOT_HINTS_AND_PATHS}
  229. PATH_SUFFIXES
  230. "lib/MinGW"
  231. "lib"
  232. )
  233. find_library(SSL_EAY
  234. NAMES
  235. ${SSL_EAY_NAMES}
  236. NAMES_PER_DIR
  237. ${_OPENSSL_ROOT_HINTS_AND_PATHS}
  238. PATH_SUFFIXES
  239. "lib/MinGW"
  240. "lib"
  241. )
  242. mark_as_advanced(SSL_EAY LIB_EAY)
  243. set(OPENSSL_SSL_LIBRARY ${SSL_EAY} )
  244. set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY} )
  245. unset(LIB_EAY_NAMES)
  246. unset(SSL_EAY_NAMES)
  247. else()
  248. # Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues:
  249. find_library(LIB_EAY
  250. NAMES
  251. libcrypto
  252. libeay32
  253. NAMES_PER_DIR
  254. ${_OPENSSL_ROOT_HINTS_AND_PATHS}
  255. HINTS
  256. ${_OPENSSL_LIBDIR}
  257. PATH_SUFFIXES
  258. lib
  259. )
  260. find_library(SSL_EAY
  261. NAMES
  262. libssl
  263. ssleay32
  264. NAMES_PER_DIR
  265. ${_OPENSSL_ROOT_HINTS_AND_PATHS}
  266. HINTS
  267. ${_OPENSSL_LIBDIR}
  268. PATH_SUFFIXES
  269. lib
  270. )
  271. mark_as_advanced(SSL_EAY LIB_EAY)
  272. set(OPENSSL_SSL_LIBRARY ${SSL_EAY} )
  273. set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY} )
  274. endif()
  275. else()
  276. find_library(OPENSSL_SSL_LIBRARY
  277. NAMES
  278. ssl
  279. ssleay32
  280. ssleay32MD
  281. NAMES_PER_DIR
  282. ${_OPENSSL_ROOT_HINTS_AND_PATHS}
  283. HINTS
  284. ${_OPENSSL_LIBDIR}
  285. PATH_SUFFIXES
  286. lib
  287. )
  288. find_library(OPENSSL_CRYPTO_LIBRARY
  289. NAMES
  290. crypto
  291. NAMES_PER_DIR
  292. ${_OPENSSL_ROOT_HINTS_AND_PATHS}
  293. HINTS
  294. ${_OPENSSL_LIBDIR}
  295. PATH_SUFFIXES
  296. lib
  297. )
  298. mark_as_advanced(OPENSSL_CRYPTO_LIBRARY OPENSSL_SSL_LIBRARY)
  299. endif()
  300. set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY})
  301. set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
  302. set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES} )
  303. _OpenSSL_test_and_find_dependencies("${OPENSSL_SSL_LIBRARY}" "${OPENSSL_CRYPTO_LIBRARY}")
  304. if(_OpenSSL_has_dependencies)
  305. _OpenSSL_add_dependencies( OPENSSL_SSL_LIBRARIES )
  306. _OpenSSL_add_dependencies( OPENSSL_CRYPTO_LIBRARIES )
  307. _OpenSSL_add_dependencies( OPENSSL_LIBRARIES )
  308. endif()
  309. function(from_hex HEX DEC)
  310. string(TOUPPER "${HEX}" HEX)
  311. set(_res 0)
  312. string(LENGTH "${HEX}" _strlen)
  313. while (_strlen GREATER 0)
  314. math(EXPR _res "${_res} * 16")
  315. string(SUBSTRING "${HEX}" 0 1 NIBBLE)
  316. string(SUBSTRING "${HEX}" 1 -1 HEX)
  317. if (NIBBLE STREQUAL "A")
  318. math(EXPR _res "${_res} + 10")
  319. elseif (NIBBLE STREQUAL "B")
  320. math(EXPR _res "${_res} + 11")
  321. elseif (NIBBLE STREQUAL "C")
  322. math(EXPR _res "${_res} + 12")
  323. elseif (NIBBLE STREQUAL "D")
  324. math(EXPR _res "${_res} + 13")
  325. elseif (NIBBLE STREQUAL "E")
  326. math(EXPR _res "${_res} + 14")
  327. elseif (NIBBLE STREQUAL "F")
  328. math(EXPR _res "${_res} + 15")
  329. else()
  330. math(EXPR _res "${_res} + ${NIBBLE}")
  331. endif()
  332. string(LENGTH "${HEX}" _strlen)
  333. endwhile()
  334. set(${DEC} ${_res} PARENT_SCOPE)
  335. endfunction()
  336. if(OPENSSL_INCLUDE_DIR AND EXISTS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h")
  337. file(STRINGS "${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h" openssl_version_str
  338. REGEX "^#[\t ]*define[\t ]+OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])+.*")
  339. if(openssl_version_str)
  340. # The version number is encoded as 0xMNNFFPPS: major minor fix patch status
  341. # The status gives if this is a developer or prerelease and is ignored here.
  342. # Major, minor, and fix directly translate into the version numbers shown in
  343. # the string. The patch field translates to the single character suffix that
  344. # indicates the bug fix state, which 00 -> nothing, 01 -> a, 02 -> b and so
  345. # on.
  346. string(REGEX REPLACE "^.*OPENSSL_VERSION_NUMBER[\t ]+0x([0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F][0-9a-fA-F])([0-9a-fA-F]).*$"
  347. "\\1;\\2;\\3;\\4;\\5" OPENSSL_VERSION_LIST "${openssl_version_str}")
  348. list(GET OPENSSL_VERSION_LIST 0 OPENSSL_VERSION_MAJOR)
  349. list(GET OPENSSL_VERSION_LIST 1 OPENSSL_VERSION_MINOR)
  350. from_hex("${OPENSSL_VERSION_MINOR}" OPENSSL_VERSION_MINOR)
  351. list(GET OPENSSL_VERSION_LIST 2 OPENSSL_VERSION_FIX)
  352. from_hex("${OPENSSL_VERSION_FIX}" OPENSSL_VERSION_FIX)
  353. list(GET OPENSSL_VERSION_LIST 3 OPENSSL_VERSION_PATCH)
  354. if (NOT OPENSSL_VERSION_PATCH STREQUAL "00")
  355. from_hex("${OPENSSL_VERSION_PATCH}" _tmp)
  356. # 96 is the ASCII code of 'a' minus 1
  357. math(EXPR OPENSSL_VERSION_PATCH_ASCII "${_tmp} + 96")
  358. unset(_tmp)
  359. # Once anyone knows how OpenSSL would call the patch versions beyond 'z'
  360. # this should be updated to handle that, too. This has not happened yet
  361. # so it is simply ignored here for now.
  362. string(ASCII "${OPENSSL_VERSION_PATCH_ASCII}" OPENSSL_VERSION_PATCH_STRING)
  363. endif ()
  364. set(OPENSSL_VERSION "${OPENSSL_VERSION_MAJOR}.${OPENSSL_VERSION_MINOR}.${OPENSSL_VERSION_FIX}${OPENSSL_VERSION_PATCH_STRING}")
  365. endif ()
  366. endif ()
  367. foreach(_comp IN LISTS OpenSSL_FIND_COMPONENTS)
  368. if(_comp STREQUAL "Crypto")
  369. if(EXISTS "${OPENSSL_INCLUDE_DIR}" AND
  370. (EXISTS "${OPENSSL_CRYPTO_LIBRARY}" OR
  371. EXISTS "${LIB_EAY_LIBRARY_DEBUG}" OR
  372. EXISTS "${LIB_EAY_LIBRARY_RELEASE}")
  373. )
  374. set(OpenSSL_${_comp}_FOUND TRUE)
  375. else()
  376. set(OpenSSL_${_comp}_FOUND FALSE)
  377. endif()
  378. elseif(_comp STREQUAL "SSL")
  379. if(EXISTS "${OPENSSL_INCLUDE_DIR}" AND
  380. (EXISTS "${OPENSSL_SSL_LIBRARY}" OR
  381. EXISTS "${SSL_EAY_LIBRARY_DEBUG}" OR
  382. EXISTS "${SSL_EAY_LIBRARY_RELEASE}")
  383. )
  384. set(OpenSSL_${_comp}_FOUND TRUE)
  385. else()
  386. set(OpenSSL_${_comp}_FOUND FALSE)
  387. endif()
  388. else()
  389. message(WARNING "${_comp} is not a valid OpenSSL component")
  390. set(OpenSSL_${_comp}_FOUND FALSE)
  391. endif()
  392. endforeach()
  393. unset(_comp)
  394. include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
  395. find_package_handle_standard_args(OpenSSL
  396. REQUIRED_VARS
  397. OPENSSL_CRYPTO_LIBRARY
  398. OPENSSL_INCLUDE_DIR
  399. VERSION_VAR
  400. OPENSSL_VERSION
  401. HANDLE_COMPONENTS
  402. FAIL_MESSAGE
  403. "Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR"
  404. )
  405. mark_as_advanced(OPENSSL_INCLUDE_DIR OPENSSL_LIBRARIES)
  406. if(OPENSSL_FOUND)
  407. if(NOT TARGET OpenSSL::Crypto AND
  408. (EXISTS "${OPENSSL_CRYPTO_LIBRARY}" OR
  409. EXISTS "${LIB_EAY_LIBRARY_DEBUG}" OR
  410. EXISTS "${LIB_EAY_LIBRARY_RELEASE}")
  411. )
  412. add_library(OpenSSL::Crypto UNKNOWN IMPORTED)
  413. set_target_properties(OpenSSL::Crypto PROPERTIES
  414. INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}")
  415. if(EXISTS "${OPENSSL_CRYPTO_LIBRARY}")
  416. set_target_properties(OpenSSL::Crypto PROPERTIES
  417. IMPORTED_LINK_INTERFACE_LANGUAGES "C"
  418. IMPORTED_LOCATION "${OPENSSL_CRYPTO_LIBRARY}")
  419. endif()
  420. if(EXISTS "${LIB_EAY_LIBRARY_RELEASE}")
  421. set_property(TARGET OpenSSL::Crypto APPEND PROPERTY
  422. IMPORTED_CONFIGURATIONS RELEASE)
  423. set_target_properties(OpenSSL::Crypto PROPERTIES
  424. IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
  425. IMPORTED_LOCATION_RELEASE "${LIB_EAY_LIBRARY_RELEASE}")
  426. endif()
  427. if(EXISTS "${LIB_EAY_LIBRARY_DEBUG}")
  428. set_property(TARGET OpenSSL::Crypto APPEND PROPERTY
  429. IMPORTED_CONFIGURATIONS DEBUG)
  430. set_target_properties(OpenSSL::Crypto PROPERTIES
  431. IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
  432. IMPORTED_LOCATION_DEBUG "${LIB_EAY_LIBRARY_DEBUG}")
  433. endif()
  434. _OpenSSL_target_add_dependencies(OpenSSL::Crypto)
  435. endif()
  436. if(NOT TARGET OpenSSL::SSL AND
  437. (EXISTS "${OPENSSL_SSL_LIBRARY}" OR
  438. EXISTS "${SSL_EAY_LIBRARY_DEBUG}" OR
  439. EXISTS "${SSL_EAY_LIBRARY_RELEASE}")
  440. )
  441. add_library(OpenSSL::SSL UNKNOWN IMPORTED)
  442. set_target_properties(OpenSSL::SSL PROPERTIES
  443. INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}")
  444. if(EXISTS "${OPENSSL_SSL_LIBRARY}")
  445. set_target_properties(OpenSSL::SSL PROPERTIES
  446. IMPORTED_LINK_INTERFACE_LANGUAGES "C"
  447. IMPORTED_LOCATION "${OPENSSL_SSL_LIBRARY}")
  448. endif()
  449. if(EXISTS "${SSL_EAY_LIBRARY_RELEASE}")
  450. set_property(TARGET OpenSSL::SSL APPEND PROPERTY
  451. IMPORTED_CONFIGURATIONS RELEASE)
  452. set_target_properties(OpenSSL::SSL PROPERTIES
  453. IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
  454. IMPORTED_LOCATION_RELEASE "${SSL_EAY_LIBRARY_RELEASE}")
  455. endif()
  456. if(EXISTS "${SSL_EAY_LIBRARY_DEBUG}")
  457. set_property(TARGET OpenSSL::SSL APPEND PROPERTY
  458. IMPORTED_CONFIGURATIONS DEBUG)
  459. set_target_properties(OpenSSL::SSL PROPERTIES
  460. IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
  461. IMPORTED_LOCATION_DEBUG "${SSL_EAY_LIBRARY_DEBUG}")
  462. endif()
  463. if(TARGET OpenSSL::Crypto)
  464. set_target_properties(OpenSSL::SSL PROPERTIES
  465. INTERFACE_LINK_LIBRARIES OpenSSL::Crypto)
  466. endif()
  467. _OpenSSL_target_add_dependencies(OpenSSL::SSL)
  468. endif()
  469. endif()
  470. # Restore the original find library ordering
  471. if(OPENSSL_USE_STATIC_LIBS)
  472. set(CMAKE_FIND_LIBRARY_SUFFIXES ${_openssl_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
  473. endif()