I’d have to start looking into the CMake code at this point to find out why it’s unable to find visual studio in your terminal environments. But not via cmake-gui.
Perhaps you are setting something in your PATH or general environment variables that is confusing CMake?
That’s speculation at this point though. I’d have to look at the CMake source code.