From d5e8a5d9cbcebec966833155728be3f2d293aafa Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 3 Jul 2020 11:18:52 +0200 Subject: [PATCH] CMake: Fix missing qdevice.pri values and qt.conf info for Android qdevice.pri should embed info about the Android SDK, NDK, host, platform api level and ABI. The machine tuple test should not be run for uikit and Android platforms. Sysroot should also not be prepended for uikit and Android platforms, otherwise it breaks Qt module include paths. Task-number: QTBUG-85399 Task-number: QTBUG-82581 Change-Id: Ic48c88f6ab15d75c2ebc323c8d7a3b7e5596f3c1 Reviewed-by: Joerg Bornemann --- cmake/QtBuild.cmake | 33 ++++++++++++++++++++++++++++++--- cmake/QtFeature.cmake | 2 +- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index f2418303c6e..80eceab27ae 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -1260,10 +1260,29 @@ function(qt_generate_global_device_pri_file) string(APPEND content "${opt}\n") endforeach() - if(TEST_machine_tuple) - string(APPEND content "GCC_MACHINE_DUMP = ${TEST_machine_tuple}\n") + # Write android specific device info. + if(ANDROID) + string(APPEND content "DEFAULT_ANDROID_SDK_ROOT = ${ANDROID_SDK_ROOT}\n") + string(APPEND content "DEFAULT_ANDROID_NDK_ROOT = ${ANDROID_NDK}\n") + + set(android_platform "android-23") + if(ANDROID_NATIVE_API_LEVEL) + set(android_platform "android-${ANDROID_NATIVE_API_LEVEL}") + endif() + string(APPEND content "DEFAULT_ANDROID_PLATFORM = ${android_platform}\n") + + string(APPEND content "DEFAULT_ANDROID_NDK_HOST = ${ANDROID_HOST_TAG}\n") + + # TODO: QTBUG-80943 When we eventually support Android multi-abi, this should be changed. + string(APPEND content "DEFAULT_ANDROID_ABIS = ${ANDROID_ABI}\n") endif() + set(gcc_machine_dump "") + if(TEST_machine_tuple) + set(gcc_machine_dump "${TEST_machine_tuple}") + endif() + string(APPEND content "GCC_MACHINE_DUMP = ${gcc_machine_dump}\n") + file(GENERATE OUTPUT "${qdevice_pri_target_path}" CONTENT "${content}") qt_install(FILES "${qdevice_pri_target_path}" DESTINATION ${INSTALL_MKSPECSDIR}) endfunction() @@ -1430,12 +1449,20 @@ Prefix=${ext_prefix_relative_to_conf_file} ") endif() + # On Android CMAKE_SYSROOT is set, but for Qt's purposes it should not be set, because then + # qmake generates incorrect Qt module include flags (among other things). Do the same for darwin + # cross-compilation. + set(sysroot "") + if(CMAKE_SYSROOT AND NOT ANDROID AND NOT UIKIT) + set(sysroot "${CMAKE_SYSROOT}") + endif() + string(APPEND content "[Paths] Prefix=${ext_prefix_relative_to_conf_file} HostPrefix=${host_prefix_relative_to_conf_file} HostData=${ext_prefix_relative_to_host_prefix} -Sysroot=${CMAKE_SYSROOT} +Sysroot=${sysroot} SysrootifyPrefix=${sysrootify_prefix} TargetSpec=${QT_QMAKE_TARGET_MKSPEC} HostSpec=${QT_QMAKE_HOST_MKSPEC} diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake index 870ae0d1945..1ac23200c8f 100644 --- a/cmake/QtFeature.cmake +++ b/cmake/QtFeature.cmake @@ -858,7 +858,7 @@ function(qt_config_compile_test_x86simd extension label) endfunction() function(qt_config_compile_test_machine_tuple label) - if(DEFINED TEST_MACHINE_TUPLE OR NOT (GCC OR CLANG)) + if(DEFINED TEST_MACHINE_TUPLE OR NOT LINUX OR ANDROID) return() endif()