1
1
function (cpprest_find_openssl)
2
- if (OPENSSL_FOUND )
2
+ if (TARGET cpprestsdk_openssl_internal )
3
3
return ()
4
4
endif ()
5
5
6
6
if (IOS)
7
7
set (IOS_SOURCE_DIR "${PROJECT_SOURCE_DIR} /../Build_iOS" )
8
- set (OPENSSL_FOUND 1 CACHE INTERNAL "" )
9
- set (OPENSSL_INCLUDE_DIR "$<BUILD_INTERFACE: $ {IOS_SOURCE_DIR} /openssl/include> " CACHE INTERNAL "" )
8
+
9
+ set (OPENSSL_INCLUDE_DIR "${IOS_SOURCE_DIR} /openssl/include" CACHE INTERNAL "" )
10
10
set (OPENSSL_LIBRARIES
11
11
"${IOS_SOURCE_DIR} /openssl/lib/libcrypto.a"
12
12
"${IOS_SOURCE_DIR} /openssl/lib/libssl.a"
13
13
CACHE INTERNAL ""
14
14
)
15
15
set (_SSL_LEAK_SUPPRESS_AVAILABLE ON CACHE INTERNAL "" )
16
- return ()
17
16
elseif (ANDROID)
18
- set (OPENSSL_FOUND 1 CACHE INTERNAL "" )
19
17
if (ARM)
20
- set (OPENSSL_INCLUDE_DIR "$<BUILD_INTERFACE: $ {CMAKE_BINARY_DIR} /../openssl/armeabi-v7a/include> " CACHE INTERNAL "" )
18
+ set (OPENSSL_INCLUDE_DIR "${CMAKE_BINARY_DIR} /../openssl/armeabi-v7a/include" CACHE INTERNAL "" )
21
19
set (OPENSSL_LIBRARIES
22
20
"${CMAKE_BINARY_DIR} /../openssl/armeabi-v7a/lib/libssl.a"
23
21
"${CMAKE_BINARY_DIR} /../openssl/armeabi-v7a/lib/libcrypto.a"
24
22
CACHE INTERNAL ""
25
23
)
26
24
else ()
27
- set (OPENSSL_INCLUDE_DIR "$<BUILD_INTERFACE: $ {CMAKE_BINARY_DIR} /../openssl/x86/include> " CACHE INTERNAL "" )
25
+ set (OPENSSL_INCLUDE_DIR "${CMAKE_BINARY_DIR} /../openssl/x86/include" CACHE INTERNAL "" )
28
26
set (OPENSSL_LIBRARIES
29
27
"${CMAKE_BINARY_DIR} /../openssl/x86/lib/libssl.a"
30
28
"${CMAKE_BINARY_DIR} /../openssl/x86/lib/libcrypto.a"
31
29
CACHE INTERNAL ""
32
30
)
33
31
endif ()
34
- elseif (APPLE )
35
- if (NOT DEFINED OPENSSL_ROOT_DIR)
36
- # Prefer a homebrew version of OpenSSL over the one in /usr/lib
37
- file (GLOB OPENSSL_ROOT_DIR /usr/local/Cellar/openssl/*)
38
- # Prefer the latest (make the latest one first)
39
- list (REVERSE OPENSSL_ROOT_DIR)
40
- endif ()
41
- # This should prevent linking against the system provided 0.9.8y
42
- set (_OPENSSL_VERSION "" )
43
- find_package (OpenSSL 1.0.0 REQUIRED)
32
+ set (_SSL_LEAK_SUPPRESS_AVAILABLE ON CACHE INTERNAL "" )
44
33
else ()
34
+ if (APPLE )
35
+ if (NOT DEFINED OPENSSL_ROOT_DIR)
36
+ # Prefer a homebrew version of OpenSSL over the one in /usr/lib
37
+ file (GLOB OPENSSL_ROOT_DIR /usr/local/Cellar/openssl/*)
38
+ # Prefer the latest (make the latest one first)
39
+ list (REVERSE OPENSSL_ROOT_DIR)
40
+ endif ()
41
+ # This should prevent linking against the system provided 0.9.8y
42
+ set (_OPENSSL_VERSION "" )
43
+ endif ()
45
44
find_package (OpenSSL 1.0.0 REQUIRED)
45
+
46
+ INCLUDE (CheckCXXSourceCompiles)
47
+ set (CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR} " )
48
+ set (CMAKE_REQUIRED_LIBRARIES "${OPENSSL_LIBRARIES} " )
49
+ CHECK_CXX_SOURCE_COMPILES("
50
+ #include <openssl/ssl.h>
51
+ int main()
52
+ {
53
+ ::SSL_COMP_free_compression_methods();
54
+ }
55
+ " _SSL_LEAK_SUPPRESS_AVAILABLE)
46
56
endif ()
47
57
48
- set (OPENSSL_FOUND 1 CACHE INTERNAL "" )
49
- set (OPENSSL_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR} CACHE INTERNAL "" )
50
- set (OPENSSL_LIBRARIES ${OPENSSL_LIBRARIES} CACHE INTERNAL "" )
58
+ add_library (cpprestsdk_openssl_internal INTERFACE )
59
+ if (TARGET OpenSSL::SSL)
60
+ target_link_libraries (cpprestsdk_openssl_internal INTERFACE OpenSSL::SSL)
61
+ else ()
62
+ target_link_libraries (cpprestsdk_openssl_internal INTERFACE "$<BUILD_INTERFACE:${OPENSSL_LIBRARIES} >" )
63
+ target_include_directories (cpprestsdk_openssl_internal INTERFACE "$<BUILD_INTERFACE:${OPENSSL_INCLUDE_DIR} >" )
64
+ endif ()
51
65
52
- INCLUDE (CheckCXXSourceCompiles)
53
- set (CMAKE_REQUIRED_INCLUDES "${OPENSSL_INCLUDE_DIR} " )
54
- set (CMAKE_REQUIRED_LIBRARIES "${OPENSSL_LIBRARIES} " )
55
- CHECK_CXX_SOURCE_COMPILES("
56
- #include <openssl/ssl.h>
57
- int main()
58
- {
59
- ::SSL_COMP_free_compression_methods();
60
- }
61
- " _SSL_LEAK_SUPPRESS_AVAILABLE)
66
+ if (NOT _SSL_LEAK_SUPPRESS_AVAILABLE)
67
+ # libressl doesn't ship with the cleanup method being used in ws_client_wspp
68
+ target_compile_definitions (cpprestsdk_openssl_internal INTERFACE -DCPPREST_NO_SSL_LEAK_SUPPRESS)
69
+ endif ()
62
70
endfunction ()
0 commit comments