Skip to content

WIP: Android: Add hooks for NDK to replace CMake Platform/Android* modules

Brad King requested to merge brad.king/cmake:android-ndk-hooks into master

The Android NDK comes with a toolchain file that intends to handle all Android-related settings and avoid using CMake's own Android support. However, it includes many settings in the toolchain file itself that are supposed to belong in Platform/Android*.cmake modules. Normally third-party platforms can be configured using a toolchain file that sets CMAKE_MODULE_PATH to a directory with Platform/<os>*.cmake modules, but that does not work when CMake comes with builtin modules for that platform due to policy CMP0017.

Add an undocumented CMAKE_ANDROID_NDK_HOOK_DIR variable for use by the Android NDK's toolchain file to specify a directory with modules that hook into CMake's modules. Teach each Platform/Android*.cmake module to include a like-named module from the specified hook directory and then skip the rest of its logic. Also offer a per-module option to not skip the rest of its logic, just in case.

This hook is needed for any Platform/Android*.cmake module that is included by other CMake builtin modules since CMP0017 prevents CMAKE_MODULE_PATH from overriding such includes.

Issue: #18787 (closed)
NDK-Issue: https://github.com/android/ndk/issues/463

Merge request reports