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. In recent years, the 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. One of the key motivations for this book is to provide developers with an up-to-date, practical guide to learning CMake, paying particular attention to these more modern practices. As a CMake tutorial, it follows a logical sequence from basic concepts through to more advanced topics. For the more experienced user, the chapter structure allows the reader to quickly focus in on a particular area of interest.

The first part of the book introduces each of the fundamental areas of CMake. These early chapters are arranged to get the reader up and running quickly with a basic project, then progressively build up an understanding of CMake’s core concepts in manageable, structured units. These chapters not only present the key concepts, they also shape the reader’s understanding of how CMake can be used most effectively and how to avoid common pitfalls.

The middle part of the book goes into much greater detail about various key areas and has a more task-focused flavor. Much of the material addresses everyday problems frequently faced by developers, while many of the chapters cover features that are new or improved in the 3.x release series. Some chapters go even deeper than discussing CMake alone and cover topics such as 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 these chapters 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.