Lesson 2 · Foundations
Install CMake
Install CMake 4.4 on Windows, macOS and Linux, and check it with one command. Takes two minutes.
Before anything else, install CMake. This lesson is short on purpose. The goal is a working cmake command in your terminal, nothing more.
Note
This tutorial targets CMake 4.4, the current stable release. Anything older than 3.15 will reject or mishandle the code here. When in doubt, install the latest 4.4.x.
Windows
- Go to cmake.org/download.
- Download the Windows x86_64 installer (
.msi). - Run it. Tick “Add CMake to the system PATH” so you can type
cmakein any terminal.
Tip
If you use Visual Studio, its “Desktop development with C++” workload includes CMake. But the standalone installer above gives you the newest version, which is what this tutorial needs.
macOS
brew install cmake
Linux
Debian / Ubuntusudo apt install cmake
Fedorasudo dnf install cmake
Archsudo pacman -S cmake
Pitfall
Distribution packages are often years behind. If your distro ships CMake older than 3.15, install the official binaries from cmake.org/download instead.
Check the installation
cmake --version
You should see something like:
cmake version 4.4.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
The first line is what matters, cmake version 4.4.x. If you see that, you are ready.
What else you need
CMake only generates build files. It does not compile, so you also need a compiler:
- Windows. Visual Studio 2022 (Community is free), with the “Desktop development with C++” workload.
- macOS.
xcode-select --installinstalls the command-line tools including clang. - Linux.
sudo apt install build-essential(gcc and make), orsudo dnf groupinstall "Development Tools".
You will also install the Ninja build tool in lesson 21. It is optional for now, but it makes every build faster.
Why
CMake plus a compiler plus a build tool (make or Ninja) is the complete toolchain. CMake generates, the build tool compiles, the compiler produces the program. You have all three after this lesson.