The latest CMake release may be installed in several ways. Without any additional programs, simply download and extract the CMake binary x64 .zip file and add the new cmake*/bin to the PATH environment variable. Python users may simply “pip install cmake”. macOS homebrew users can “brew install 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
On Windows, CMake defaults to Visual Studio and Nmake. This is usually not a useful default. We use the Ninja build system with CMake, which is generally faster on any 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 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:
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