diff options
Diffstat (limited to 'docs/markdown')
-rw-r--r-- | docs/markdown/Cython.md | 29 | ||||
-rw-r--r-- | docs/markdown/snippets/cython-c++-intermediate.md | 22 |
2 files changed, 51 insertions, 0 deletions
diff --git a/docs/markdown/Cython.md b/docs/markdown/Cython.md index 1d30c1f..3042750 100644 --- a/docs/markdown/Cython.md +++ b/docs/markdown/Cython.md @@ -31,3 +31,32 @@ py.extension_module( dependencies : dep_py, ) ``` + +## C++ intermediate support + +*(New in 0.60.0)* + +An option has been added to control this, called `cython_language`. This can be +either `'c'` or `'cpp'`. + +For those coming from setuptools/distutils, they will find two things. First, +meson ignores `# distutils: language = c++` inline directives. Second that Meson +allows options only on a per-target granularity. This means that if you need to mix +cython files being transpiled to C and to C++ you need two targets: + +```meson +project('my project', 'cython') + +cython_cpp_lib = static_library( + 'helper_lib', + 'foo_cpp.pyx', # will be transpiled to C++ + override_options : ['cython_language=cpp'], +) + +py.extension_module( + 'foo', + 'foo.pyx', # will be transpiled to C + link_with : [cython_cpp_lib], + dependencies : dep_py, +) +``` diff --git a/docs/markdown/snippets/cython-c++-intermediate.md b/docs/markdown/snippets/cython-c++-intermediate.md new file mode 100644 index 0000000..0a1c35f --- /dev/null +++ b/docs/markdown/snippets/cython-c++-intermediate.md @@ -0,0 +1,22 @@ +## Cython can now transpile to C++ as an intermediate language + +Built-in cython support currently only allows C as an intermediate language, now +C++ is also allowed. This can be set via the `cython_language` option, either on +the command line, or in the meson.build files. + +```meson +project( + 'myproject', + 'cython', + default_options : ['cython_language=cpp'], +) +``` + +or on a per target basis with: +```meson +python.extension_module( + 'mod', + 'mod.pyx', + override_options : ['cython_language=cpp'], +) +``` |