Skip to content

Commit 887474b

Browse files
committed
Add CMake OpenSSL module
1 parent fab08f6 commit 887474b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

cmake/modules/FindOpenSSL.cmake

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#
2+
# Set hints for FindOpenSSL and then call the real FindOpenSSL module.
3+
#
4+
# Our way of placing OpenSSL installation outside of the sysroot does not play well
5+
# with CMake's find_xxx() stuff, so cheat a little and pre-set certain internal
6+
# variables of FindOpenSSL.cmake so it will skip its searching steps.
7+
#
8+
9+
# Find the OpenSSL version
10+
file( GLOB OPENSSL_ROOTS "${ANDROID_NDK}/sources/openssl/*" )
11+
list( LENGTH OPENSSL_ROOTS OPENSSL_ROOTS_NR )
12+
13+
if( OPENSSL_ROOTS_NR GREATER 1 )
14+
message( FATAL_ERROR "Not implemented: more than one OpenSSL version bundled with NDK" )
15+
endif()
16+
17+
list( GET OPENSSL_ROOTS 0 OPENSSL_ROOT )
18+
# Set hard-coded pathes for the real FindOpenSSL.cmake (see above)
19+
set( OPENSSL_INCLUDE_DIR "${OPENSSL_ROOT}/include" CACHE STRING "Bundled OpenSSL include directory")
20+
set( OPENSSL_ROOT_DIR "${OPENSSL_ROOT}/libs/${ANDROID_NDK_ABI_NAME}" CACHE STRING "Bundled OpenSSL root directory")
21+
22+
unset(OPENSSL_SSL_LIBRARY)
23+
# Cleanup and chain to real FindOpenSSL.cmake
24+
unset( OPENSSL_ROOT )
25+
unset( OPENSSL_ROOTS )
26+
27+
set( ORIG_CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" )
28+
list( REMOVE_ITEM CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}" )
29+
find_package( OpenSSL )
30+
set( CMAKE_MODULE_PATH "${ORIG_CMAKE_MODULE_PATH}" )
31+
unset( ORIG_CMAKE_MODULE_PATH )

0 commit comments

Comments
 (0)