Professional CMake:

A Practical Guide

Structured learning, best practice and real world advice direct from a CMake co-maintainer

Production Focused

Professional CMake: A Practical Guide is the handbook for every CMake user, from beginner to seasoned veteran. It contains hundreds of pages of real-world advice, best practices, and insights gained from production projects and interaction with the CMake community.

Topics cover the complete software pipeline, from the very initial setup of a project through to testing, packaging, and integration with other projects. Important more advanced topics like improving build performance and code analysis tools are also covered.

Free Getting Started Guide

The first five chapters of the book form the Getting Started guide. It covers the basics of using CMake, introducing the essential aspects of defining, building, testing, installing, and packaging a simple CMake project. The guide is an ideal introduction for developers new to CMake. And the best part is, it is available for free!

This free download also includes the full table of contents for the whole book, so it gives an excellent taste of what to expect for the rest of the book’s other chapters.

Flexible Learning

Apart from the Getting Start guide, the book consists of a few other parts. The Fundamentals part covers the important topics every CMake developer should learn, while the remaining parts are more focused on specific topics. The reader can work through the Fundamentals chapters to build a solid foundation, then pick out chapters from the rest of the book on a more as-needed basis. Each chapter focuses on a particular theme or fundamental concept, so each one acts like a mini CMake tutorial on that topic. Every chapter also ends with a Recommended Practices section highlighting the most important points (great for those with limited time!).

Regular Updates

A new edition of the book is typically published sometime after each CMake feature release. Every purchase includes access to all future editions at no extra cost, so you can always stay up-to-date. The latest version of the book is the 18th Edition, which covers up to CMake 3.29.

The book is provided in digital form only (PDF and EPUB)



Buying on behalf of someone else? Want to bulk buy multiple copies with up to 76% discount? Purchase coupon codes instead…


Table Of Contents

Part I: Getting Started

  1. Introduction
  2. Setting Up A Project
  3. A Minimal Project
  4. Building Simple Targets
  5. Basic Testing And Deployment

Part II: Fundamentals

  1. Variables
  2. Flow Control
  3. Using Subdirectories
  4. Functions And Macros
  5. Properties
  6. Generator Expressions
  7. Modules
  8. Policies
  9. Debugging And Diagnostics
  10. Build Type
  11. Compiler And Linker Essentials

Part III: Builds In Depth

  1. Language Requirements
  2. Advanced Linking
  3. Target Types
  4. Custom Tasks
  5. Working With Files
  6. Specifying Version Details
  7. Libraries
  8. Toolchains And Cross Compiling
  9. Apple Features
  10. Build Performance

Part IV: Testing And Analysis

  1. Testing Fundamentals
  2. Test Resources And Constraints
  3. Build And Test Mode
  4. Test Frameworks
  5. CDash Integration
  6. Static Code Analysis
  7. Dynamic Code Analysis

Part V: Deployment And Dependencies

  1. Finding Things
  2. Installing
  3. Packaging
  4. Package Generators
  5. ExternalProject
  6. FetchContent
  7. Making Projects Consumable
  8. Dependency Providers

Part VI: Project Organization

  1. Presets
  2. Project Structure

Part VII: Special Topics

  1. Working With Qt


CMake is a very popular tool for defining how projects should be built, tested and packaged. Its maturity, breadth of features, broad platform support and toolchain flexibility have led to its widespread adoption among the software development community. It has even become the de facto standard build system for C++ projects. The CMake 3.x release series has brought with it a whole new set of powerful capabilities and best practices, leading to the coining of the term Modern CMake. But “modern” is a moving target. Therefore, a key motivation for this book is to provide developers with an up-to-date, practical guide to learning CMake, paying particular attention to the latest best practices.

Part I: Getting Started

The first part of the book covers the essential steps for getting up and running quickly with a basic project. It assumes no prior experience with CMake. It introduces the reader to the most pivotal CMake concepts (especially targets) and each of the main tools: cmake, ctest and cpack. It also points out a few common things for new users to avoid. By the end of this section, the reader will have a basic working project they can use to explore and experiment with as they build their knowledge through the rest of the book.

