Exporting Without Installation
Let's learn how to export the project without installation.
We'll cover the following
How can we make the targets of the project A
available to the consuming project B
? Usually, we'd reach for the find_package()
command, but that would mean that we'd need to create a package and install it on the system. That approach is useful, but it takes some work. Sometimes, we just need a really quick way to build a project and make its targets available for other projects.
We could save some time by including the main listfile of A
: it contains all the target definitions already. Unfortunately, it also potentially contains a lot of other things: global configuration, requirements, CMake commands with side effects, additional dependencies, and perhaps targets that we don't want in B
(such as unit tests). So, let's not do that.
Target export file
It's better to achieve this by providing a target export file that the consuming project, B
, can include with the include()
command:
Get hands-on with 1400+ tech skills courses.