summaryrefslogtreecommitdiffstats
path: root/cmake/QtAndroidHelpers.cmake
Commit message (Collapse)AuthorAgeFilesLines
* Generate features in AndroidManifest.xmlAlexey Edelev4 days1-0/+12
| | | | | | | | Use the transitive INTERFACE_QT_ANDROID_FEATURES property to generate user feature declarations in AndroidManifest.xml. Change-Id: I6d49da12dc708abe125546241a268bb4ed6937d1 Reviewed-by: Alexandru Croitor <[email protected]>
* Rework android permission handlingAlexey Edelev4 days1-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current QT_ANDROID_PERMISSIONS property format is inconvenient for use in the CMake generator expressions and mixes attribute syntax with CMake list syntax. This suggests the new format for the QT_ANDROID_PERMISSIONS property. Each element is encoded the following way: <android:name>\;<permission>\\\;<extra1>\;<value>\\\;<extra2>\;<value> Elements are separated using standard CMake semicolons. QT_ANDROID_PERMISSIONS is now transitive LINK property. This feature deprecates the '<permission' records in the Qt6<Module>-android-dependencies.xml files. If application links Qt Module that requires specific permissions, these permissions will be written to the application deployment-settings.json file. The 'permissions' record in the application deployment-settings.json file is changed too, the new format is following: "permissions": [{ "name": "permission", "extra1": "value", "extra2": "value" }] Comparing to the previous format each extra attribute is stored under a separate key in permission object. IMPORTANT: androiddeployqt has no backward compatibility with the old format. With QT_USE_ANDROID_MODERN_BUNDLE enabled permissions are written directly to the AndroidManifest.xml without androiddeployqt involved. Supply tests for the Android permissions, that reads the manifest-declared permissions in test using the Android PackageManager API. Change-Id: I691df33c70acc6c7139302b119edc791fef8d5ef Reviewed-by: Assam Boudjelthia <[email protected]>
* CMake: Add targets for building Android docs from Java sourcesJoerg Bornemann2025-06-021-0/+186
| | | | | | | | | | | | | | | | | | One can now run "ninja android_docs" to generate HTML docs for Android Java sources of Qt. This is done with javadoc. One can now run "ninja android_source_jars" to generate source jars for Android. They're supposed to be loaded into an IDE. The targets are enabled automatically for Android builds. For non-Android builds, set QT_BUILD_HOST_JAVA_DOCS=ON to create those targets. In that case you must also set ANDROID_SDK_ROOT. Fixes: QTBUG-117028 Change-Id: I2df51153359a95870c055d3ee373b8381f10cb51 Reviewed-by: Alexandru Croitor <[email protected]> Reviewed-by: Alexey Edelev <[email protected]> Reviewed-by: Nicholas Bennett <[email protected]>
* Introduce qt_add_android_permission CMake functionJuha Vuolle2024-09-161-36/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qt_add_android_permission function can be used to set Android permissions on target executable. This allows setting new permissions, or overriding permissions set by Qt modules, without needing to supply a manual application AndroidManifest.xml. The change consists of: - New public CMake function for setting the permissions on the target + documentation - Writing these application permissions into the deployment settings json file - Reading and handling these permissions at androiddeployqt side - Moving some pre-existing permission functionality from QtAndroidHelpers.cmake to Qt6AndroidMacros.cmake so that they can be reused also in the context of application CMakeLists.txt processing - Documentation update for Android permission handling In future this same mechanism can be extended for Android features. [ChangeLog][CMake] Added qt_add_android_permission function for setting Android permissions from application CMake Fixes: QTBUG-128280 Change-Id: Ia22951fb435598be00b5da5eae11b9f35f704795 Reviewed-by: Assam Boudjelthia <[email protected]> Reviewed-by: Alexey Edelev <[email protected]>
* Android: Get rid of init classes mechanismAssam Boudjelthia2024-08-261-8/+2
| | | | | | | | | | | | | | | | | | | | | | | | Make it more the responsibility of the module to ensure any initialization is done under JNI_OnLoad(). Qt for Android have these mechanism to set the context to Java static classes used by various modules, where the QtLoader tries to look for setContext(Context), setActivity(Activity) and setService(Service) methods defined under certain modules where it uses reflection to, for example, assign the context to them before actually loading their respective shared libraries where some initialization is needed and requires the context to be already set. This mechanism is not really necessary, since the respective libraries are going to be loaded first anyways, and they could ensure to init the context, if needed, under JNI_OnLoad() instead of those static classes and through reflection which requires the class to be public. Also, this way it would be more explicit behavior where the context is set exactly before it's needed by the module's library. Fixes: QTBUG-126478 Change-Id: I4cb39b8ef057ff7a99b66c268d85ba6da0c591ce Reviewed-by: Ville Voutilainen <[email protected]>
* Introduce qt_internal_add_android_permission CMake functionJuha Vuolle2024-08-221-1/+49
| | | | | | | | | | | | The function allows setting additional permission attributes like minSdkVersion and maxSdkVersion. The function's implementation is such that it should work alongside the older way of directly setting the QT_ANDROID_PERMISSIONS target property. Task-number: QTBUG-117358 Task-number: QTBUG-112164 Change-Id: I0f40692574848fccdf65f9baedd14351917ce4bf Reviewed-by: Alexandru Croitor <[email protected]>
* Add the support of the qt_import_plugins functionality to androiddeployqtAlexey Edelev2024-01-111-1/+2
| | | | | | | | | | qt_import_plugins allows to control application deployment on non-Android platforms. This adds support for the pre-defined plugin list that is computed using the qt_import_plugins input. Task-number: QTBUG-118829 Change-Id: Iaa9c3f600533a4b5a3079ab228fabf212d9ce5a5 Reviewed-by: Assam Boudjelthia <[email protected]>
* CMake: Split QtBuild.cmake into smaller files v2Alexandru Croitor2023-11-271-81/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | My motivation to do this: - it got big and tangled again - sometimes functions need to be added to QtBuild.cmake rather than to a separate file because they need to be called before some of the global variables are set, to determine the value of those global variables (in my case install paths needed to be modified when building with xcframework support) - some of the global variable assignments have dependencies on other variables already being set and it's hard to keep track where that happens Split the contents of the file into smaller functions and macros and place them into pre-existing files when appropriate, or into new files. The new files are: - QtBuildHelpers.cmake - QtBuildPathsHelpers.cmake - QtMkspecHelpers.cmake The idea is to have Helpers file only define functions and never call them, so it's easy to include the file where needed without being scared of side effects. QtBuild.cmake will just include the helpers and call one entry point function to set up everything that was done by the file before. QtBuild.cmake is not merged into QtSetup, to make it easier to git blame (it's hard to blame a removed file). No new features were added as part of the refactoring. Some function names were renamed (but not all of them) to include the qt_internal prefix. Some lines were reformatted so they don't pass 100 chars limit after the code was placed into a function / macro. The Helpers includes were re-sorted. Some function calls were re-ordered where the order call didn't matter. Some of the code in QtAndroidHelpers.cmake was wrapped into a macro so that including the file does not cause side-effects by default. I'd like to follow up with similar changes for QtSetup.cmake and QtBuildInternalsConfig.cmake where possible, because having a few "entry points" into building a Qt submodule is also confusing, especially for those that aren't familiar with the build system and why certain things go into certain places. The intent is to cherry-pick this also to 6.5 and 6.6. Amends 44cce1a2ea9dadd8b2de93f40de34269dda703c0 Task-number: QTBUG-86035 Change-Id: I02ceff8ceb9b6e9c78bc85d6a42deb02fca3e46b Reviewed-by: Alexey Edelev <[email protected]> Reviewed-by: Joerg Bornemann <[email protected]> Reviewed-by: Orkun Tokdemir <[email protected]>
* Revert "Revert "Add support for MultiABI with custom install dir of the ↵Alexey Edelev2023-02-021-1/+1
| | | | | | | | | | | | android-build"" This reverts commit d7e8d5bb1b5a9c4b21a3d824780c672eaf4e56b1. Reason for revert: Found a working solution for the issue. Change-Id: Ia720cc63ece9dfb1a24067cdd9c3d79d4edbe3be Reviewed-by: Alexandru Croitor <[email protected]> Reviewed-by: Assam Boudjelthia <[email protected]>
* Revert "Add support for MultiABI with custom install dir of the android-build"Alexandru Croitor2023-02-011-1/+1
| | | | | | | | | | This reverts commit 979a21dc4ee0c6f483c6b55e9242a153d659ab6f. Reason for revert: Caused QTBUG-110836 Task-number: QTBUG-110836 Change-Id: I4f31018954e6bb0f4e7b6db0df76d04c0a56d9b1 Reviewed-by: Alexandru Croitor <[email protected]>
* Add support for MultiABI with custom install dir of the android-buildFab Stz2023-01-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Right now, "multi abi builds" of android projects works only if the android-build installation doesn't use custom install dirs (INSTALL_PREFIX, INSTALL_BINDIR...) At the same time, it fixes QTBUG-106533. The patches are the same as the ones in that bugreport. Add new items to android-*-deployment-settings.json: qtDataDirectory qtLibsDirectory qtLibExecsDirectory qtPluginsDirectory qtQmlDirectory Update androiddeployqt to be able to get files from their install location BTW (fixes QTBUG-106533): Install src/android/templates into INSTALL_DATADIR Install src/3rdparty/gradle into INSTALL_DATADIR Install src/android/java files into INSTALL_DATADIR Install all jars into INSTALL_DATADIR Add missing path to target_qt.conf Update target_qt.conf to have all path. Otherwise qmake wouldn't have the path when installing the android-build with custom install dirs like INSTALL_LIBDIR & friends Add support for a new cmake variable that can be set at build time of the android projects: QT_ANDROID_PATH_CMAKE_DIR_${abi} (Name chosen as brother of QT_HOST_PATH_CMAKE_DIR) Pick-to: 6.5 Fixes: QTBUG-106533 Fixes: QTBUG-107207 Change-Id: Ia3751362ab1b5f877ecafbe02f263feac167119c Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Alexandru Croitor <[email protected]>
* CMake: Use unix paths in android xml filesAlexandru Croitor2022-10-071-12/+20
| | | | | | | | | | | | | | | | | | | | | | We aim to allow building Qt for Android on one host, and make it usable on any host. Previously when built on a Windows host, we embedded windows style paths into the android -dependencies.xml files, which caused androideployqt to fail deployment when building a project on a unix host. In Qt 5, the dependencies xml files for Windows Android packages had unix style paths. Thus switch to always using unix styles paths on all platforms. Amends a9d2c5b6d7fa6b7365db8690f57aa78002c8bc4b. Fixes: QTBUG-107249 Change-Id: I851d3e0b08415b4c7f0d22baf43c10c715879ee7 Reviewed-by: Jörg Bornemann <[email protected]> Reviewed-by: Alexey Edelev <[email protected]> Reviewed-by: Assam Boudjelthia <[email protected]>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-231-1/+1
| | | | | | | Task-number: QTBUG-105718 Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Jörg Bornemann <[email protected]>
* Add license headers to cmake filesLucie Gérard2022-08-031-0/+3
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa Reviewed-by: Jörg Bornemann <[email protected]>
* Replace ANDROID_ABI argument with the QT_ANDROID_ABI target propertyAlexey Edelev2022-01-031-0/+9
| | | | | | | | | | | | | | | | | | | | | | This change tries to make the API more user friendly and prevent wrong use of multi-abi API. ANDROID_ABI argument of qt6_add_executable was position-depend and needed to be placed after the executable 'sources'. Using the target property we solve this problem and provide more consistent and common way to enable multi-abi build for the single target. This meanwhile also requires to execute multi-abi build configuration in the finalizer, since the property might be set at any point. Also the priority of the QT_ANDROID_ABI target property now is higher than the priority of the QT_ANDROID_BUILD_ALL_ABIS variable. So target will only build packages with the ABIs specified in QT_ANDROID_ABI property if both are set. Pick-to: 6.3 Task-number: QTBUG-88841 Change-Id: I3515297ed267974498913c59619433dc234ec217 Reviewed-by: Joerg Bornemann <[email protected]>
* CMake: make sure to collect Android dependencies for pluginsAssam Boudjelthia2021-03-171-40/+65
| | | | | | | | | | | | androiddeployqt relies on *-android-dependencies.xml files to know what dependencies like jar files and permissions a Qt module requires. CMake create those files under Qt prefix's lib dir but CMake was not accounting for module plugins. Fixes: QTBUG-90812 Pick-to: 6.1 6.0 Change-Id: Ib3b2e2bb237159b4851ac0f23dc75f8e56af3f7a Reviewed-by: Alexandru Croitor <[email protected]>
* CMake: handle Android features dependencies for modulesAssam Boudjelthia2021-02-181-0/+19
| | | | | | | | | | | QMake used to allow retrieving the Android features list for a modules. The dependencies are written to *-android-dependencies.xml files and are read by androiddeployqt. This option was missed at some point along the way of writing CMake port for Qt 6. Pick-to: 6.1 6.0 Change-Id: Ic0b82f024567e640968f97aeff2db1888f2b53a5 Reviewed-by: Joerg Bornemann <[email protected]>
* Fix completely wrong init_class and jar_bundle_native valuesAlex Blasche2021-02-101-2/+2
| | | | | | | | | | This prevented androiddeployqt from properly deploying libraries which specify init class via the ":" delimiter. Pick-to: 6.0 6.1 Change-Id: Ib9cfa7edc864d7d540577df22284ceb9714a2511 Reviewed-by: Assam Boudjelthia <[email protected]> Reviewed-by: Andreas Buhr <[email protected]>
* CMake: Rename QtBuildInternalsAndroid.cmake to QtAndroidHelpers.cmakeJoerg Bornemann2020-11-241-0/+214
...and include it in QtBuild.cmake. Commit e8d8b1a5e4c added two different code paths to include QtBuildInternalsAndroid.cmake. This was needed, because: In a top-level build, we must not include files that are not yet installed. We have the source tree available, and "${QT_SOURCE_TREE}/cmake" is in CMAKE_MODULE_PATH. We can use the "module syntax" of the include() command. In a per-repository build, when building against an installed qtbase, we must not include files of the source tree, because that's not guaranteed to be available. However, Qt6BuildInternalsConfig.cmake is installed, and we can directly include QtBuildInternalsAndroid.cmake, which is right next to it. We can circumvent this whole issue by moving the Android-related functions out of the Qt6BuildInternals package and including it in QtBuild.cmake. Pick-to: 6.0 Task-number: QTBUG-88718 Change-Id: I5192ba19bb77952505c20d053d7285f798d16ac5 Reviewed-by: Alexandru Croitor <[email protected]>