Using Modern CMake Patterns to Enforce a Good Modular Design
Play Using Modern CMake Patterns to Enforce a Good Modular Design
CMake is the build system chosen by most open-source C++ projects. While it is fully capable of helping you enforce a good modular design, those features are usually not well known or understood. In this talk I will present modern CMake practices that will simplify your project build and help you design better C++ components with clear dependencies and build interfaces (the sum of compile flags required to use a given library). We will first do a quick recap of the theory behind modular design, most of it coming from John Lakos' work on Large Scale C++ Software Development. Then we will see a few of the legacy CMake patterns that can be found in a lot of open source projects and explain their shortcomings. We will learn how to create a clean C++ library using modern CMake practices and depend on it in others modules. Finally, we will explore the options available to export the build interfaces for use by external projects. In this last part a few external tools will be discussed such as pkg-config and Conan.