This lesson is being piloted (Beta version)

More Modern CMake

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.11+. This is almost what is called the “More Modern” era of CMake (which is 3.12+). We will cover the basics of making and building a project, and some details of design.

Prereqs

On your computer, you need to have:

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

Note that the ATLAS docker container has all of these things already.

docker run --rm -it atlas/analysisbase:21.2.75 bash
source release_setup.sh
git clone https://github.com/henryiii/cmake_workshop.git
cd cmake_workshop

A quick and minimal docker works too:

docker run --rm -it alpine
apk add git g++ cmake make
git clone https://github.com/henryiii/cmake_workshop.git
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.

Schedule

Setup Download files required for the lesson
00:00 1. Introduction What is CMake, anyway?
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.