You should be able to do this by reusing the build command line shown in the VisualGDB build log (you can find the CMake parameters in View->Output->Advanced VisualGDB Project Output when opening the project), however you may need to setup some additional environment (e.g. cmake/ninja paths).
When I try build using C:\PROGRA~2\Sysprogs\VISUAL~1/ninja.exe command it work, but not work with downloaded ninja from https://ninja-build.org/.
Do you have a special version of ninja ?