Skip to content

Commit c0414a7

Browse files
committed
Add CMake OpenSSL module
1 parent fab08f6 commit c0414a7

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

cmake/modules/FindOpenSSL.cmake

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
# Cleanup and chain to real FindOpenSSL.cmake
23+
unset( OPENSSL_ROOT )
24+
unset( OPENSSL_ROOTS )
25+
26+
set( ORIG_CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" )
27+
list( REMOVE_ITEM CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}" )
28+
find_package( OpenSSL )
29+
set( CMAKE_MODULE_PATH "${ORIG_CMAKE_MODULE_PATH}" )
30+
unset( ORIG_CMAKE_MODULE_PATH )

0 commit comments

Comments
 (0)