modify apk.cmake to allow caller to include jar libs

This commit is contained in:
Stephen Birarda 2014-11-17 13:13:54 -08:00
parent 52750f1ec5
commit c3f57cd07f
2 changed files with 13 additions and 1 deletions

View file

@ -68,7 +68,7 @@ set(ANDROID_THIS_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}) # Directory this CMake fil
## - "jarsigner" (part of the JDK)
## - "zipalign" (part of the Android SDK)
##################################################
macro(android_create_apk name apk_directory shared_libraries assets data_directory)
macro(android_create_apk name apk_directory shared_libraries jar_libraries assets data_directory)
if(ANDROID_APK_CREATE)
# Construct the current package name and theme
set(ANDROID_APK_PACKAGE "${ANDROID_APK_TOP_LEVEL_DOMAIN}.${ANDROID_APK_DOMAIN}.${ANDROID_APK_SUBDOMAIN}")
@ -127,6 +127,15 @@ macro(android_create_apk name apk_directory shared_libraries assets data_directo
COMMAND ${CMAKE_COMMAND} -E copy ${value} "${apk_directory}/libs/${ARM_TARGET}"
)
endforeach()
# Copy any required external jars to the libs folder
foreach(value ${jar_libraries})
add_custom_command(TARGET ${ANDROID_NAME}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${value} "${apk_directory}/libs/"
)
endforeach()
# Create "build.xml", "default.properties", "local.properties" and "proguard.cfg" files
add_custom_command(TARGET ${ANDROID_NAME}

View file

@ -24,10 +24,13 @@ set(ARM_TARGET "armeabi-v7a")
set(TARGET_SHARED_LIBRARIES ${${TARGET_NAME}_LIBRARIES_TO_LINK})
list(APPEND TARGET_SHARED_LIBRARIES "${LIBRARY_OUTPUT_PATH}/lib${TARGET_NAME}.so")
set(TARGET_JAR_LIBRARIES "${QT_CMAKE_PREFIX_PATH}/../../jar/QtAndroid-bundled.jar")
android_create_apk(
${TARGET_NAME}
"${CMAKE_BINARY_DIR}/apk"
"${TARGET_SHARED_LIBRARIES}"
"${TARGET_JAR_LIBRARIES}"
"${CMAKE_CURRENT_SOURCE_DIR}/assets"
"Data"
)