CMake fails with: "The C compiler '../cl.exe' is not able to compile a simple test program"

It turns out I have made a mistake.
Newer ninja versions work fine.
What was really the problem was a registry value I added that runs a script when cmd.exe is run and the fact that this script is broken caused cmd.exe to always return error code 1.
After deleting the value everything worked as expected both from the command line and Visual Studio.

I apologize for the confusion