CMake tries to determine the host target triple for the build by checking the value of CMAKE_CL_64. The value of this variable is tied to the CMake generator, and not the toolchain in use. In particular, it is only set to 1 when a generator of the form "Visual Studio <n> Win64" is used. This means that it doesn't work for the Ninja generator, and will always give you a host triple of i686-pc-win32 even when compiling with a 64-bit toolchain.
This patch addresses this by running ${CMAKE_CXX_COMPILER} when MSVC is detected, and parsing its output to determine the architecture that it claims it targets, and then choosing the target triple accordingly.