The typical method of building a project that uses CMake is a bit different on Windows.
Create a subdirectory in the project directory named
Open a command prompt in the build directory and type
In the CMake GUI, click Configure. Choose the Visual Studio version you want to use and build for.
Have a look at the CMake variables marked in red. Remember that many of these variables might be filled using your environment variables. If you find that something is not set or set incorrectly, it might be due to a wrong value in one of your environment variables. Sometimes, the build will not succeed if one of these variables is not set correctly.
Take note of the variable
CMAKE_INSTALL_PREFIX. On Linux, the build results are installed to standard locations like
/usr/include. On Windows, the results of the build will be installed to the directory in
CMAKE_INSTALL_PREFIX. If you do not like its default location, set it to something else.
Click Configure again, to allow CMake get the right values. It typically needs two clicks of Configure.
Click Generate to generate the Visual Studio solution file. It will be placed in the
Open the generated Visual Studio solution file. If your
CMAKE_INSTALL_PREFIX was a system directory, like
C:\Program Files, you will need to open this solution file as Administrator.
The solution file might have one or many projects. The two main projects that concern us is
ALL_BUILD project in both Release and Debug modes.
To install the header files, libraries and executables generated to the location pointed to in
CMAKE_INSTALL_PREFIX, build the
INSTALL project in both Release and Debug mode. If you get an error here, it typically means that you are running Visual Studio as normal user, who does not have permissions to place these files in a directory that needs Administrator permissions.
That is it. You have built a CMake project on Windows :)