DuneAddPybind11Module

Infrastructure for building Python extension modules with pybind11-style bindings.

dune_add_pybind11_module

Add a Python extension module as a shared library target.

dune_add_pybind11_module(
  NAME <module-name>
  [SOURCES <sources>...]
  [EXCLUDE_FROM_ALL]
  [COMPILE_DEFINITIONS <definitions>...]
  [CMAKE_GUARD <condition>...]
)
NAME

Name of the Python extension module target.

SOURCES

Source files used to build the shared library. If omitted, <NAME>.cc is used when that file exists in the current source directory.

EXCLUDE_FROM_ALL

Exclude the generated target from the default all target.

COMPILE_DEFINITIONS

Additional compile definitions passed to target_compile_definitions().

CMAKE_GUARD

Conditions evaluated before the module target is added. If one of the conditions evaluates to false, the target is skipped.

The generated target links against Dune::Common and Python3::Module and is configured with dune_target_enable_all_packages().

dune_add_pybind11_submodule

Add an object-library submodule and link it into an existing Python module.

dune_add_pybind11_submodule(
  MODULE <parent-module>
  NAME <submodule-name>
  SOURCES <sources>...
  [EXCLUDE_FROM_ALL]
  [COMPILE_DEFINITIONS <definitions>...]
  [CMAKE_GUARD <condition>...]
)
MODULE

Name of the previously created parent module target that receives the submodule object library.

NAME

Name of the object-library target providing the submodule sources.

SOURCES

Source files compiled into the object library.

EXCLUDE_FROM_ALL

Exclude the object-library target from the default all target.

COMPILE_DEFINITIONS

Additional compile definitions passed to target_compile_definitions().

CMAKE_GUARD

Conditions evaluated before the submodule target is added. If one of the conditions evaluates to false, the target is skipped.

The generated object library links against Dune::Common, is configured with dune_target_enable_all_packages(), and is linked into the parent module target specified by MODULE.