Details
-
Suggestion
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.0.0
-
None
Description
CMake documents the CMAKE_ANDROID_NDK variable as the location of the Android NDK. It has logic for detecting this based on other CMake variables and environment variables. If using the Android NDK toolchain file, that file also sets CMAKE_ANDROID_NDK.
In qtbase/cmake/QtAutoDetect.cmake, two other variables ANDROID_NDK_ROOT and CMAKE_ANDROID_NDK_ROOT are referred to. They are apparently used to allow the CMAKE_TOOLCHAIN_FILE to be set automatically when only the NDK location is provided. Neither seems to really be needed and could be replaced by CMAKE_ANDROID_NDK to reduce potential confusion over their meaning.
This has become relevant lately because of the need to document the variables that are used by Qt's CMake API. See QTBUG-88839 and in particular the changes in https://codereview.qt-project.org/c/qt/qtbase/+/327306 for context. The user should only have to worry about one variable for defining where the NDK is and CMake already documents a canonical one, but Qt seems to be using something else. While QtAutoDetect.cmake is only used to build Qt itself, it makes sense to not have different approaches between building Qt and a project that uses Qt. The generated qt.toolchain.cmake file is one example of a cross-over point between the two, as it is used by both.