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

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 ...

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