How to do it

Boost consists of many different libraries and these can be used almost independently from each other. Internally, CMake represents this library collection as a collection of components. The FindBoost.cmake module can search not only for the full installation of the library collection but also for particular components and their dependencies within the collection, if any. We will build up the corresponding CMakeLists.txt step by step:

  1. We first declare the minimum CMake version, project name, language, and enforce the use of the C++11 standard:
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)project(recipe-08 LANGUAGES CXX)set(CMAKE_CXX_STANDARD 11)set(CMAKE_CXX_EXTENSIONS OFF)set(CMAKE_CXX_STANDARD_REQUIRED ON)
  1. Then, we use ...

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.