Android: SDK Support
Enable building androiddeployqt when performing host builds only. Added QtPlatformAndroid.cmake to locate Java and the setup the android SDK platform when building on android. Install the androiddeployqt support files when performing a host build. Added ANDROID_SDK_ROOT configuration variable for specifying the android sdk directory. Generating the deployment-settings.json will be done in another change. Change-Id: I1bf15315af4ed904d2fb1d22b0e8e834df32d6ed Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>bb10
parent
bc9409d857
commit
04da0df568
|
|
@ -111,6 +111,7 @@ qt_copy_or_install(FILES
|
|||
cmake/QtCompilerOptimization.cmake
|
||||
cmake/QtFeature.cmake
|
||||
cmake/QtPlatformSupport.cmake
|
||||
cmake/QtPlatformAndroid.cmake
|
||||
cmake/QtPostProcess.cmake
|
||||
cmake/QtSetup.cmake
|
||||
cmake/QtModuleConfig.cmake.in
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
#
|
||||
# Platform Settings for Android
|
||||
#
|
||||
|
||||
if (NOT DEFINED ANDROID_SDK_ROOT)
|
||||
message(FATAL_ERROR "ANDROID_SDK_ROOT is not defined")
|
||||
endif()
|
||||
|
||||
if (NOT IS_DIRECTORY "${ANDROID_SDK_ROOT}")
|
||||
message(FATAL_ERROR "Could not find ANDROID_SDK_ROOT or path is not a directory: ${ANDROID_SDK_ROOT}")
|
||||
endif()
|
||||
|
||||
# Minimum recommend android SDK api version
|
||||
set(qt_android_api_version "android-21")
|
||||
|
||||
# Locate android.jar
|
||||
set(android_jar "${ANDROID_SDK_ROOT}/platforms/${qt_android_api_version}/android.jar")
|
||||
if(NOT EXISTS "${android_jar}")
|
||||
# Locate the highest available platform
|
||||
file(GLOB android_platforms
|
||||
LIST_DIRECTORIES true
|
||||
RELATIVE "${ANDROID_SDK_ROOT}/platforms"
|
||||
"${ANDROID_SDK_ROOT}/platforms/*")
|
||||
# If list is not empty
|
||||
if(android_platforms)
|
||||
list(SORT android_platforms)
|
||||
list(REVERSE android_platforms)
|
||||
list(GET android_platforms 0 android_platform_latest)
|
||||
set(qt_android_api_version ${android_platform_latest})
|
||||
set(android_jar "${ANDROID_SDK_ROOT}/platforms/${qt_android_api_version}/android.jar")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${android_jar}")
|
||||
message(FATAL_ERROR "No suitable Android SDK platform found. Minimum version is ${qt_android_api_version}")
|
||||
endif()
|
||||
|
||||
message(STATUS "Using Android SDK API ${qt_android_api_version} from ${ANDROID_SDK_ROOT}/platforms")
|
||||
|
||||
# Locate Java
|
||||
include(UseJava)
|
||||
|
||||
# Find JDK 8.0
|
||||
find_package(Java 1.8 COMPONENTS Development REQUIRED)
|
||||
|
|
@ -79,3 +79,7 @@ endfunction()
|
|||
if(CMAKE_CXX_COMPILER_VERSION)
|
||||
qt_parse_version_string("${CMAKE_CXX_COMPILER_VERSION}" "QT_COMPILER_VERSION")
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
include(QtPlatformAndroid)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -131,9 +131,10 @@ Vcpkg for Android can be set up using the following steps:
|
|||
* Run ```bootstrap-vcpkg.bat``` or ```bootstrap-vcpkg.sh```
|
||||
* Set the ``VCPKG_DEFAULT_TRIPLET`` environment variable to ``arm-android``
|
||||
* Set the ``ANDROID_NDK_HOME`` environment variable to the path where you have installed the Android NDK.
|
||||
* Set the ``ANDROID_SDK_HOME`` environment variable to the path where you have installed the Android SDK.
|
||||
* Build Qt dependencies: ``vcpkg install zlib pcre2 harfbuzz freetype openssl zstd``
|
||||
|
||||
When running cmake in qtbase, pass ``-DCMAKE_TOOLCHAIN_FILE=/path/to/your/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake -DVCPKG_TARGET_TRIPLET=$VCPKG_DEFAULT_TRIPLET -DQT_HOST_PATH=/path/to/your/host/build -DANDROID_NATIVE_API_LEVEL=21``
|
||||
When running cmake in qtbase, pass ``-DCMAKE_TOOLCHAIN_FILE=/path/to/your/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake -DVCPKG_TARGET_TRIPLET=$VCPKG_DEFAULT_TRIPLET -DQT_HOST_PATH=/path/to/your/host/build -DANDROID_NATIVE_API_LEVEL=21 -DANDROID_SDK_ROOT=$ANDROID_SDK_HOME``
|
||||
|
||||
|
||||
# Debugging CMake files
|
||||
|
|
|
|||
|
|
@ -56,3 +56,5 @@ endif()
|
|||
add_subdirectory(plugins)
|
||||
|
||||
add_subdirectory(winmain)
|
||||
|
||||
add_subdirectory(android)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
# Generated from android.pro.
|
||||
|
||||
# special case begin
|
||||
# Only build jars during android build?
|
||||
if (ANDROID)
|
||||
add_subdirectory(jar)
|
||||
endif()
|
||||
# special case end
|
||||
|
||||
# Templates need to be installed during host build
|
||||
add_subdirectory(java)
|
||||
add_subdirectory(templates)
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
# QtAndroid Jar
|
||||
|
||||
# special case begin
|
||||
set(path_prefix ${CMAKE_CURRENT_SOURCE_DIR}/src/org/qtproject/qt5/android/)
|
||||
|
||||
set(java_sources
|
||||
${path_prefix}/accessibility/QtAccessibilityDelegate.java
|
||||
${path_prefix}/accessibility/QtNativeAccessibility.java
|
||||
${path_prefix}/CursorHandle.java
|
||||
${path_prefix}/EditContextView.java
|
||||
${path_prefix}/EditPopupMenu.java
|
||||
${path_prefix}/ExtractStyle.java
|
||||
${path_prefix}/QtActivityDelegate.java
|
||||
${path_prefix}/QtEditText.java
|
||||
${path_prefix}/QtInputConnection.java
|
||||
${path_prefix}/QtLayout.java
|
||||
${path_prefix}/QtMessageDialogHelper.java
|
||||
${path_prefix}/QtNative.java
|
||||
${path_prefix}/QtNativeLibrariesDir.java
|
||||
${path_prefix}/QtServiceDelegate.java
|
||||
${path_prefix}/QtSurface.java
|
||||
${path_prefix}/QtThread.java)
|
||||
|
||||
add_jar(QtAndroid
|
||||
INCLUDE_JARS ${android_jar}
|
||||
SOURCES ${java_sources}
|
||||
)
|
||||
|
||||
install_jar(QtAndroid
|
||||
DESTINATION jar
|
||||
COMPONENT Devel)
|
||||
# special case end
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# Android Java Resource files
|
||||
|
||||
# special case begin
|
||||
set(resource_directories
|
||||
res
|
||||
src)
|
||||
|
||||
qt_install(DIRECTORY ${resource_directories}
|
||||
DESTINATION src/android/java
|
||||
COMPONENT Devel)
|
||||
# special case end
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
# Android template files
|
||||
|
||||
# special case begin
|
||||
set(template_files
|
||||
AndroidManifest.xml
|
||||
build.gradle)
|
||||
|
||||
set(template_directories
|
||||
res)
|
||||
|
||||
qt_install(FILES ${template_files}
|
||||
DESTINATION src/android/templates
|
||||
COMPONENT Devel)
|
||||
|
||||
qt_install(DIRECTORY ${template_directories}
|
||||
DESTINATION src/android/templates
|
||||
COMPONENT Devel)
|
||||
# special case end
|
||||
|
|
@ -5,3 +5,8 @@ if (QT_FEATURE_dbus)
|
|||
endif()
|
||||
add_subdirectory(qlalr)
|
||||
add_subdirectory(qvkgen)
|
||||
|
||||
# Only include the following tools when performing a host build
|
||||
if(NOT CMAKE_CROSSCOMPILING)
|
||||
add_subdirectory(androiddeployqt)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
# Generated from androiddeployqt.pro.
|
||||
|
||||
#####################################################################
|
||||
## androiddeployqt Binary:
|
||||
#####################################################################
|
||||
|
||||
add_qt_executable(androiddeployqt
|
||||
SOURCES
|
||||
main.cpp
|
||||
DEFINES
|
||||
QT_NO_CAST_FROM_ASCII
|
||||
QT_NO_CAST_TO_ASCII
|
||||
QT_NO_FOREACH
|
||||
)
|
||||
|
||||
#### Keys ignored in scope 1:.:.:androiddeployqt.pro:<TRUE>:
|
||||
# CONFIG = "console"
|
||||
# _LOADED = "qt_app"
|
||||
# _OPTION = "host_build"
|
||||
|
||||
## Scopes:
|
||||
#####################################################################
|
||||
|
||||
extend_target(androiddeployqt CONDITION windows
|
||||
COMPILE_OPTIONS
|
||||
-U__STRICT_ANSI__
|
||||
)
|
||||
Loading…
Reference in New Issue