diff options
author | Volker Krause <vkrause@kde.org> | 2020-10-24 17:04:22 +0200 |
---|---|---|
committer | Volker Krause <vkrause@kde.org> | 2020-11-01 10:30:10 +0000 |
commit | 2135cbdfa6da743f32f3d03b0661313caecc7b16 (patch) | |
tree | a7a71a5cb2ccb38e3f0be9063088f499266d2d42 | |
parent | f1bf6bd813bebb2d95cdfb404bc5406be87814ae (diff) | |
download | extra-cmake-modules-5.76.0.tar.gz extra-cmake-modules-5.76.0.tar.bz2 |
Make androiddeployqt find libraries and QML plugins without installationv5.76.0-rc1v5.76.0
This matters for libraries in the same repository as the application that
also have an AAR that needs to be integrated, as well as QML plugins. For
this to work we need to consider the build directory as a search prefix,
and produce the exact directory layout there that androiddeployqt expects.
For libraries this is then almost transparent for the application build
system, the only thing that needs to be taken care of manually is putting
the corresponding -android-dependencies.xml file into the right place in
the build dir as well. A macro wrapping that might be an option to
centralize that logic here as well in the future.
For QML plugins this is transparent if you have them set up to work without
installation already anyway, otherwise that setup has to be done for this
to work.
Example: https://invent.kde.org/pim/itinerary/-/merge_requests/28
https://invent.kde.org/frameworks/knotifications/-/merge_requests/12 would
presumably also need this (not tested yet).
-rw-r--r-- | find-modules/FindGradle.cmake | 2 | ||||
-rw-r--r-- | kde-modules/KDECMakeSettings.cmake | 7 | ||||
-rw-r--r-- | toolchain/ECMAndroidDeployQt.cmake | 12 |
3 files changed, 15 insertions, 6 deletions
diff --git a/find-modules/FindGradle.cmake b/find-modules/FindGradle.cmake index 08221d43..414ea661 100644 --- a/find-modules/FindGradle.cmake +++ b/find-modules/FindGradle.cmake @@ -71,6 +71,8 @@ function(gradle_add_aar target) add_custom_command( OUTPUT ${_build_root}/build/outputs/aar/${ARG_NAME}${_aar_suffix}.aar COMMAND ${Gradle_EXECUTABLE} ${_aar_gradleCmd} + # this allows make create-apk to work without installations for apps with AAR libs in the same repository + COMMAND ${CMAKE_COMMAND} -E copy ${_build_root}/build/outputs/aar/${ARG_NAME}${_aar_suffix}.aar ${CMAKE_BINARY_DIR}/jar/${ARG_NAME}.aar DEPENDS ${Gradle_EXECUTABLE} ${_src_files} DEPENDS gradle WORKING_DIRECTORY ${_build_root} diff --git a/kde-modules/KDECMakeSettings.cmake b/kde-modules/KDECMakeSettings.cmake index 126b0a04..03d10d16 100644 --- a/kde-modules/KDECMakeSettings.cmake +++ b/kde-modules/KDECMakeSettings.cmake @@ -254,6 +254,13 @@ if(NOT KDE_SKIP_BUILD_SETTINGS) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") endif() + # For Android we need to put shared libraries into "lib" for androiddeployqt to work without prior installation. + # That fact that this conflicts with the above isn't really an issue, as we can't run things while cross-compiling + # for Android anyway. + if (ANDROID) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") + endif() + if (APPLE) # Disable detection of X11 and related package on OS X because when using # brew or macports, X11 can be installed and thus is detected. diff --git a/toolchain/ECMAndroidDeployQt.cmake b/toolchain/ECMAndroidDeployQt.cmake index 06943390..74f4c550 100644 --- a/toolchain/ECMAndroidDeployQt.cmake +++ b/toolchain/ECMAndroidDeployQt.cmake @@ -9,6 +9,10 @@ function(ecm_androiddeployqt QTANDROID_EXPORTED_TARGET ECM_ADDITIONAL_FIND_ROOT_ set(EXECUTABLE_DESTINATION_PATH "${EXPORT_DIR}/libs/${CMAKE_ANDROID_ARCH_ABI}/lib${QTANDROID_EXPORTED_TARGET}_${CMAKE_ANDROID_ARCH_ABI}.so") endif() set(QML_IMPORT_PATHS "") + # add build directory to the search path as well, so this works without installation + if (EXISTS ${CMAKE_BINARY_DIR}/lib) + set(QML_IMPORT_PATHS ${CMAKE_BINARY_DIR}/lib) + endif() foreach(prefix ${ECM_ADDITIONAL_FIND_ROOT_PATH}) # qmlimportscanner chokes on symlinks, so we need to resolve those first get_filename_component(qml_path "${prefix}/lib/qml" REALPATH) @@ -24,13 +28,9 @@ function(ecm_androiddeployqt QTANDROID_EXPORTED_TARGET ECM_ADDITIONAL_FIND_ROOT_ set(DEFINE_QML_IMPORT_PATHS "\"qml-import-paths\": \"${QML_IMPORT_PATHS}\",") endif() - set(EXTRA_PREFIX_DIRS "") + set(EXTRA_PREFIX_DIRS "\"${CMAKE_BINARY_DIR}\"") foreach(prefix ${ECM_ADDITIONAL_FIND_ROOT_PATH}) - if (EXTRA_PREFIX_DIRS) - set(EXTRA_PREFIX_DIRS "${EXTRA_PREFIX_DIRS}, \"${prefix}\"") - else() - set(EXTRA_PREFIX_DIRS "\"${prefix}\"") - endif() + set(EXTRA_PREFIX_DIRS "${EXTRA_PREFIX_DIRS}, \"${prefix}\"") endforeach() if (Qt5Core_VERSION VERSION_LESS 5.14.0) |