Part II: Fundamentals

The chapters in this part of the book cover fundamental concepts and CMake features that will be used extensively by most projects. As the reader works through each chapter and gains familiarity with each new topic, they will be able to do progressively more with their own projects and those of others. These chapters cover the real bread-and-butter of CMake! The last chapter in this part, Compiler And Linker Essentials, contains some of the most important material in the whole book.

Part III: Builds In Depth

This part of the book goes into much greater detail about various key areas associated with building a CMake project. The chapters take on a more task-focused flavor, allowing the developer to skip around and gain knowledge about the specific areas most relevant to their own projects. The Build Performance chapter is especially likely to be a popular read, covering material that can potentially lead to drastic reductions in build times, and more efficient use of build resources.

Some chapters go even deeper than discussing CMake alone. Topics covered include advanced linking techniques, how to structure libraries, managing versioning across platforms, and an in-depth treatment of Apple-specific technologies such as bundles, frameworks and code signing.

The many recommended practices in this part of the book demonstrate how developers can get the most out of CMake’s extensive feature set. They also draw attention to a number of common but discouraged practices and explain why they should be avoided.

Part IV: Testing And Analysis

CMake provides extensive support for testing projects. The first chapter in this part of the book teaches the most important knowledge about these features up front. Subsequent chapters then focus on specific areas of CMake’s testing functionality. Again, the reader can skip around the later chapters after getting a good grounding in the Testing Fundamentals chapter.

The two code analysis chapters in this part of the book are also sure to be popular. They bring the power and confidence of a variety of analysis tools and techniques to CMake projects. CMake’s direct support for clang-tidy, cppcheck, cpplint and include-what-you-use is explained. This is complemented by the material on sanitizers and code coverage, which brings together much hard-won and scattered knowledge into a single, coherent place. A complete working sanitizers example is also included at the end of the book as an appendix.

Part V: Deployment And Dependencies

Developers often find the deployment and dependency handling aspects of software development difficult. This part of the book equips the reader with the knowledge needed to get the most out of what CMake offers for these closely related areas. It gives detailed instructions for how to define what a project installs, how to assemble those artifacts into packages in various formats, how to export CMake-specific package details for other projects to consume, and more. It also equips the reader with the knowledge to choose between and implement the most appropriate way to consume other projects as dependencies.

Part VI: Project Organization

This part of the book deals with more high-level aspects of a CMake project. It covers the important topic of CMake presets, which are proving to be very popular with developers as a way of simplifying their day-to-day workflow. It also covers how to structure a project, laying out recommendations and advice that give production-scale projects a solid foundation for maintainability and growth.

Part VII: Special Topics

The final part of the book contains a chapter dedicated to the special area of Qt support. It includes discussion of features provided by both CMake and Qt, covering topics including moc, uic and rcc support, translation handling and using Qt’s deployment tools.

Frequently Asked Questions

Can I copy the book to read on my various devices?

Yes, you are free to make copies for your own personal use. The copyright message from the book states the following:

  • The original purchaser may make personal copies exclusively for their own use on their electronic devices. All reasonable steps must be taken to ensure that only the original purchaser has access to such copies.
  • Permission is given to use any of the code samples in this work without restriction. Attribution is not required.

Can I purchase a printed version?

The book is only available in electronic form at this time. Buyers are permitted to print their own personal copy if they so wish.

Is the book available from other places like Safari Books Online, Amazon, etc.?

The book may only be purchased directly from the Crascit website.

Is there any other freely available material by the same author?

This site contains a number of CMake blog articles by the same author. Some of the more popular ones include:

The author’s talk at CppCon 2019 also provides a taste of the sort of material the book covers.

I’ve lost my order details or download link. How can I recover them?

If you have misplaced your original order confirmation email with the download link, you can visit this link to have it resent to you. Note that you must use the same email address as the original order.