2019-06-05 10:07:42 +00:00
#
2019-06-06 12:29:31 +00:00
# Self contained Platform Settings for Android
#
2020-09-28 17:19:05 +00:00
# Note: This file is used by the internal builds.
2019-06-06 12:29:31 +00:00
#
#
2020-09-28 17:19:05 +00:00
# Variables:
2019-06-06 12:29:31 +00:00
# QT_ANDROID_JAR
# Location of the adroid sdk jar for java code
2020-09-28 17:19:05 +00:00
# QT_ANDROID_API_VERSION
2019-06-06 12:29:31 +00:00
# Android API version
2019-06-05 10:07:42 +00:00
#
if ( NOT DEFINED ANDROID_SDK_ROOT )
2020-10-05 11:32:23 +00:00
message ( FATAL_ERROR "Please provide the location of the Android SDK directory via -DANDROID_SDK_ROOT=<path to Android 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
2020-06-04 06:17:40 +00:00
set ( QT_ANDROID_API_VERSION "android-28" )
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
# 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 . "
)
2020-08-13 14:39:22 +00:00
define_property ( TARGET
P R O P E R T Y
Q T _ A N D R O I D _ A P P L I C A T I O N _ A R G U M E N T 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 c o m m a n d - l i n e a r g u m e n t s t o t h e A n d r o i d a p p . "
F U L L _ D O C S
" S p e c i f i e s e x t r a c o m m a n d - l i n e a r g u m e n t s t o t h e A n d r o i d a p p u s i n g t h e A n d r o i d M a n i f e s t . x m l w i t h t h e t a g a n d r o i d . a p p . a r g u m e n t s . "
)
2019-06-06 12:29:31 +00:00
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
2020-09-28 13:00:32 +00:00
" T h i s v a r i a b l e i s u s e d t o s p e c i f y t h e d e p l o y m e n t s e t t i n g s J S O N f i l e f o r a n d r o i d d e p l o y q t . "
2019-06-06 12:29:31 +00:00
F U L L _ D O C S
2020-09-28 13:00:32 +00:00
" T h i s v a r i a b l e p o i n t s t o t h e p a t h o f t h e d e p l o y m e n t s e t t i n g s J S O N f i l e , w h i c h h o l d s p r o p e r t i e s r e q u i r e d b y a n d r o i d d e p l o y q t t o p a c k a g e t h e A n d r o i d a p p . "
2019-06-06 12:29:31 +00:00
)
2020-12-08 14:40:43 +00:00
# Returns test execution arguments for Android targets
function ( qt_internal_android_test_arguments target out_test_runner out_test_arguments )
2020-12-15 17:09:32 +00:00
set ( ${ out_test_runner } "${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}/androidtestrunner" PARENT_SCOPE )
set ( deployment_tool "${QT_HOST_PATH}/${QT${PROJECT_VERSION_MAJOR}_HOST_INFO_BINDIR}/androiddeployqt" )
2019-10-24 08:50:06 +00:00
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" )
2020-12-08 14:40:43 +00:00
set ( ${ out_test_arguments }
" - - p a t h " " $ { a p k _ d i r } "
" - - 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 "
" - - 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 "
P A R E N T _ S C O P E
2019-10-24 08:50:06 +00:00
)
endfunction ( )