pybind11 setup and examples
Cmake settings
Discuss the setting in cmake only.1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22find_package(PythonLibs 3.6)
find_package(PythonInterp 3.6)
include_directories(${PYTHON_INCLUDE_DIRS})
...
set(PYBIND11_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/pybind11)
add_subdirectory(${PYBIND11_DIR}/ pybind11)
...
target_link_libraries(example_embed pybind11::embed)
# use link lib pybind11::embed to embed a python interpreter in you c++ code.
# if want to generate wrapper
pybind11_add_module(example_wrapper MODULE main.cpp)
target_link_libraries(example_wrapper PRIVATE pybind11::module)
set_target_properties(example_wrapper PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
SUFFIX "${PYTHON_MODULE_EXTENSION}")
#