Modern CMake C++ SWIG Sample
OS | C++ | Python | Java | .NET |
---|---|---|---|---|
Linux | ||||
macOS | ||||
Windows |
This is a complete example of how to create a Modern CMake C++ Project with the SWIG code generator to generate wrapper and package for Python, .Net and Java.
This project should run on GNU/Linux, MacOS and Windows.
You can find detailed documentation for C++, Swig, Python 3, .Net Core and Java.
note: You should read C++ and Swig first since since other languages are just swig generated wrappers from the C++.
You'll need:
The project layout is as follow:
CMakeLists.txt Top-level for CMake based build.
cmake Subsidiary CMake files.
ci Root directory for continuous integration.
Foo Root directory for Foo
library.
Foo
.Foo
Python.Foo
.Net.Foo
Java.Bar Root directory for Bar
library.
Bar
.Bar
Python.Bar
.Net.Bar
Java.FooBar Root directory for FooBar
library.
FooBar
.FooBar
Python.FooBar
.Net.FooBar
Java.FooBarApp Root directory for FooBarApp
executable.
FooBarApp
.python Root directory for Python template files
setup.py.in
setup.py template for the Python native package.dotnet Root directory for .Net template files
java Root directory for Java template files
To complexify a little, the CMake project is composed of three libraries (Foo, Bar and FooBar) with the following dependencies:
Foo:
Bar:
FooBar: PUBLIC Foo PRIVATE Bar
To build the C++ project, as usual:
cmake -S. -Bbuild
cmake --build build
Few links on the subject...
Project layout:
CMake:
Python:
.Net:
Some issue related to this process
Image has been generated using plantuml:
plantuml -Tsvg docs/{file}.dot
So you can find the dot source files in docs.
Apache 2. See the LICENSE file for details.
This is not an official Google product, it is just code that happens to be owned by Google.