This workshop has moved! New address:

More Modern CMake

This site has been moved to the HSF training page!

Welcome to the FIRST-HEP CMake tutorial! The aim of this tutorial is to cover the basics of using CMake. This tutorial is based on the online book Modern CMake, with a focus on CMake 3.14+. This is in what is called the “More Modern” era of CMake (which is 3.12+), and includes the fantastic command line improvements in CMake π (notes for 3.11+ compatible features will be included usually). We will cover the basics of making and building a project, and some details of design.

First taught at the 2019 USATLAS Computing Bootcamp at LBNL.


On your computer, you need to have:

  • git
  • cmake (Version 3.14 or newer). See the instructions here.
  • A C++ compiler - system default is fine.
  • make or ninja

A quick and minimal docker works well, too:

docker run --rm -it alpine
apk add git g++ cmake make
git clone
cd cmake_workshop

This does not make a volume, so you will lose whatever you do in here when it exits - that’s probably a good thing mostly.


Setup Download files required for the lesson
00:00 1. Introduction What is CMake, anyway?
What is the difference between a build system and a build system generator?
00:10 2. Building with CMake How do I build a project?
00:30 3. Your first CMakeLists.txt file How little can I get away with in my CMakeLists?
00:50 4. Working with Targets How do targets work?
01:15 5. Variables explained How do variables work?
01:35 6. Project Structure What should my project look like?
01:55 7. Common Problems and Solutions What could go possibly wrong?
02:00 8. Debugging How do I debug everything?
02:20 9. Finding Packages How do I search for packages?
02:30 10. ROOT How do I use ROOT?
02:50 11. Functions in CMake How do I write my own CMake commands?
03:00 Finish

The actual schedule may vary slightly depending on the topics and exercises chosen by the instructor.