diff options
| author | Volker Krause <vkrause@kde.org> | 2022-02-11 19:13:47 +0100 | 
|---|---|---|
| committer | Volker Krause <vkrause@kde.org> | 2022-02-11 19:14:37 +0100 | 
| commit | 676f90873b4d35c20976536844c36b8c0fbe06a5 (patch) | |
| tree | 98663d3a5a4c04d7acf14c3fb1eebf292ef6ea36 | |
| parent | 402903e5caa15f483193cd10d97754ea73078f0e (diff) | |
| download | extra-cmake-modules-676f90873b4d35c20976536844c36b8c0fbe06a5.tar.gz extra-cmake-modules-676f90873b4d35c20976536844c36b8c0fbe06a5.tar.bz2 | |
Adapt Android toolchain file and FindGradle to Qt6
- We don't need the Threads target workaround anymore, that breaks the
build with Qt6 even.
- The Gradle wrapper shipped with Qt is no longer installed as executable,
so we need to run this in sh explicitly.
- Qt6 uses a different Android Gradle plugin version (not to be confused
with the Gradle version), which we need to make available for the
configure_file() call on the build.gradle file.
With this most Framework modules build against Qt6 here.
| -rw-r--r-- | find-modules/FindGradle.cmake | 19 | ||||
| -rw-r--r-- | toolchain/Android.cmake | 6 | 
2 files changed, 21 insertions, 4 deletions
| diff --git a/find-modules/FindGradle.cmake b/find-modules/FindGradle.cmake index 6d8d6929..792598ed 100644 --- a/find-modules/FindGradle.cmake +++ b/find-modules/FindGradle.cmake @@ -27,18 +27,24 @@ Installs a Android AAR library that has been created with ``gradle_add_aar``.  Since 5.76.0.  #]=======================================================================] +include(${CMAKE_CURRENT_LIST_DIR}/../modules/QtVersionOption.cmake)  include(CMakeParseArguments)  include(FindPackageHandleStandardArgs) -find_package(Qt5Core REQUIRED) +find_package(Qt${QT_MAJOR_VERSION}Core REQUIRED) +set (Gradle_PRECOMMAND "")  if (NOT WIN32)      set(Gradle_EXECUTABLE ${CMAKE_BINARY_DIR}/gradle/gradlew) +    # the gradlew script installed by Qt6 is not executable, so running it directly fails +    if (QT_MAJOR_VERSION EQUAL "6") +        set(Gradle_PRECOMMAND "sh") +    endif()  else()      set(Gradle_EXECUTABLE ${CMAKE_BINARY_DIR}/gradle/gradlew.bat)  endif() -get_target_property(_qt_core_location Qt5::Core LOCATION) +get_target_property(_qt_core_location Qt${QT_MAJOR_VERSION}::Core LOCATION)  get_filename_component(_qt_install_root ${_qt_core_location} DIRECTORY)  get_filename_component(_qt_install_root ${_qt_install_root}/../ ABSOLUTE) @@ -50,6 +56,13 @@ add_custom_command(OUTPUT ${Gradle_EXECUTABLE}  )  add_custom_target(gradle DEPENDS ${Gradle_EXECUTABLE}) +# Android Gradle plugin version (not the Gradle version!) used by Qt, for use in our own build.gradle files +if (QT_MAJOR_VERSION EQUAL "5") +    set(Gradle_ANDROID_GRADLE_PLUGIN_VERSION 3.6.4) +else() +    set(Gradle_ANDROID_GRADLE_PLUGIN_VERSION 7.0.2) +endif() +  find_package_handle_standard_args(Gradle DEFAULT_MSG Gradle_EXECUTABLE)  function(gradle_add_aar target) @@ -71,7 +84,7 @@ function(gradle_add_aar target)      file(GLOB_RECURSE _src_files CONFIGURE_DEPENDS "*")      add_custom_command(          OUTPUT ${_build_root}/build/outputs/aar/${ARG_NAME}${_aar_suffix}.aar -        COMMAND ${Gradle_EXECUTABLE} ${_aar_gradleCmd} +        COMMAND ${Gradle_PRECOMMAND} ${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} diff --git a/toolchain/Android.cmake b/toolchain/Android.cmake index 5a48464c..280f129d 100644 --- a/toolchain/Android.cmake +++ b/toolchain/Android.cmake @@ -179,7 +179,11 @@ endif()  # armv7 really doesn't like mixing PIC/PIE code.  # Since we only have to care about a single compiler,  # hard-code the values here. -if (NOT TARGET Threads::Threads) +# Qt6 fixes this and breaks if we define Threads::Threads here. +# We cannot use our usual Qt version check at this point though yet, +# se check whether we are chainloaded by the Qt toolchain as an indicator +# for Qt6. +if (NOT TARGET Threads::Threads AND NOT DEFINED __qt_chainload_toolchain_file)      set(Threads_FOUND TRUE)      set(CMAKE_THREAD_LIBS_INIT "-pthread")      add_library(Threads::Threads INTERFACE IMPORTED) | 
