ABSTRACT

The process of building and installing a project from source can vary in complexity from one person’s computer to another, which makes it difficult to share and distribute code. CMake is a program that helps to solve the issue of cross-platform development by providing a way to build and install programs that are independent of a user’s compiler, operating system, and development environment. In short, CMake automates the generation of a Makefile that is customized for a user’s build environment, which he or she can use to build the project with make. In this chapter, we discuss the basics of using CMake to manage an example C++ project. First, we describe how to make and use CMakeLists. txt, the main input file needed by CMake to manage a project. We then show how CMake can be used to perform automated tasks, including the incorporation of version numbers into source code and the generation of customized header files. We then demonstrate how simple tests can be performed, along with system introspection that allows for conditional compilation.