Visual Studio Android support with recent NDK

Has anyone attempted to use the new Visual Studio NDK support with a NDK more recent than what comes with Visual Studio (which is ancient r16)? I’ve been trying to get this working for a while now and with the changes made on CMake master and NDK master recently, it should work. In my testing, I can get Ninja to work with a continuous build of NDK from today (see here) and CMake master, but using the Visual Studio generator, it fails at the compiler check stage. It seems like the LLVM compilers from Visual Studio are being used instead of the ones from the NDK, but I can’t be sure since there’s a few levels of compiler flags involved which may be forwarding things on. Here’s an example command line I’ve been using:

cmake -G "Visual Studio 16" -A ARM64 -DCMAKE_TOOLCHAIN_FILE:FILEPATH=path/to/my/toolchain.cmake path/to/project/source/dir

The -A ARM64 is a bit of an experiment. It fails with or without it. The contents of my toolchain file are pretty straightforward:

set(CMAKE_ANDROID_NDK C:/Users/craig/AppData/Local/Android/Sdk/ndk/23.0.7045647)  # My copy of the continuous build
set(CMAKE_ANDROID_STL_TYPE c++_shared)

Here’s the CMakeError.log and CMakeOutput.log from the above setup:

CMakeError.log (22.3 KB) CMakeOutput.log (1.6 KB)

I will also point out that the output in CMakeError.log shows that Visual Studio is ignoring CMAKE_ANDROID_NDK and is setting the NDK_ROOT environment variable to the value providing in the Visual Studio settings under the Tools > Options… > Cross Platform > C++ > Android settings. But even if I update those settings to match my desired NDK root, it still fails.

Just curious if I’m missing something or whether the Visual Studio support for NDK is not actually finished work.

CC: @kyle.edwards @brad.king

The VS Android support from MR 4898 and the NDK/CMake integration work that resolved NDK issue 463 (with several MRs on the CMake side, some of which are mentioned here) were independent efforts. I don’t think anyone has tried to combine them yet, and no one is currently working on it AFAIK. You could open a new issue to track that.