O'Reilly logo

CMake Cookbook by Roberto Di Remigio, Radovan Bast

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it

We will begin with the root CMakeLists.txt:

  1. We declare a C++11 project as usual:
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)project(recipe-02 LANGUAGES CXX)set(CMAKE_CXX_STANDARD 11)set(CMAKE_CXX_EXTENSIONS OFF)set(CMAKE_CXX_STANDARD_REQUIRED ON)
  1. We set the EP_BASE directory property:
set_property(DIRECTORY PROPERTY EP_BASE ${CMAKE_BINARY_DIR}/subprojects)
  1. We set the STAGED_INSTALL_PREFIX variable. This directory will be used to install the dependencies within our build tree:
set(STAGED_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/stage)message(STATUS "${PROJECT_NAME} staged install: ${STAGED_INSTALL_PREFIX}")
  1. Our project needs the filesystem and system components of the Boost libraries. We declare a list variable to hold this ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required