[cmake-developers] 3.9.0-rc3: CMAKE_ANDROID_NDK_DEPRECATED_HEADERS doesn't work outside of toolchain

Brad King brad.king at kitware.com
Tue Jun 27 12:07:05 EDT 2017


On 06/27/2017 11:36 AM, Robert Dailey wrote:
> Ok maybe I'm misunderstanding the design intent for toolchain files. 

Originally they were intended to contain information local to the
machine, like `set(CMAKE_ANDROID_NDK /path/on/my/machine/to/ndk)`.
In controlled environments that share many things it makes sense
to have deployable toolchain files instead.

> Basically, some things I like to determine programmatically. Putting
> in them in the toolchain file violates the "introspection" rule, but
> also results in code duplication

Toolchain files can `include()` other files from next to them.  That
can be used to avoid duplicate code.

The only information you need within your toolchain file logic to
compute CMAKE_ANDROID_NDK_DEPRECATED_HEADERS is CMAKE_ANDROID_NDK.
If you add logic to find/require CMAKE_ANDROID_NDK up front then you
can check its version.

CMake's `Modules/Platform/Android-Determine.cmake` file has very little
logic to choose `CMAKE_ANDROID_NDK` if it is not set by the user.  You
can either duplicate this in a toolchain file helper or take advantage
of knowledge about your controlled environments to have a shorter version.

-Brad



More information about the cmake-developers mailing list