aboutsummaryrefslogtreecommitdiff
path: root/toolchain
diff options
context:
space:
mode:
authorSharaf Zaman <sharafzaz121@gmail.com>2020-10-21 12:23:06 +0000
committerSharaf Zaman <sharafzaz121@gmail.com>2020-10-21 14:54:31 +0000
commit0dc7bd82b03387183bb389ffbd5a28876ba3ed31 (patch)
tree0ea44a47a68f8ec2d830d690760d33c3c1ef2dea /toolchain
parente3dd0a50689620c0ecbfc722cd9e9c9aabe6d63d (diff)
downloadextra-cmake-modules-0dc7bd82b03387183bb389ffbd5a28876ba3ed31.tar.gz
extra-cmake-modules-0dc7bd82b03387183bb389ffbd5a28876ba3ed31.tar.bz2
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.
Diffstat (limited to 'toolchain')
-rw-r--r--toolchain/ECMAndroidDeployQt.cmake2
-rw-r--r--toolchain/deployment-file.json.in3
-rw-r--r--toolchain/specifydependencies.cmake15
3 files changed, 15 insertions, 5 deletions
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 "$<TARGET_PROPERTY:create-apk-${QTANDROID_EXPORTED_TARGET},ANDROID_APK_DIR>" "${EXPORT_DIR}"
COMMAND cmake -E copy "$<TARGET_FILE:${QTANDROID_EXPORTED_TARGET}>" "${EXECUTABLE_DESTINATION_PATH}"
COMMAND LANG=C cmake "-DTARGET=$<TARGET_FILE:${QTANDROID_EXPORTED_TARGET}>" -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=$<TARGET_FILE:${QTANDROID_EXPORTED_TARGET}>" "-DOUTPUT_DIR=$<TARGET_FILE_DIR:${QTANDROID_EXPORTED_TARGET}>" "-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=$<TARGET_FILE:${QTANDROID_EXPORTED_TARGET}>" "-DOUTPUT_DIR=$<TARGET_FILE_DIR:${QTANDROID_EXPORTED_TARGET}>" "-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 $<TARGET_FILE_DIR:Qt5::qmake>/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}")