Usage
Given that you have installed tolc
you should be able to use the CMake
interface.
Via CMake
tolc_create_bindings
Example usage:
tolc_create_bindings(
TARGET MyLib
LANGUAGE python
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/python-bindings
)
This will create a new target called MyLib_python
which, when built and available, will be importable from python
as import MyLib
. The generated python
library will be available under ${CMAKE_CURRENT_BINARY_DIR}/tolc
, typically build/tolc
. To import it, start a python
session from the same directory as the built library and import it as you would any other library.
An overview of the internal process is described below:
- Find and combine all public header files based on include directories marked
PUBLIC
inCMake
for targetMyLib
. - Let
tolc
read the combined header and generate the bindings (in this case they will be available under${CMAKE_CURRENT_BINARY_DIR}/python-bindings
). - Download and make
pybind11
available. - Create the target
MyLib_python
and link it topybind11
aswell asMyLib
.