This repository has been archived by the owner on Aug 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 607
/
FindOpenSSL.cmake
72 lines (60 loc) · 2.78 KB
/
FindOpenSSL.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# - Try to find the OpenSSL library
# Once done this will define
#
# OpenSSL_FOUND - system has the OpenSSL library
# OpenSSL_INCLUDE_DIRS - Include paths needed
# OpenSSL_LIBRARY_DIRS - Linker paths needed
# OpenSSL_LIBRARIES - Libraries needed
# Copyright (c) 2010, Ambroz Bizjak, <[email protected]>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
include(FindLibraryWithDebug)
if (OpenSSL_LIBRARIES)
set(OpenSSL_FIND_QUIETLY TRUE)
endif ()
set(OpenSSL_FOUND FALSE)
if (WIN32)
find_path(OpenSSL_FIND_INCLUDE_DIR openssl/ssl.h)
if (OpenSSL_FIND_INCLUDE_DIR)
# look for libraries built with GCC
find_library(OpenSSL_FIND_LIBRARIES_SSL NAMES ssl)
find_library(OpenSSL_FIND_LIBRARIES_CRYPTO NAMES crypto)
if (OpenSSL_FIND_LIBRARIES_SSL AND OpenSSL_FIND_LIBRARIES_CRYPTO)
set(OpenSSL_FOUND TRUE)
set(OpenSSL_LIBRARY_DIRS "" CACHE STRING "OpenSSL library dirs")
set(OpenSSL_LIBRARIES "${OpenSSL_FIND_LIBRARIES_SSL};${OpenSSL_FIND_LIBRARIES_CRYPTO}" CACHE STRING "OpenSSL libraries")
else ()
# look for libraries built with MSVC
FIND_LIBRARY_WITH_DEBUG(OpenSSL_FIND_LIBRARIES_SSL WIN32_DEBUG_POSTFIX d NAMES ssl ssleay ssleay32 libssleay32 ssleay32MD)
FIND_LIBRARY_WITH_DEBUG(OpenSSL_FIND_LIBRARIES_EAY WIN32_DEBUG_POSTFIX d NAMES eay libeay libeay32 libeay32MD)
if (OpenSSL_FIND_LIBRARIES_SSL AND OpenSSL_FIND_LIBRARIES_EAY)
set(OpenSSL_FOUND TRUE)
set(OpenSSL_LIBRARY_DIRS "" CACHE STRING "OpenSSL library dirs")
set(OpenSSL_LIBRARIES "${OpenSSL_FIND_LIBRARIES_SSL};${OpenSSL_FIND_LIBRARIES_EAY}" CACHE STRING "OpenSSL libraries")
endif ()
endif ()
if (OpenSSL_FOUND)
set(OpenSSL_INCLUDE_DIRS "${OpenSSL_FIND_INCLUDE_DIR}" CACHE STRING "OpenSSL include dirs")
endif ()
endif ()
else ()
find_package(PkgConfig REQUIRED)
pkg_check_modules(OpenSSL_PC openssl)
if (OpenSSL_PC_FOUND)
set(OpenSSL_FOUND TRUE)
set(OpenSSL_INCLUDE_DIRS "${OpenSSL_PC_INCLUDE_DIRS}" CACHE STRING "OpenSSL include dirs")
set(OpenSSL_LIBRARY_DIRS "${OpenSSL_PC_LIBRARY_DIRS}" CACHE STRING "OpenSSL library dirs")
set(OpenSSL_LIBRARIES "${OpenSSL_PC_LIBRARIES}" CACHE STRING "OpenSSL libraries")
endif ()
endif ()
if (OpenSSL_FOUND)
if (NOT OpenSSL_FIND_QUIETLY)
MESSAGE(STATUS "Found OpenSSL: ${OpenSSL_INCLUDE_DIRS} ${OpenSSL_LIBRARY_DIRS} ${OpenSSL_LIBRARIES}")
endif ()
else ()
if (OpenSSL_FIND_REQUIRED)
message(FATAL_ERROR "Could NOT find OpenSSL")
endif ()
endif ()
mark_as_advanced(OpenSSL_INCLUDE_DIRS OpenSSL_LIBRARY_DIRS OpenSSL_LIBRARIES)