From 0dc7bd82b03387183bb389ffbd5a28876ba3ed31 Mon Sep 17 00:00:00 2001 From: Sharaf Zaman Date: Wed, 21 Oct 2020 12:23:06 +0000 Subject: Include option to use LLVM for users with Qt < 5.14 When NDK r20+ is used along with Qt5.12, APK generation fails because of the layout change in newer NDK. This patch introduces a new variable USE_LLVM, when this is set for older Qt versions, androiddeployqt uses LLVM's tools. --- toolchain/ECMAndroidDeployQt.cmake | 2 +- toolchain/deployment-file.json.in | 3 ++- toolchain/specifydependencies.cmake | 15 ++++++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) (limited to 'toolchain') diff --git a/toolchain/ECMAndroidDeployQt.cmake b/toolchain/ECMAndroidDeployQt.cmake index b04b5dd7..06943390 100644 --- a/toolchain/ECMAndroidDeployQt.cmake +++ b/toolchain/ECMAndroidDeployQt.cmake @@ -77,7 +77,7 @@ function(ecm_androiddeployqt QTANDROID_EXPORTED_TARGET ECM_ADDITIONAL_FIND_ROOT_ COMMAND cmake -E copy_directory "$" "${EXPORT_DIR}" COMMAND cmake -E copy "$" "${EXECUTABLE_DESTINATION_PATH}" COMMAND LANG=C cmake "-DTARGET=$" -P ${_CMAKE_ANDROID_DIR}/hasMainSymbol.cmake - COMMAND LANG=C cmake -DINPUT_FILE="${QTANDROID_EXPORTED_TARGET}-deployment.json.in2" -DOUTPUT_FILE="${QTANDROID_EXPORTED_TARGET}-deployment.json" "-DTARGET=$" "-DOUTPUT_DIR=$" "-DEXPORT_DIR=${CMAKE_INSTALL_PREFIX}" "-DECM_ADDITIONAL_FIND_ROOT_PATH=\"${ECM_ADDITIONAL_FIND_ROOT_PATH}\"" "-DANDROID_EXTRA_LIBS=\"${ANDROID_EXTRA_LIBS}\"" -P ${_CMAKE_ANDROID_DIR}/specifydependencies.cmake + COMMAND LANG=C cmake -DINPUT_FILE="${QTANDROID_EXPORTED_TARGET}-deployment.json.in2" -DOUTPUT_FILE="${QTANDROID_EXPORTED_TARGET}-deployment.json" "-DTARGET=$" "-DOUTPUT_DIR=$" "-DEXPORT_DIR=${CMAKE_INSTALL_PREFIX}" "-DECM_ADDITIONAL_FIND_ROOT_PATH=\"${ECM_ADDITIONAL_FIND_ROOT_PATH}\"" "-DANDROID_EXTRA_LIBS=\"${ANDROID_EXTRA_LIBS}\"" "-DUSE_LLVM=\"${USE_LLVM}\"" -P ${_CMAKE_ANDROID_DIR}/specifydependencies.cmake COMMAND $/androiddeployqt --gradle --input "${QTANDROID_EXPORTED_TARGET}-deployment.json" --apk "${ANDROID_APK_OUTPUT_DIR}/${QTANDROID_EXPORTED_TARGET}-${CMAKE_ANDROID_ARCH_ABI}.apk" --output "${EXPORT_DIR}" --android-platform android-${ANDROID_SDK_COMPILE_API} --deployment bundled ${arguments} ) # --android-platform above is only available as a command line option diff --git a/toolchain/deployment-file.json.in b/toolchain/deployment-file.json.in index 206e069d..c870b5f4 100644 --- a/toolchain/deployment-file.json.in +++ b/toolchain/deployment-file.json.in @@ -17,5 +17,6 @@ "sdkBuildToolsRevision": "@ANDROID_SDK_BUILD_TOOLS_REVISION@", "android-min-sdk-version": "@ANDROID_API_LEVEL@", "android-target-sdk-version": "@ANDROID_SDK_COMPILE_API@", - "extraPrefixDirs": [ @EXTRA_PREFIX_DIRS@ ] + "extraPrefixDirs": [ @EXTRA_PREFIX_DIRS@ ], + "useLLVM": ##USE_LLVM## } diff --git a/toolchain/specifydependencies.cmake b/toolchain/specifydependencies.cmake index d21250c1..905b62c3 100644 --- a/toolchain/specifydependencies.cmake +++ b/toolchain/specifydependencies.cmake @@ -73,9 +73,18 @@ file(READ "stl" stl_contents) file(READ "ranlib" ranlib_contents) string(REGEX MATCH ".+/toolchains/(.+)-([^\\-]+)/prebuilt/.*/bin/(.*)-ranlib" x ${ranlib_contents}) -string(REPLACE "##ANDROID_TOOL_PREFIX##" "${CMAKE_MATCH_1}" NEWCONTENTS "${CONTENTS}") -string(REPLACE "##ANDROID_TOOLCHAIN_VERSION##" "${CMAKE_MATCH_2}" NEWCONTENTS "${NEWCONTENTS}") -string(REPLACE "##ANDROID_COMPILER_PREFIX##" "${CMAKE_MATCH_3}" NEWCONTENTS "${NEWCONTENTS}") +if (USE_LLVM) + string(REPLACE "##ANDROID_TOOL_PREFIX##" "llvm" NEWCONTENTS "${CONTENTS}") + string(REPLACE "##ANDROID_COMPILER_PREFIX##" "llvm" NEWCONTENTS "${NEWCONTENTS}") + string(REPLACE "##USE_LLVM##" true NEWCONTENTS "${NEWCONTENTS}") +else() + string(REPLACE "##ANDROID_TOOL_PREFIX##" "${CMAKE_MATCH_1}" NEWCONTENTS "${CONTENTS}") + string(REPLACE "##ANDROID_COMPILER_PREFIX##" "${CMAKE_MATCH_3}" NEWCONTENTS "${NEWCONTENTS}") + string(REPLACE "##USE_LLVM##" false NEWCONTENTS "${NEWCONTENTS}") +endif() + +string(REPLACE "##ANDROID_TOOLCHAIN_VERSION##" "${CMAKE_MATCH_2}" NEWCONTENTS "${NEWCONTENTS}") # not used when USE_LLVM is set + string(REPLACE "##EXTRALIBS##" "${extralibs}" NEWCONTENTS "${NEWCONTENTS}") string(REPLACE "##EXTRAPLUGINS##" "${extraplugins}" NEWCONTENTS "${NEWCONTENTS}") string(REPLACE "##CMAKE_CXX_STANDARD_LIBRARIES##" "${stl_contents}" NEWCONTENTS "${NEWCONTENTS}") -- cgit v1.2.1