Using CMake on Windows
The latest CMake release may be installed by any one of:
- WinGet:
winget install Kitware.CMake
- Python:
pip install cmake
Using CMake
The CMake build process is the same across operating systems and compilers:
- configure: This is normally run only once unless making major project changes.
- build: This is the command run each time you make a change to the project code.
- install (optional): Put the binary artifacts into a convenient directory like /bin or /lib
cmake -S myproj -B myproj/build
cmake --build myproj/build
cmake --install myproj/build
CMake Generator
On Windows, CMake defaults to Visual Studio and Nmake, which may not work on some projects. Ninja build system with CMake is generally faster to build and particularly rebuild regardless of operating system. Ninja on Windows solves numerous issues vs. GNU Make. Ninja works with Visual Studio as well.
Override the default CMake generator by setting environment variable
CMAKE_GENERATOR=Ninja
CMAKE_GENERATOR
can be overridden (e.g. to use GNU Make from MSYS2) like:
cmake -G "MinGW Makefiles"
Older CMake on Windows may get the message below. Fix by upgrading to CMake ≥ 3.17.
sh.exe was found in your PATH, here:
C:/Program Files/Git/user/bin/sh.exe
For MinGW make to work correctly sh.exe must NOT be in your path.
Run cmake from a shell that does not have sh.exe in your PATH.
If you want to use a UNIX shell, then use MSYS Makefile