Reader small image

You're reading from  Modern CMake for C++

Product typeBook
Published inFeb 2022
PublisherPackt
ISBN-139781801070058
Edition1st Edition
Tools
Right arrow
Author (1)
Rafał Świdziński
Rafał Świdziński
author image
Rafał Świdziński

Rafał Świdziński works as a staff engineer at Google. With over 10 years of professional experience as a full stack developer, he has been able to experiment with a vast multitude of programming languages and technologies. During this time, he has been building software under his own company and for corporations including Cisco Meraki, Amazon, and Ericsson. Originally from Łódź, Poland, he now lives in London, UK, from where he runs a YouTube channel, "Smok," discussing topics related to software development. He tackles technical problems, including real-life and work-related challenges encountered by many people in the field. Throughout his work, he explains the technical concepts in detail and demystifies the art and science behind the role of software engineer. His primary focus is on high-quality code and the craftsmanship of programming.
Read more about Rafał Świdziński

Right arrow

Exporting without installation

How can we make the targets of 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. It's better to achieve this by providing a target export file that the consuming project, B, can include with the include() command:

cmake_minimum_required(VERSION 3.20.0)
project(B)
include(/path...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Modern CMake for C++
Published in: Feb 2022Publisher: PacktISBN-13: 9781801070058

Author (1)

author image
Rafał Świdziński

Rafał Świdziński works as a staff engineer at Google. With over 10 years of professional experience as a full stack developer, he has been able to experiment with a vast multitude of programming languages and technologies. During this time, he has been building software under his own company and for corporations including Cisco Meraki, Amazon, and Ericsson. Originally from Łódź, Poland, he now lives in London, UK, from where he runs a YouTube channel, "Smok," discussing topics related to software development. He tackles technical problems, including real-life and work-related challenges encountered by many people in the field. Throughout his work, he explains the technical concepts in detail and demystifies the art and science behind the role of software engineer. His primary focus is on high-quality code and the craftsmanship of programming.
Read more about Rafał Świdziński