Python And C++: How To Use Pybind11 With Cmakelists Including Gsl Libraries
I want to be able to call my C++ code as a python package. To do this I am using pybind11 with CMakelists (following this example https://github.com/pybind/cmake_example). My probl
Solution 1:
Function pybind11_add_module
creates a library target, which can be used for link added module with other libraries:
pybind11_add_module(namr ${SOURCES} "${SOURCE_DIR}/bindings.cpp")
target_link_libraries(namr PUBLIC GSL::gsl GSL::gslcblas)
This is explicitely stated in documentation:
This function behaves very much like CMake’s builtin
add_library
(in fact, it’s a wrapper function around that command). It will add a library target called<name>
to be built from the listed source files. In addition, it will take care of all the Python-specific compiler and linker flags as well as the OS- and Python-version-specific file extension. The produced target<name>
can be further manipulated with regular CMake commands.
Post a Comment for "Python And C++: How To Use Pybind11 With Cmakelists Including Gsl Libraries"