Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Commit

Permalink
Custom manifest and activity to launch
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslo committed Dec 30, 2017
1 parent f02c9c3 commit e963cf9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
17 changes: 16 additions & 1 deletion AndroidApk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -235,6 +239,8 @@ function(android_create_apk)
DIRECTORY
ASSETS
DATA_DIRECTORY
ACTIVITY_LAUNCH
MANIFEST_TEMPLATE
)
set(multiple LIBRARIES)

Expand All @@ -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)
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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}"
Expand All @@ -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}"
)
Expand Down
14 changes: 12 additions & 2 deletions scripts/CreateApk.cmake
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -77,14 +77,24 @@ 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
# * ANDROID_APK_PACKAGE
# * ANDROID_APK_THEME
# * x_BASE_TARGET
configure_file(
"${_ANDROID_APK_THIS_DIRECTORY}/templates/AndroidManifest.xml.in"
"${android_manifest}"
"${x_DIRECTORY}/AndroidManifest.xml"
@ONLY
)
Expand Down

0 comments on commit e963cf9

Please sign in to comment.