These are the steps to follow in our CMakeLists.txt:
- The first block contains the minimum CMake version, project name, and required language:
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)project(recipe-02 LANGUAGES C)
- In this recipe we enforce the use of the C99 standard for C. This is not strictly required for linking with Python, but is something you might want to have in place:
set(CMAKE_C_STANDARD 99)set(CMAKE_C_EXTENSIONS OFF)set(CMAKE_C_STANDARD_REQUIRED ON)
- Find the Python interpreter. This is now a required dependency:
find_package(PythonInterp REQUIRED)
- Find the Python header and library. The appropriate module is called FindPythonLibs.cmake:
find_package(PythonLibs ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} ...