This is an example for compiling a C++ library using CMake and either pybind11 or emscripten. It also provides an example of its usage on a html page and a python module.
sudo apt-get install emscripten
emcmake cmake -B build/ -DTARGET_TYPE="javascript"
cmake --build build/
pip3 install "pybind11[global]"
cmake -B build/ -DTARGET_TYPE="python"
cmake --build build/
Just start a web server on this directory and navigate to host:port/index.html
.
Move the compiled library and run main.py
.
mv build/binding.<ext> binding.<ext>
python3 main.py