An open API service indexing awesome lists of open source software.

https://github.com/danielunderwood/swig-example

An example for using CMake with the SWIG code generator
https://github.com/danielunderwood/swig-example

cpp python swig swig-binding

Last synced: 7 days ago
JSON representation

An example for using CMake with the SWIG code generator

Awesome Lists containing this project

README

          

# SWIG Example

This is an example of how to use CMake with the [SWIG](http://www.swig.org) interface generator. It is meant for those
interested to use as a guide to setting up a project built by CMake with interfaces in other languages generated by
SWIG.

## Getting Started

### Docker

If you have docker installed, the following should get you started with a sample environment

```shell
$ docker build -t swig-example .
$ docker run --name swig-example -it swig-example
$ # Now in container
# python swig/python/test.py
```

### Local Build
To build locally, the following should be installed:
- cmake
- swig
- python Headers (python-dev for debian-based systems)

It can then be built and run with

```shell
$ # Build libraries
$ mkdir build && cd build
$ cmake ..
$ make -j4
$ # Note that this currently installs in /usr/lib, which isn't ideal
$ make install
$ make install-python
$ # Go back to root dir to run
$ cd ..
$ python swig/python/test.sh
```

## Languages
This example currently generates interfaces for the following languages:

* Python

I will add languages as I need to use them. Anyone that wishes to add another language, feel free to open a pull request
and let me know if there are any issues with using the installation procedure described below with your language.