Mixing C, C++, Fortran, and Python using Python CFFI

The code for this recipe is available at https://github.com/dev-cafe/cmake-cookbook/tree/v1.0/chapter-09/recipe-06 and has C++ and Fortran examples. The recipes are valid with CMake version 3.5 (and higher). Both versions of the recipe have been tested on GNU/Linux, macOS, and Windows.

In the previous three recipes, we have discussed Cython, Boost.Python, and pybind11 as tools to interface Python and C++ providing a modern and clean approach. The main interface in the previous recipes was a C++ interface. However, we may be in a situation where we do not have a C++ interface to hook on to and where we would like to interface Python with Fortran or other languages.

In this recipe, we will ...

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.