diff options
author | Leander Beernaert <leander.beernaert@qt.io> | 2019-06-05 12:07:42 +0200 |
---|---|---|
committer | Leander Beernaert <leander.beernaert@qt.io> | 2019-06-05 14:20:31 +0000 |
commit | 04da0df56851565fe93f69be72efbba2b492d5db (patch) | |
tree | fe0bc43e08e70b0d5dd798f02f48fc29341dab17 /cmake/QtPlatformAndroid.cmake | |
parent | bc9409d85748c7167a9e8e7eec82fa6c9420ea3d (diff) |
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>
Diffstat (limited to 'cmake/QtPlatformAndroid.cmake')
-rw-r--r-- | cmake/QtPlatformAndroid.cmake | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/cmake/QtPlatformAndroid.cmake b/cmake/QtPlatformAndroid.cmake new file mode 100644 index 0000000000..46a8fe06a4 --- /dev/null +++ b/cmake/QtPlatformAndroid.cmake @@ -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) |