What this book covers
Chapter 1, Kickstarting CMake, explains what CMake is in a nutshell, then jumps right into installing CMake and building something with CMake. You learn how to install the latest stable version manually, even if not provided by your package manager. You’ll also learn about the basic concepts behind CMake and why it is a build system generator and not a build system itself. Learn how it fits into modern software development with C++ (And C).
Chapter 2, Accessing CMake in the Best Ways, shows how to best use CMake from the command line, with a GUI and how CMake integrates into some of the common IDEs and Editors.
Chapter 3, Creating a CMake Project, takes you through setting up a project for building an executable, a library, and linking the two together.
Chapter 4, Packaging, Deploying, and Installing a CMake Project, will show you how to create a distributable version of your software project. You will learn how to add installation instructions and package the project using CMake and CPack (CMakes packaging program).
Chapter 5, Integrating Third-Party Libraries and Dependency Management, explains how to integrate existing 3rd-party libraries into your project. It also shows you how to add libraries already installed in your system, external CMake projects and non-CMake projects. This chapter covers CMakes depedency providers and gives a brief insight into using external package managers.
Chapter 6, Automatically Generating Documentation, explores how to generate documentation from your code with CMake as part of the build process with doxygen, dot (graphviz), and plantuml.
Chapter 7, Seamlessly Integrating Code Quality Tools with CMake, will show you how to integrate unit testing, code sanitizers, static code analysis and code coverage tools into your project. It will show you how CMake can help to discover and execute tests.
Chapter 8, Executing Custom Tasks with CMake, will explain how you can integrate almost any tool into your build process. You will learn how to wrap external programs into custom targets or hook into the build process to execute them. We will cover how custom tasks can be used to generate files and how they can consume files produced by other targets. You will also learn how to execute system commands during the configuration of the CMake build and how to create platform-agnostic commands using the CMake cscript mode.
Chapter 9, Creating Reproducible Build Environments, shows how you can build a portable environment between various machines including CI/CD pipelines. How to work with docker, sysroots, and CMake presets to make your build work “out of the box” everywhere.
Chapter 10, Handling Distributed Repositories and Dependencies in a Super-Build, simplifies managing projects that are distributed across multiple git repositories with CMake. You will learn how to create a super-build that allows you to build specific versions as well as the latest nightly builds. Explore what prerequisites it needs and how to combine them.
Chapter 11, Creating Software for Apple Systems, Because of the closed ecosystem, Apple platforms have some unique build characteristics, especially for applications with a graphical user interface and more complex library frameworks. For those cases Apple uses specific formats called app bundles and frameworks. In this chapter you will learn how to create these Apple-specific build artifacts and how to sign them for use in the App Store.
Chapter 12, Cross-Platform Compiling and Custom Toolchains, demonstrates how you can use a predefined cross-platform toolchains. You will also learn how to write your own toolchain definitions and conveniently use different toolchains with CMake.
Chapter 13, Reusing CMake Code, explains CMake Modules and how you can generalize your cmake files. You will learn how to write broadly used modules, which you can ship individually from your project.
Chapter 14, Optimizing and Maintaining CMake Projects, hints about how to get faster build times and tips and tricks for keeping a CMake project neat and tidy over a long period of time.
Chapter 15, Migrating to CMake, explains a high-level strategy on how to migrate a large existing codebase to CMake without the need to completely stop your development.
Appendix, Contributing to CMake and Further Reading Material, hints about where to go if you want to contribute, what is looked for, and basic contributing guidelines. It will also guide you on where to find additional in-depth information or more specific literature.