Silencing `Compatibility with CMake < 3.10 will be removed` message

Hi,

When configuring a project with cmake 3.31+ and a cmake toolchain file provided by an Android NDK < r28, one will see the following deprecation warning:

$ cat ../CMakeLists.txt
cmake_minimum_required(VERSION 3.16)
project(app LANGUAGES CXX)

$ cmake .. -DCMAKE_TOOLCHAIN_FILE=/Users/alex/Dev/android/sdk/ndk/27.2.12479018/build/cmake/android.toolchain.cmake

CMake Deprecation Warning at /Users/alex/Dev/android/sdk/ndk/27.2.12479018/build/cmake/android.toolchain.cmake:35 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

This can be silenced if one configures the project with cmake . -Wno-deprecated or with cmake . -DCMAKE_WARN_DEPRECATED=OFF

Unfortunately that will silence all deprecation warnings.

Is there a way to silence just this specific deprecation warning, without any others, thus accidentally silencing other deprecation warnings a project might care about?

I considered wrapping a project call with `set(DCMAKE_WARN_DEPRECATED ON) set(DCMAKE_WARN_DEPRECATED OFF)` but that will still silence any other deprecation warnings within the toolchain file, and it also requires editing the project.

As an aside, the warning doesn’t appear with ndk r28+, because they bumped the minimum to 3.10 see https://github.com/android/ndk/issues/2100 and 799e5a2d44cc2cc6c7d67f52f2d67957944b7680 - platform/ndk - Git at Google

See the CMAKE_POLICY_VERSION_MINIMUM environment variable.

You can also set it with -D on the command line (I don’t believe project code will be able to reliably set something earlier than the toolchain though).

While an option, that is a behavior change, causing the android toolchain file code to run with NEWer policies.

There aren’t that many policies between 3.6 and 3.10, so I suppose i could check if that won’t have any negative consequences on user projects.