summaryrefslogtreecommitdiffstats
path: root/cmake/QtPlatformAndroid.cmake
diff options
context:
space:
mode:
authorLeander Beernaert <leander.beernaert@qt.io>2019-10-22 16:19:13 +0200
committerLeander Beernaert <leander.beernaert@qt.io>2019-10-23 09:08:10 +0000
commit790d380f8b5b46d135e5c9c25bdfe13b7e5c4b05 (patch)
tree2759ee2d802bf3f0222465b55c85057543395a3e /cmake/QtPlatformAndroid.cmake
parentd5dc755c653b56d8c09d8331e3a56e0382cf5ac5 (diff)
Add custom targets to generate Android APK
This patch adds two custom targets to generate android apks. The targets are named ${TARGET}_prepare_apk_dir and ${TARGET}_make_apk. The first one insures the binary is copied to the right location and the latter invokes androiddeployqt on the apk directory. Change-Id: I8152cef387b50ec03ee2bfd92b56910a6f22754c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtPlatformAndroid.cmake')
-rw-r--r--cmake/QtPlatformAndroid.cmake28
1 files changed, 27 insertions, 1 deletions
diff --git a/cmake/QtPlatformAndroid.cmake b/cmake/QtPlatformAndroid.cmake
index 3532217722..0a91e14591 100644
--- a/cmake/QtPlatformAndroid.cmake
+++ b/cmake/QtPlatformAndroid.cmake
@@ -317,9 +317,35 @@ endfunction()
function(qt_android_apply_arch_suffix target)
get_target_property(target_type ${target} TYPE)
- if (target_type STREQUAL "SHARED_LIBRARY")
+ if (target_type STREQUAL "SHARED_LIBRARY" OR target_type STREQUAL "MODULE_LIBRARY")
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()
+
+# 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")
+ set(apk_dir "$<TARGET_PROPERTY:${target},BINARY_DIR>/apk")
+ add_custom_target(${target}_prepare_apk_dir
+ DEPENDS ${target}
+ COMMAND ${CMAKE_COMMAND}
+ -E copy $<TARGET_FILE:${target}>
+ "${apk_dir}/libs/${CMAKE_ANDROID_ARCH_ABI}/$<TARGET_FILE_NAME:${target}>"
+ COMMENT "Copying ${target} binarty to apk folder"
+ )
+
+ add_custom_target(${target}_make_apk
+ DEPENDS ${target}_prepare_apk_dir
+ COMMAND ${deployment_tool}
+ --input ${deployment_file}
+ --output ${apk_dir}
+ COMMENT "Creating APK for ${target}"
+ )
+endfunction()