Pseudo Targets
Explore the concept of pseudo targets in CMake, including imported, alias, and interface libraries. Understand their roles in managing external dependencies, creating logical interface targets, and optimizing build processes. This lesson helps you use these constructs effectively to build cleaner and more maintainable C++ projects.
We'll cover the following...
Meet the pseudo targets
The concept of a target is so useful that it would be great if some of its behaviors could be borrowed for other things too. This is, specifically, things that do not represent outputs of the buildsystem but rather inputs—external dependencies, aliases, and so on. These are the pseudo targets, or targets that don't make it to the generated buildsystem.
Imported targets
We'll now talk about how CMake manages external dependencies—other projects, libraries, and so on. IMPORTED targets are essentially products of this process. CMake can define them as a result of the find_ package() command.
We can adjust the target properties of such a target: compile definitions, compile options, include directories, and so on—and they will even support transitive usage requirements. However, we should treat them as immutable; don't change their sources or dependencies.
The scope of the definition of an IMPORTED target can be global or local to the directory where it was defined (visible in subdirectories but not in parent directories). ...