From 365a2946da9a7ecb06b10983f63b7ad231bb7a8f Mon Sep 17 00:00:00 2001 From: Laurent Gomila Date: Tue, 16 Aug 2016 15:09:56 +0200 Subject: [PATCH] Added the VERSION_CODE argument to the macro, using a valid default number if not provided (no longer tied to the target's VERSION property) Increased the minimum SDK version to 18 (required by Qt) Updated the documentation --- AddQtAndroidApk.cmake | 17 ++++++++++++----- AndroidManifest.xml.in | 2 +- readme.md | 14 ++++++++++++++ 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/AddQtAndroidApk.cmake b/AddQtAndroidApk.cmake index 688d906..7093822 100644 --- a/AddQtAndroidApk.cmake +++ b/AddQtAndroidApk.cmake @@ -65,6 +65,7 @@ include(CMakeParseArguments) # example: # add_qt_android_apk(my_app_apk my_app # NAME "My App" +# VERSION_CODE 12 # PACKAGE_NAME "org.mycompany.myapp" # PACKAGE_SOURCES ${CMAKE_CURRENT_LIST_DIR}/my-android-sources # KEYSTORE ${CMAKE_CURRENT_LIST_DIR}/mykey.keystore myalias @@ -76,7 +77,7 @@ include(CMakeParseArguments) macro(add_qt_android_apk TARGET SOURCE_TARGET) # parse the macro arguments - cmake_parse_arguments(ARG "INSTALL" "NAME;PACKAGE_NAME;PACKAGE_SOURCES;KEYSTORE_PASSWORD" "DEPENDS;KEYSTORE" ${ARGN}) + cmake_parse_arguments(ARG "INSTALL" "NAME;VERSION_CODE;PACKAGE_NAME;PACKAGE_SOURCES;KEYSTORE_PASSWORD" "DEPENDS;KEYSTORE" ${ARGN}) # check the configuration if(CMAKE_BUILD_TYPE STREQUAL "Debug") @@ -110,11 +111,17 @@ macro(add_qt_android_apk TARGET SOURCE_TARGET) if(ARG_PACKAGE_SOURCES) set(QT_ANDROID_APP_PACKAGE_SOURCE_ROOT ${ARG_PACKAGE_SOURCES}) else() - # get app version - get_property(QT_ANDROID_APP_VERSION TARGET ${SOURCE_TARGET} PROPERTY VERSION) + # get version code from arguments, or generate a fixed one if not provided + set(QT_ANDROID_APP_VERSION_CODE ${ARG_VERSION_CODE}) + if(NOT QT_ANDROID_APP_VERSION_CODE) + set(QT_ANDROID_APP_VERSION_CODE 1) + endif() - # use the major version number for code version (must be a single number) - string(REGEX MATCH "[0-9]+" QT_ANDROID_APP_VERSION_CODE "${QT_ANDROID_APP_VERSION}") + # try to extract the app version from the target properties, or use the version code if not provided + get_property(QT_ANDROID_APP_VERSION TARGET ${SOURCE_TARGET} PROPERTY VERSION) + if(NOT QT_ANDROID_APP_VERSION) + set(QT_ANDROID_APP_VERSION ${QT_ANDROID_APP_VERSION_CODE}) + endif() # create a subdirectory for the extra package sources set(QT_ANDROID_APP_PACKAGE_SOURCE_ROOT "${CMAKE_CURRENT_BINARY_DIR}/package") diff --git a/AndroidManifest.xml.in b/AndroidManifest.xml.in index df80e18..3c3a090 100644 --- a/AndroidManifest.xml.in +++ b/AndroidManifest.xml.in @@ -28,6 +28,6 @@ - + diff --git a/readme.md b/readme.md index 12ab459..fa9388a 100644 --- a/readme.md +++ b/readme.md @@ -102,6 +102,20 @@ add_qt_android_apk(my_app_apk my_app ) ``` +### VERSION_CODE + +The internal version of the application. It must be a single number, incremented everytime your app is updated on the play store (otherwise it has no importance). If not given, the number 1 is used. + +Note that the public version of the application, which is a different thing, is taken from the VERSION property of the CMake target. If none is provided, the VERSION_CODE number is used. + +Example: + +```cmake +add_qt_android_apk(my_app_apk my_app + VERSION_CODE 6 +) +``` + ### PACKAGE_NAME The name of the application package. If not given, "org.qtproject.${source_target}" , where source_target is the name of the source target, is taken.