How to do it

Let us look at how to generate the Python interface:

  1. Our CMakeLists.txt starts out defining the CMake dependency, project name, and language:
# define minimum cmake versioncmake_minimum_required(VERSION 3.5 FATAL_ERROR)# project name and supported languageproject(recipe-03 LANGUAGES CXX)# require C++11set(CMAKE_CXX_STANDARD 11)set(CMAKE_CXX_EXTENSIONS OFF)set(CMAKE_CXX_STANDARD_REQUIRED ON)
  1. On Windows, it is best not to keep the build type undefined, so that we can match the build type of this project with the build type of the Python environment. Here we default to the Release build type:
if(NOT CMAKE_BUILD_TYPE)  set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)endif()
  1. In this recipe, we will also require the ...

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.