generator Visual Studio 16 2019

I have a project and use the command to build it.

mkdir build
cd build
cmake -G "ninja" ^
		-DCMAKE_INSTALL_PREFIX=..\release ^
		-DCMAKE_BUILD_TYPE=Release
ninja -j12 install

Now I want to build it with Visual Studio 16 2019
How can I do next step? Except double click .sln method

mkdir build
cd build
cmake -G "Visual Studio 16 2019" ^
		-DCMAKE_INSTALL_PREFIX=..\release ^
		-DCMAKE_BUILD_TYPE=Release

The simplest way to build and install anything regardless of the generator is:
cmake --build . --target install from the build directory.

I want to assign PREFIX path for release library.
Should I duplicate declare PREFIX for cmake -G and cmake --install?

Should I duplicate declare build type for ( -DCMAKE_BUILD_TYPE and --config)

mkdir build
cd build
cmake -G "Visual Studio 16 2019" ^
		-DCMAKE_INSTALL_PREFIX=..\release ^
		-DCMAKE_BUILD_TYPE=Release
cmake --build . --target install --config Release
cmake --install . --config release --prefix ..\release

I don’t use multi-config generators at all, so I don’t really know how to deal with that.

CMAKE_BUILD_TYPE has no intrinsic meaning to multi-config generators. The project code can care, but it shouldn’t.

The following will work for either Visual Studio / Ninja

Writing your build script this way makes it easier to change your generator on the fly:

cmake -B build/ -D CMAKE_BUILD_TYPE=Release

cmake --build build/ --config Release

cmake --install build/ --config Release --prefix C:/release/

--config doesn’t do anything for Ninja

CMAKE_BUILD_TYPE doesn’t do anything for Visual Studio

Using them as shown above though should simplify your scripts though.