There is more

Clients of the message library are now very happy since they can finally install the library on their system and have CMake discover it for them with minimal modifications to their own CMakeLists.txt:

find_package(message VERSION 1 REQUIRED)

Clients can now configure their project with the following:

$ cmake -Dmessage_DIR=/path/to/message/share/cmake/message ..

The tests included with our example show how to check that the installation of the targets went according to plan. Looking at the structure of the tests folder we notice the use_target subdirectory:

tests/├── CMakeLists.txt└── use_target    ├── CMakeLists.txt    └── use_message.cpp

This directory contains a small project that uses the exported targets. The interesting part ...

Get CMake Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.