How to do it

Let us first go through the root CMakeLists.txt file:

  1. We start, as usual, by requiring a minimum CMake version and defining a C++11 project. Note that we have set a version for our project with the VERSION keyword to the project command:
# CMake 3.6 needed for IMPORTED_TARGET option# to pkg_search_modulecmake_minimum_required(VERSION 3.6 FATAL_ERROR)
project(recipe-01  LANGUAGES CXX  VERSION 1.0.0  )# <<< General set up >>>set(CMAKE_CXX_STANDARD 11)set(CMAKE_CXX_EXTENSIONS OFF)set(CMAKE_CXX_STANDARD_REQUIRED ON)
  1. The user can define the installation prefix by means of the CMAKE_INSTALL_PREFIX variable. CMake will set a sensible default for this variable: /usr/local on Unix and C:\Program Files on Windows, respectively. We print ...

Get CMake Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.