casadi/casadi — pull request #861 by toivoh (2013-10-23 09:36:51+00:00)
Title: First attempt to make CasADi usable as a dependency for external SWIG modules

When doing `%import "casadi.i"`, some things follow along that probably shouldn't.
This patch
* Adds a define `-DCASADI_MODULE` in `swig/CMakeLists.txt` that is in effect when CasADi builds its SWIG wrappers, but should not be defined in other modules.
* Adds `#ifdef CASADI_MODULE` to exclude a few things when in another module:
* Typemaps on non-CasADi types: `int, double, vector, vector`
* `%exception` directives: they depend on a CasADi-internal flag, define macros `START` and `STOP` that are likely to conflict with existing symbols, and also depend on `exception.i`.

With this patch, I am able to create a standalone SWIG module for my code that uses the CasADi SWIG module as a dependency through `casadi.i`. I hope that either it can be accepted, or changes can be made to the same effect.

Note: Additionally, when using `%import "casadi"` in another module, standard includes like `std_vector.i` and `exception.i` that should be included in the module must be included before `%import "casadi"`, since their inclusion from within the imported `casadi.i` will otherwise cause them to be imported instead.