Skip to content

Commit

Permalink
Add openssl-3 on Qt 6.4+
Browse files Browse the repository at this point in the history
  • Loading branch information
strseb committed Dec 28, 2023
1 parent e217080 commit 2636060
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
8 changes: 8 additions & 0 deletions src/cmake/android.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,11 @@ set_property(TARGET mozillavpn PROPERTY QT_ANDROID_EXTRA_LIBS
${OPENSSL_LIBS_DIR}/libssl_1_1.so
${QTGLEAN_LIB_LOCATION}
APPEND)


if( ${Qt6_VERSION} VERSION_GREATER_EQUAL 6.4.0)
set_property(TARGET mozillavpn PROPERTY QT_ANDROID_EXTRA_LIBS
${OPENSSL_LIBS_DIR}/libcrypto_3.so
${OPENSSL_LIBS_DIR}/libssl_3.so
APPEND)
endif()
28 changes: 25 additions & 3 deletions src/cmake/android_openssl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# Publishes builds of openSSL for android on maven.

include(ExternalProject)


ExternalProject_Add(ndk_openssl
URL https://maven.google.com/com/android/ndk/thirdparty/openssl/1.1.1q-beta-1/openssl-1.1.1q-beta-1.aar
URL_HASH SHA256=a5b05c4b362d35c022238ef9b2e4e2196248adea3bac9dd683845ee75a3a8d66
Expand Down Expand Up @@ -54,6 +56,26 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E copy ${_OPENSSL_CRYPTO_MODULE}/libs/android.${ANDROID_ABI}/libcrypto.so ${_OPENSSL_LIBS}/libcrypto.so)


get_property(crypto_module GLOBAL PROPERTY OPENSSL_CRYPTO_MODULE)
get_property(ssl_module GLOBAL PROPERTY OPENSSL_SSL_MODULE)
get_property(openssl_libs GLOBAL PROPERTY OPENSSL_LIBS)
# In case of newer versions of QT, for QtSLL we need to
# have 3.x.x bundled alongside.
# Some rust crates seem to need 1.x? so ugh. both i guess.
# This piece just add's the _3.so libs into the merged folder.
find_package(Qt6 COMPONENTS Core)
if( ${Qt6_VERSION} VERSION_GREATER_EQUAL 6.4.0)
include(FetchContent)
# Google does not provide openssl v 3.0
# so let's use the builds from kdab
FetchContent_Declare(
android_openssl
DOWNLOAD_EXTRACT_TIMESTAMP true
URL https://github.com/KDAB/android_openssl/archive/refs/heads/master.zip
# URL_HASH MD5=c97d6ad774fab16be63b0ab40f78d945 #optional
)
FetchContent_MakeAvailable(android_openssl)
add_custom_command(
TARGET ndk_openssl_merged
COMMAND ${CMAKE_COMMAND} -E copy ${android_openssl_SOURCE_DIR}/ssl_3/${ANDROID_ABI}/libssl_3.so ${_OPENSSL_LIBS}/libssl_3.so
COMMAND ${CMAKE_COMMAND} -E copy ${android_openssl_SOURCE_DIR}/ssl_3/${ANDROID_ABI}/libcrypto_3.so ${_OPENSSL_LIBS}/libcrypto_3.so
)
endif()

10 changes: 0 additions & 10 deletions src/platforms/android/sources.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,4 @@ else()
endif()
endif()

add_dependencies(shared-sources ndk_openssl_merged)

get_property(crypto_module GLOBAL PROPERTY OPENSSL_CRYPTO_MODULE)
get_property(ssl_module GLOBAL PROPERTY OPENSSL_SSL_MODULE)

target_include_directories(shared-sources INTERFACE ${ssl_module}/include)

target_link_directories(shared-sources INTERFACE ${openssl_libs})
target_link_libraries(shared-sources INTERFACE libcrypto.so)
target_link_libraries(shared-sources INTERFACE libssl.so)
target_link_libraries(shared-sources INTERFACE -ljnigraphics)

0 comments on commit 2636060

Please sign in to comment.