You can start a specific VS Developer Command Prompt from the Start menu, or alternatively you can run CMD.EXE and set the necessary environment variables, e.g.:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
Then cmake and ninja must be run from this same command prompt. For the sake of convenience, I use the cmake (v3.12) that Microsoft ships with VS2017.