From e963cf94247ff2488b97f09407ac2cc75b37d12e Mon Sep 17 00:00:00 2001 From: Ruslan Baratov Date: Sun, 31 Dec 2017 01:29:13 +0300 Subject: [PATCH] Custom manifest and activity to launch --- AndroidApk.cmake | 17 ++++++++++++++++- scripts/CreateApk.cmake | 14 ++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/AndroidApk.cmake b/AndroidApk.cmake index 105a46f..c3c0588 100644 --- a/AndroidApk.cmake +++ b/AndroidApk.cmake @@ -152,6 +152,10 @@ endfunction() ## @param DATA_DIRECTORY ## Subdirectory within the apk asset directory to copy the "assets"-files ## into (e.g. "Data") +## @param MANIFEST_TEMPLATE +## Template for creating AndroidManifest.xml +## @param ACTIVITY_LAUNCH +## Activity name for launching ################################################## function(android_create_apk) @@ -235,6 +239,8 @@ function(android_create_apk) DIRECTORY ASSETS DATA_DIRECTORY + ACTIVITY_LAUNCH + MANIFEST_TEMPLATE ) set(multiple LIBRARIES) @@ -250,6 +256,8 @@ function(android_create_apk) # * x_DIRECTORY # * x_ASSETS # * x_DATA_DIRECTORY + # * x_MANIFEST_TEMPLATE + # * x_ACTIVITY_LAUNCH # * x_LIBRARIES string(COMPARE EQUAL "${x_UNPARSED_ARGUMENTS}" "" is_empty) @@ -489,6 +497,7 @@ function(android_create_apk) "-D_ANDROID_APK_THIS_DIRECTORY=${_ANDROID_APK_THIS_DIRECTORY}" "-Dx_BASE_TARGET=${x_BASE_TARGET}" "-Dx_DIRECTORY=${x_DIRECTORY}" + "-Dx_MANIFEST_TEMPLATE=${x_MANIFEST_TEMPLATE}" -P "${_ANDROID_APK_THIS_DIRECTORY}/scripts/CreateApk.cmake" WORKING_DIRECTORY "${x_DIRECTORY}" @@ -535,6 +544,12 @@ function(android_create_apk) endif() endif() + if("${x_ACTIVITY_LAUNCH}" STREQUAL "") + set(activity_launch "LoadLibraries") + else() + set(activity_launch "${x_ACTIVITY_LAUNCH}") + endif() + if(create_launch_target) add_custom_target( "${x_LAUNCH_TARGET}" @@ -544,7 +559,7 @@ function(android_create_apk) start -S -n - "${ANDROID_APK_PACKAGE}/${ANDROID_APK_PACKAGE}.LoadLibraries" + "${ANDROID_APK_PACKAGE}/${ANDROID_APK_PACKAGE}.${activity_launch}" DEPENDS "${install_target_name}" ) diff --git a/scripts/CreateApk.cmake b/scripts/CreateApk.cmake index 5e5182a..4026ee8 100644 --- a/scripts/CreateApk.cmake +++ b/scripts/CreateApk.cmake @@ -1,7 +1,7 @@ # Copyright (c) 2016, Ruslan Baratov # All rights reserved. -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.2) string(COMPARE EQUAL "${APK_BUILD_TYPE}" "" is_empty) if(is_empty) @@ -77,6 +77,16 @@ else() set(ANDROID_APK_THEME "") endif() +if("${x_MANIFEST_TEMPLATE}" STREQUAL "") + set(android_manifest "${_ANDROID_APK_THIS_DIRECTORY}/templates/AndroidManifest.xml.in") +else() + set(android_manifest "${x_MANIFEST_TEMPLATE}") +endif() + +if(NOT EXISTS "${android_manifest}") + message(FATAL_ERROR "AndroidManifest template not found: ${android_manifest}") +endif() + # Used variables: # * CMAKE_SYSTEM_VERSION # * ANDROID_APK_DEBUGGABLE @@ -84,7 +94,7 @@ endif() # * ANDROID_APK_THEME # * x_BASE_TARGET configure_file( - "${_ANDROID_APK_THIS_DIRECTORY}/templates/AndroidManifest.xml.in" + "${android_manifest}" "${x_DIRECTORY}/AndroidManifest.xml" @ONLY )