Optimizing build performance
Apart from raw compilation time, the main driver for long build times in C++ projects is often unnecessary dependencies between the targets or files. If targets have unnecessary linking requirements between each other, the build system will be limited in executing build tasks in parallel and some of the targets will be frequently relinked. Creating a dependency graph of the targets, as described in Chapter 6, Automatically Generating Documentation, will help identify the dependencies. If the resulting graph looks more like a snarl of rope than a tree, optimizing and refactoring the project structure might bring a lot of performance gains. Tools such as include what you use and link what you use, as described in Chapter 7, Seamlessly Integrating Code Quality Tools with CMake, may further help identify unnecessary dependencies. Another common theme is C or C++ projects that expose too much private information in public headers, often causing frequent rebuilds...