Chapter 4: Working with Targets
The most basic target we can build in CMake is a single binary executable file that encompasses an entire application. It can be made out of a single piece of source code, such as the classic helloworld.cpp
. Or it can be something complex – built with hundreds or even tens of thousands of files. This is what many beginner projects look like – create a binary with one source file, add another, and, before you know it, everything is linked to a single binary without any structure whatsoever.
As software developers, we deliberately draw boundaries and designate components to group one or more units of translation (.cpp
files). We do it for multiple reasons: to increase code readability, manage coupling and connascence, speed up the build process, and finally, extract the reusable components.
Every project that is big enough will push you to introduce some form of partitioning. A target in CMake is an answer to exactly that problem ...