summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAssam Boudjelthia <assam.boudjelthia@qt.io>2020-10-26 21:50:36 +0200
committerAssam Boudjelthia <assam.boudjelthia@qt.io>2020-10-27 13:49:39 +0200
commitf8a83fc5c0aee1290a3e6b9a64ea3d50a07ee71d (patch)
tree80bd1310a2d21d0cb9c7c9dc178c9eae84113f8e
parent397b3725176780d8888f8499cac0127dbb7df2c7 (diff)
CMake: allow using ANDORID_NDK_ROOT for user projects
Allow CMake for Android to use ANDROID_NDK_ROOT to deduce the path for QT_CHAINLOAD_TOOLCHAIN_FILE instead of the user providing it manually. Change-Id: Ida728011d5ca8d5a723d341ea77b173e8f105f8c Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r--cmake/QtToolchainHelpers.cmake15
-rw-r--r--cmake/qt.toolchain.cmake.in5
2 files changed, 18 insertions, 2 deletions
diff --git a/cmake/QtToolchainHelpers.cmake b/cmake/QtToolchainHelpers.cmake
index a067ef7c0c..2593aa7429 100644
--- a/cmake/QtToolchainHelpers.cmake
+++ b/cmake/QtToolchainHelpers.cmake
@@ -134,6 +134,21 @@ function(qt_internal_create_toolchain_file)
list(APPEND init_platform
" set(ANDROID_SDK_ROOT \"${__qt_android_sdk_root}\" CACHE STRING \"\")")
list(APPEND init_platform "endif()")
+
+ list(APPEND init_platform "if(NOT \"$\{ANDROID_NDK_ROOT\}\" STREQUAL \"\")")
+ list(APPEND init_platform
+ " set(__qt_toolchain_file_candidate \"$\{ANDROID_NDK_ROOT\}/build/cmake/android.toolchain.cmake\")")
+ list(APPEND init_platform " if(EXISTS \"$\{__qt_toolchain_file_candidate\}\")")
+ list(APPEND init_platform
+ " message(STATUS \"Android toolchain file within NDK detected: $\{__qt_toolchain_file_candidate\}\")")
+ list(APPEND init_platform " set(__qt_chainload_toolchain_file \"$\{__qt_toolchain_file_candidate\}\")")
+ list(APPEND init_platform " else()")
+ list(APPEND init_platform
+ " message(FATAL_ERROR \"Cannot find the toolchain file '$\{__qt_toolchain_file_candidate\}'. \"")
+ list(APPEND init_platform
+ " \"Please specify the toolchain file with -DQT_CHAINLOAD_TOOLCHAIN_FILE=<file>.\")")
+ list(APPEND init_platform " endif()")
+ list(APPEND init_platform "endif()")
endif()
string(REPLACE ";" "\n" init_vcpkg "${init_vcpkg}")
diff --git a/cmake/qt.toolchain.cmake.in b/cmake/qt.toolchain.cmake.in
index f1a7a5abaa..e97e46879d 100644
--- a/cmake/qt.toolchain.cmake.in
+++ b/cmake/qt.toolchain.cmake.in
@@ -1,9 +1,10 @@
-@init_platform@
-
@init_qt_host_path@
@init_qt_host_path_cmake_dir@
@init_original_toolchain_file@
@init_vcpkg@
+
+@init_platform@
+
if(NOT "${QT_CHAINLOAD_TOOLCHAIN_FILE}" STREQUAL "")
set(__qt_chainload_toolchain_file "${QT_CHAINLOAD_TOOLCHAIN_FILE}")
endif()