2019-06-05 10:07:42 +00:00
#
2019-06-06 12:29:31 +00:00
# Self contained Platform Settings for Android
#
# Note: This file is used both by the internal and public builds.
#
#
# Public variables:
# QT_ANDROID_JAR
# Location of the adroid sdk jar for java code
# QT_ANDROID_APIVERSION
# Android API version
# QT_ANDROID_SDK_BUILD_TOOLS_VERSION
# Detected Android sdk build tools version
#
# Public functions:
#
2019-06-12 08:21:40 +00:00
# qt_android_generate_deployment_settings()
# Generate the deployment settings json file for a cmake target.
2019-06-05 10:07:42 +00:00
#
if ( NOT DEFINED ANDROID_SDK_ROOT )
2019-06-06 12:29:31 +00:00
message ( FATAL_ERROR "Please provide the location of the Android SDK directory via -DANDROID_SDK_ROOT=<path to Adndroid SDK>" )
2019-06-05 10:07:42 +00:00
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 ( )
2019-10-18 12:28:08 +00:00
# Get the Android SDK jar for an API version other than the one specified with
# QT_ANDROID_API_VERSION.
function ( qt_get_android_sdk_jar_for_api api out_jar_location )
set ( jar_location "${ANDROID_SDK_ROOT}/platforms/${api}/android.jar" )
if ( NOT EXISTS "${jar_location}" )
message ( WARNING "Could not locate Android SDK jar for api '${api}', defaulting to ${QT_ANDROID_API_VERSION}" )
set ( ${ out_jar_location } ${ QT_ANDROID_JAR } PARENT_SCOPE )
else ( )
set ( ${ out_jar_location } ${ jar_location } PARENT_SCOPE )
endif ( )
endfunction ( )
2019-06-05 10:07:42 +00:00
# Minimum recommend android SDK api version
2019-06-06 12:29:31 +00:00
set ( QT_ANDROID_API_VERSION "android-21" )
2019-06-05 10:07:42 +00:00
# Locate android.jar
2019-06-06 12:29:31 +00:00
set ( QT_ANDROID_JAR "${ANDROID_SDK_ROOT}/platforms/${QT_ANDROID_API_VERSION}/android.jar" )
if ( NOT EXISTS "${QT_ANDROID_JAR}" )
2019-06-05 10:07:42 +00:00
# Locate the highest available platform
file ( GLOB android_platforms
L I S T _ D I R E C T O R I E S t r u e
R E L A T I V E " $ { A N D R O I D _ S D K _ R O O T } / p l a t f o r m s "
" $ { A N D R O I D _ S D K _ R O O T } / p l a t f o r m s / * " )
# If list is not empty
if ( android_platforms )
list ( SORT android_platforms )
list ( REVERSE android_platforms )
list ( GET android_platforms 0 android_platform_latest )
2019-06-06 12:29:31 +00:00
set ( QT_ANDROID_API_VERSION ${ android_platform_latest } )
set ( QT_ANDROID_JAR "${ANDROID_SDK_ROOT}/platforms/${QT_ANDROID_API_VERSION}/android.jar" )
2019-06-05 10:07:42 +00:00
endif ( )
endif ( )
2019-06-06 12:29:31 +00:00
if ( NOT EXISTS "${QT_ANDROID_JAR}" )
message ( FATAL_ERROR "No suitable Android SDK platform found. Minimum version is ${QT_ANDROID_API_VERSION}" )
2019-06-05 10:07:42 +00:00
endif ( )
2019-06-06 12:29:31 +00:00
message ( STATUS "Using Android SDK API ${QT_ANDROID_API_VERSION} from ${ANDROID_SDK_ROOT}/platforms" )
2019-06-05 10:07:42 +00:00
# Locate Java
include ( UseJava )
# Find JDK 8.0
find_package ( Java 1.8 COMPONENTS Development REQUIRED )
2019-06-06 12:29:31 +00:00
# Locate newest android sdk build tools
if ( NOT QT_ANDROID_SDK_BUILD_TOOLS_VERSION )
file ( GLOB android_build_tools
L I S T _ D I R E C T O R I E S t r u e
R E L A T I V E " $ { A N D R O I D _ S D K _ R O O T } / b u i l d - t o o l s "
" $ { A N D R O I D _ S D K _ R O O T } / b u i l d - t o o l s / * " )
if ( NOT android_build_tools )
message ( FATAL_ERROR "Could not locate Android SDK build tools under \" ${ ANDROID_SDK } /build-tools\ "" )
endif ( )
list ( SORT android_build_tools )
list ( REVERSE android_build_tools )
list ( GET android_build_tools 0 android_build_tools_latest )
2019-06-24 12:54:40 +00:00
set ( QT_ANDROID_SDK_BUILD_TOOLS_VERSION ${ android_build_tools_latest } )
2019-06-06 12:29:31 +00:00
endif ( )
# Ensure we are using the shared version of libc++
if ( NOT ANDROID_STL STREQUAL c++_shared )
message ( FATAL_ERROR "The Qt libraries on Android only supports the shared library configuration of stl. Please use -DANDROID_STL=\" c++_shared\ " as configuration argument." )
endif ( )
# Target properties required for android deploy tool
define_property ( TARGET
P R O P E R T Y
Q T _ A N D R O I D _ D E P L O Y M E N T _ D E P E N D E N C I E S
B R I E F _ D O C S
" S p e c i f y a d d i t i o n a l p l u g i n s t h a t n e e d t o b e d e p l o y e d w i t h t h e c u r r e n t a n d r o i d a p p l i c a t i o n "
F U L L _ D O C S
" B y d e f a u l t , a n d r o i d d e p l o y q t w i l l d e t e c t t h e d e p e n d e n c i e s o f y o u r a p p l i c a t i o n . B u t s i n c e r u n - t i m e u s a g e o f p l u g i n s c a n n o t b e d e t e c t e d , t h e r e c o u l d b e f a l s e p o s i t i v e s , a s y o u r a p p l i c a t i o n w i l l d e p e n d o n a n y p l u g i n s t h a t a r e p o t e n t i a l d e p e n d e n c i e s . I f y o u w a n t t o m i n i m i z e t h e s i z e o f y o u r A P K , i t ' s p o s s i b l e t o o v e r r i d e t h e a u t o m a t i c d e t e c t i o n u s i n g t h e A N D R O I D _ D E P L O Y M E N T _ D E P E N D E N C I E S v a r i a b l e . T h i s s h o u l d c o n t a i n a l i s t o f a l l Q t f i l e s w h i c h n e e d t o b e i n c l u d e d , w i t h p a t h s r e l a t i v e t o t h e Q t i n s t a l l r o o t . N o t e t h a t o n l y t h e Q t f i l e s s p e c i f i e d h e r e w i l l b e i n c l u d e d . F a i l i n g t o i n c l u d e t h e c o r r e c t f i l e s c a n r e s u l t i n c r a s h e s . I t ' s a l s o i m p o r t a n t t o m a k e s u r e t h e f i l e s a r e l i s t e d i n t h e c o r r e c t l o a d i n g o r d e r . T h i s v a r i a b l e p r o v i d e s a w a y t o o v e r r i d e t h e a u t o m a t i c d e t e c t i o n e n t i r e l y , s o i f a l i b r a r y i s l i s t e d b e f o r e i t s d e p e n d e n c i e s , i t w i l l f a i l t o l o a d o n s o m e d e v i c e s . "
)
define_property ( TARGET
P R O P E R T Y
Q T _ A N D R O I D _ E X T R A _ L I B S
B R I E F _ D O C S
" A l i s t o f e x t e r n a l l i b r a r i e s t h a t w i l l b e c o p i e d i n t o y o u r a p p l i c a t i o n ' s l i b r a r y f o l d e r a n d l o a d e d o n s t a r t - u p . "
F U L L _ D O C S
" A l i s t o f e x t e r n a l l i b r a r i e s t h a t w i l l b e c o p i e d i n t o y o u r a p p l i c a t i o n ' s l i b r a r y f o l d e r a n d l o a d e d o n s t a r t - u p . T h i s c a n b e u s e d , f o r i n s t a n c e , t o e n a b l e O p e n S S L i n y o u r a p p l i c a t i o n . S i m p l y s e t t h e p a t h s t o t h e r e q u i r e d l i b s s l . s o a n d l i b c r y p t o . s o l i b r a r i e s h e r e a n d O p e n S S L s h o u l d b e e n a b l e d a u t o m a t i c a l l y . "
)
define_property ( TARGET
P R O P E R T Y
Q T _ A N D R O I D _ E X T R A _ P L U G I N S
B R I E F _ D O C S
" T h i s v a r i a b l e c a n b e u s e d t o s p e c i f y d i f f e r e n t r e s o u r c e s t h a t y o u r p r o j e c t h a s t o b u n d l e b u t c a n n o t b e d e l i v e r e d t h r o u g h t h e a s s e t s s y s t e m , s u c h a s q m l p l u g i n s . "
F U L L _ D O C S
" T h i s v a r i a b l e c a n b e u s e d t o s p e c i f y d i f f e r e n t r e s o u r c e s t h a t y o u r p r o j e c t h a s t o b u n d l e b u t c a n n o t b e d e l i v e r e d t h r o u g h t h e a s s e t s s y s t e m , s u c h a s q m l p l u g i n s . W h e n u s i n g t h i s v a r i a b l e , a n d r o i d d e p l o y q t w i l l m a k e s u r e e v e r y t h i n g i s p a c k a g e d a n d d e p l o y e d p r o p e r l y . "
)
define_property ( TARGET
P R O P E R T Y
Q T _ A N D R O I D _ P A C K A G E _ S O U R C E _ D I R
B R I E F _ D O C S
" T h i s v a r i a b l e c a n b e u s e d t o s p e c i f y a d i r e c t o r y w h e r e a d d i t i o n s a n d m o d i f i c a t i o n s c a n b e m a d e t o t h e d e f a u l t A n d r o i d p a c k a g e t e m p l a t e . "
F U L L _ D O C S
" T h i s v a r i a b l e c a n b e u s e d t o s p e c i f y a d i r e c t o r y w h e r e a d d i t i o n s a n d m o d i f i c a t i o n s c a n b e m a d e t o t h e d e f a u l t A n d r o i d p a c k a g e t e m p l a t e . T h e a n d r o i d d e p l o y q t t o o l w i l l c o p y t h e a p p l i c a t i o n t e m p l a t e f r o m Q t i n t o t h e b u i l d d i r e c t o r y , a n d t h e n i t w i l l c o p y t h e c o n t e n t s o f t h e A N D R O I D _ P A C K A G E _ S O U R C E _ D I R o n t o p o f t h i s , o v e r w r i t i n g a n y e x i s t i n g f i l e s . T h e u p d a t e s t e p w h e r e p a r t s o f t h e s o u r c e f i l e s a r e m o d i f i e d a u t o m a t i c a l l y t o r e f l e c t y o u r o t h e r s e t t i n g s i s t h e n r u n o n t h e r e s u l t i n g m e r g e d p a c k a g e . I f y o u , f o r i n s t a n c e , w a n t t o m a k e a c u s t o m A n d r o i d M a n i f e s t . x m l f o r y o u r a p p l i c a t i o n , t h e n p l a c e t h i s d i r e c t l y i n t o t h e f o l d e r s p e c i f i e d i n t h i s v a r i a b l e . Y o u c a n a l s o a d d c u s t o m J a v a f i l e s i n A N D R O I D _ P A C K A G E _ S O U R C E _ D I R / s r c . "
)
define_property ( TARGET
P R O P E R T Y
Q T _ A N D R O I D _ D E P L O Y M E N T _ S E T T I N G S _ F I L E
B R I E F _ D O C S
" "
F U L L _ D O C S
" "
)
# Generate deployment tool json
2019-06-12 08:21:40 +00:00
function ( qt_android_generate_deployment_settings target )
2019-06-06 12:29:31 +00:00
# Information extracted from mkspecs/features/android/android_deployment_settings.prf
if ( NOT TARGET ${ target } )
message ( SEND_ERROR "${target} is not a cmake target" )
return ( )
endif ( )
get_target_property ( target_type ${ target } TYPE )
if ( NOT "${target_type}" STREQUAL "MODULE_LIBRARY" )
2019-06-12 08:21:40 +00:00
message ( SEND_ERROR "QT_ANDROID_GENERATE_DEPLOYMENT_SETTINGS only works on Module targets" )
2019-06-06 12:29:31 +00:00
return ( )
endif ( )
get_target_property ( target_source_dir ${ target } SOURCE_DIR )
get_target_property ( target_binary_dir ${ target } BINARY_DIR )
get_target_property ( target_output_name ${ target } OUTPUT_NAME )
if ( NOT target_output_name )
set ( target_output_name ${ target } )
endif ( )
set ( deploy_file "${target_binary_dir}/android-lib${target_output_name}.so-deployment-settings.json" )
2019-08-30 09:34:23 +00:00
set ( file_contents "{\n" )
2019-06-06 12:29:31 +00:00
# content begin
2019-08-30 09:34:23 +00:00
string ( APPEND file_contents
2019-06-06 12:29:31 +00:00
" \ " d e s c r i p t i o n \ " : \ " T h i s f i l e i s g e n e r a t e d b y c m a k e t o b e r e a d b y a n d r o i d d e p l o y q t a n d s h o u l d n o t b e m o d i f i e d b y h a n d . \ " , \ n " )
# Host Qt Android install path
2019-06-12 08:21:40 +00:00
if ( NOT QT_BUILDING_QT )
2019-08-30 09:34:23 +00:00
set ( file_check "${Qt6_DIR}/plugins/platforms/android/libqtforandroid_${CMAKE_ANDROID_ARCH_ABI}.so" )
2019-06-06 12:29:31 +00:00
if ( NOT EXISTS ${ file_check } )
2019-06-12 08:21:40 +00:00
message ( SEND_ERROR "Detected Qt installation does not contain libqtforandroid.so. This is most likely due to the installation not being a build of Qt for Android. Please update your settings." )
2019-06-06 12:29:31 +00:00
return ( )
endif ( )
2019-06-14 10:59:07 +00:00
set ( qt_android_install_dir ${ Qt6_Dir } )
2019-06-06 12:29:31 +00:00
else ( )
# Building from source, use the same install prefix
set ( qt_android_install_dir ${ CMAKE_INSTALL_PREFIX } )
endif ( )
file ( TO_NATIVE_PATH "${qt_android_install_dir}" qt_android_install_dir_native )
2019-08-30 09:34:23 +00:00
string ( APPEND file_contents
2019-06-06 12:29:31 +00:00
" \ " q t \ " : \ " $ { q t _ a n d r o i d _ i n s t a l l _ d i r _ n a t i v e } \ " , \ n " )
# Android SDK path
file ( TO_NATIVE_PATH "${ANDROID_SDK_ROOT}" android_sdk_root_native )
2019-08-30 09:34:23 +00:00
string ( APPEND file_contents
2019-06-06 12:29:31 +00:00
" \ " s d k \ " : \ " $ { a n d r o i d _ s d k _ r o o t _ n a t i v e } \ " , \ n " )
# Android SDK Build Tools Revision
2019-08-30 09:34:23 +00:00
string ( APPEND file_contents
2019-06-06 12:29:31 +00:00
" \ " s d k B u i l d T o o l s R e v i s i o n \ " : \ " $ { Q T _ A N D R O I D _ S D K _ B U I L D _ T O O L S _ V E R S I O N } \ " , \ n " )
# Android NDK
file ( TO_NATIVE_PATH "${ANDROID_NDK}" android_ndk_root_native )
2019-08-30 09:34:23 +00:00
string ( APPEND file_contents
2019-06-06 12:29:31 +00:00
" \ " n d k \ " : \ " $ { a n d r o i d _ n d k _ r o o t _ n a t i v e } \ " , \ n " )
# Setup LLVM toolchain
2019-08-30 09:34:23 +00:00
string ( APPEND file_contents
2019-06-06 12:29:31 +00:00
" \ " t o o l c h a i n - p r e f i x \ " : \ " l l v m \ " , \ n " )
2019-08-30 09:34:23 +00:00
string ( APPEND file_contents
2019-06-06 12:29:31 +00:00
" \ " t o o l - p r e f i x \ " : \ " l l v m \ " , \ n " )
2019-08-30 09:34:23 +00:00
string ( APPEND file_contents
2019-06-06 12:29:31 +00:00
" \ " u s e L L V M \ " : t r u e , \ n " )
# NDK Toolchain Version
2019-08-30 09:34:23 +00:00
string ( APPEND file_contents
2019-06-06 12:29:31 +00:00
" \ " t o o l c h a i n - v e r s i o n \ " : \ " $ { C M A K E _ A N D R O I D _ N D K _ T O O L C H A I N _ V E R S I O N } \ " , \ n " )
# NDK Host
2019-08-30 09:34:23 +00:00
string ( APPEND file_contents
2019-06-06 12:29:31 +00:00
" \ " n d k - h o s t \ " : \ " $ { A N D R O I D _ N D K _ H O S T _ S Y S T E M _ N A M E } \ " , \ n " )
2019-08-30 09:34:23 +00:00
if ( CMAKE_ANDROID_ARCH_ABI STREQUAL "x86" )
set ( arch_value "i686-linux-android" )
elseif ( CMAKE_ANDROID_ARCH_ABI STREQUAL "x86_64" )
set ( arch_value "x86_64-linux-android" )
2020-04-24 11:59:21 +00:00
elseif ( CMAKE_ANDROID_ARCH_ABI STREQUAL "arm64-v8a" )
2019-08-30 09:34:23 +00:00
set ( arch_value "aarch64-linux-android" )
else ( )
set ( arch_value "arm-linux-androideabi" )
endif ( )
2019-06-06 12:29:31 +00:00
# Architecture
2019-08-30 09:34:23 +00:00
string ( APPEND file_contents
" \ " a r c h i t e c t u r e s \ " : { \ " $ { C M A K E _ A N D R O I D _ A R C H _ A B I } \ " : \ " $ { a r c h _ v a l u e } \ " } , \ n " )
2019-06-06 12:29:31 +00:00
# deployment dependencies
get_target_property ( android_deployment_dependencies
$ { t a r g e t } Q T _ A N D R O I D _ D E P L O Y M E N T _ D E P E N D E N C I E S )
if ( android_deployment_dependencies )
list ( JOIN android_deployment_dependencies "," android_deployment_dependencies )
2019-08-30 09:34:23 +00:00
string ( APPEND file_contents
2019-06-06 12:29:31 +00:00
" \ " d e p l o y m e n t - d e p e n d e n c i e s \ " : \ " $ { a n d r o i d _ d e p l o y m e n t _ d e p e n d e n c i e s } \ " , \ n " )
endif ( )
# Extra plugins
get_target_property ( android_extra_plugins
$ { t a r g e t } Q T _ A N D R O I D _ E X T R A _ P L U G I N S )
if ( android_extra_plugins )
list ( JOIN android_extra_plugins "," android_extra_plugins )
2019-08-30 09:34:23 +00:00
string ( APPEND file_contents
2019-06-06 12:29:31 +00:00
" \ " a n d r o i d - e x t r a - p l u g i n s \ " : \ " $ { a n d r o i d _ e x t r a _ p l u g i n s } \ " , \ n " )
endif ( )
# Extra libs
get_target_property ( android_extra_libs
$ { t a r g e t } Q T _ A N D R O I D _ E X T R A _ L I B S )
if ( android_extra_libs )
list ( JOIN android_extra_libs "," android_extra_libs )
2019-08-30 09:34:23 +00:00
string ( APPEND file_contents
2019-06-06 12:29:31 +00:00
" \ " a n d r o i d - e x t r a - l i b s \ " : \ " $ { a n d r o i d _ e x t r a _ l i b s } \ " , \ n " )
endif ( )
# package source dir
get_target_property ( android_package_source_dir
$ { t a r g e t } Q T _ A N D R O I D _ P A C K A G E _ S O U R C E _ D I R )
if ( android_package_source_dir )
file ( TO_NATIVE_PATH "${android_package_source_dir}" android_package_source_dir_native )
2019-08-30 09:34:23 +00:00
string ( APPEND file_contents
2019-06-06 12:29:31 +00:00
" \ " a n d r o i d - p a c k a g e - s o u r c e - d i r e c t o r y \ " : \ " $ { a n d r o i d _ p a c k a g e _ s o u r c e _ d i r _ n a t i v e } \ " , \ n " )
endif ( )
#TODO: ANDROID_VERSION_NAME, doesn't seem to be used?
#TODO: ANDROID_VERSION_CODE, doesn't seem to be used?
2019-08-27 16:05:13 +00:00
get_target_property ( qml_import_path ${ target } QT_QML_IMPORT_PATH )
if ( qml_import_path )
file ( TO_NATIVE_PATH "${qml_import_path}" qml_import_path_native )
2019-08-30 09:34:23 +00:00
string ( APPEND file_contents
2019-08-27 16:05:13 +00:00
" \ " q m l - i m p o r t - p a t h \ " : \ " $ { q m l _ i m p o r t _ p a t h _ n a t i v e } \ " , \ n " )
endif ( )
get_target_property ( qml_root_path ${ target } QT_QML_ROOT_PATH )
if ( NOT qml_root_path )
set ( qml_root_path "${target_source_dir}" )
endif ( )
file ( TO_NATIVE_PATH "${qml_root_path}" qml_root_path_native )
2019-08-30 09:34:23 +00:00
string ( APPEND file_contents
2019-08-27 16:05:13 +00:00
" \ " q m l - r o o t - p a t h \ " : \ " $ { q m l _ r o o t _ p a t h _ n a t i v e } \ " , \ n " )
2019-06-06 12:29:31 +00:00
# App binary
2019-08-30 09:34:23 +00:00
string ( APPEND file_contents
" \ " a p p l i c a t i o n - b i n a r y \ " : \ " $ { t a r g e t _ o u t p u t _ n a m e } \ " , \ n " )
2019-06-06 12:29:31 +00:00
2019-08-30 12:58:57 +00:00
# Override qmlimportscanner binary path
set ( qml_importscanner_binary_path "${QT_HOST_PATH}/bin/qmlimportscanner" )
if ( WIN32 )
string ( APPEND qml_importscanner_binary_path ".exe" )
endif ( )
file ( TO_NATIVE_PATH "${qml_importscanner_binary_path}" qml_importscanner_binary_path_native )
string ( APPEND file_contents
" \ " q m l - i m p o r t s c a n n e r - b i n a r y \ " : \ " $ { q m l _ i m p o r t s c a n n e r _ b i n a r y _ p a t h _ n a t i v e } \ " , \ n " )
# Last item in json file
2019-06-06 12:29:31 +00:00
2019-08-30 09:34:23 +00:00
# base location of stdlibc++, will be suffixed by androiddeploy qt
set ( android_ndk_stdlib_base_path
" $ { A N D R O I D _ N D K } / t o o l c h a i n s / l l v m / p r e b u i l t / l i n u x - x 8 6 _ 6 4 / s y s r o o t / u s r / l i b / "
)
string ( APPEND file_contents
" \ " s t d c p p - p a t h \ " : \ " $ { a n d r o i d _ n d k _ s t d l i b _ b a s e _ p a t h } \ " \ n " )
2019-06-06 12:29:31 +00:00
# content end
2019-08-30 09:34:23 +00:00
string ( APPEND file_contents "}\n" )
file ( WRITE ${ deploy_file } ${ file_contents } )
2019-06-06 12:29:31 +00:00
set_target_properties ( ${ target }
P R O P E R T I E S
Q T _ A N D R O I D _ D E P L O Y M E N T _ S E T T I N G S _ F I L E $ { d e p l o y _ f i l e }
)
endfunction ( )
2019-08-30 09:34:23 +00:00
function ( qt_android_apply_arch_suffix target )
get_target_property ( target_type ${ target } TYPE )
2019-10-22 14:19:13 +00:00
if ( target_type STREQUAL "SHARED_LIBRARY" OR target_type STREQUAL "MODULE_LIBRARY" )
2019-08-30 09:34:23 +00:00
set_property ( TARGET "${target}" PROPERTY SUFFIX "_${CMAKE_ANDROID_ARCH_ABI}.so" )
elseif ( target_type STREQUAL "STATIC_LIBRARY" )
set_property ( TARGET "${target}" PROPERTY SUFFIX "_${CMAKE_ANDROID_ARCH_ABI}.a" )
endif ( )
endfunction ( )
2019-10-22 14:19:13 +00:00
# Add custom target to package the APK
function ( qt_android_add_apk_target target )
get_target_property ( deployment_file ${ target } QT_ANDROID_DEPLOYMENT_SETTINGS_FILE )
if ( NOT deployment_file )
message ( FATAL_ERROR "Target ${target} is not a valid android executable target\n" )
endif ( )
set ( deployment_tool "${QT_HOST_PATH}/bin/androiddeployqt" )
2019-10-24 08:50:06 +00:00
set ( apk_dir "$<TARGET_PROPERTY:${target},BINARY_DIR>/android-build" )
2019-10-22 14:19:13 +00:00
add_custom_target ( ${ target } _prepare_apk_dir
D E P E N D S $ { t a r g e t }
C O M M A N D $ { C M A K E _ C O M M A N D }
- E c o p y $ < T A R G E T _ F I L E : $ { t a r g e t } >
" $ { a p k _ d i r } / l i b s / $ { C M A K E _ A N D R O I D _ A R C H _ A B I } / $ < T A R G E T _ F I L E _ N A M E : $ { t a r g e t } > "
C O M M E N T " C o p y i n g $ { t a r g e t } b i n a r t y t o a p k f o l d e r "
)
add_custom_target ( ${ target } _make_apk
D E P E N D S $ { t a r g e t } _ p r e p a r e _ a p k _ d i r
C O M M A N D $ { d e p l o y m e n t _ t o o l }
- - i n p u t $ { d e p l o y m e n t _ f i l e }
- - o u t p u t $ { a p k _ d i r }
C O M M E N T " C r e a t i n g A P K f o r $ { t a r g e t } "
)
endfunction ( )
2019-10-24 08:50:06 +00:00
# Add a test for Android which will be run by the android test runner tool
function ( qt_android_add_test target )
set ( deployment_tool "${QT_HOST_PATH}/bin/androiddeployqt" )
set ( test_runner "${QT_HOST_PATH}/bin/androidtestrunner" )
get_target_property ( deployment_file ${ target } QT_ANDROID_DEPLOYMENT_SETTINGS_FILE )
if ( NOT deployment_file )
message ( FATAL_ERROR "Target ${target} is not a valid android executable target\n" )
endif ( )
set ( target_binary_dir "$<TARGET_PROPERTY:${target},BINARY_DIR>" )
set ( apk_dir "${target_binary_dir}/android-build" )
add_test ( NAME "${target}"
C O M M A N D " $ { t e s t _ r u n n e r } "
- - a n d r o i d d e p l o y q t " $ { d e p l o y m e n t _ t o o l } - - i n p u t $ { d e p l o y m e n t _ f i l e } "
- - a d b " $ { A N D R O I D _ S D K _ R O O T } / p l a t f o r m - t o o l s / a d b "
- - p a t h " $ { a p k _ d i r } "
- - s k i p - i n s t a l l - r o o t
- - m a k e " $ { C M A K E _ C O M M A N D } - - b u i l d $ { C M A K E _ B I N A R Y _ D I R } - - t a r g e t $ { t a r g e t } _ m a k e _ a p k "
- - a p k " $ { a p k _ d i r } / $ { t a r g e t } . a p k "
- - v e r b o s e
)
endfunction ( )