diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2021-08-24 09:20:03 -0700 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2021-09-24 22:56:46 +0300 |
commit | 68c23a61203fc35dd11c7a0b1cc13f7cc2c5cf8c (patch) | |
tree | 5afe315e41b55e8b12f3b1b56d75bfd766620cae /docs/markdown/Cython.md | |
parent | 524a95fa62a6e0cb77e53d7b38d5c2d59a75e449 (diff) | |
download | meson-68c23a61203fc35dd11c7a0b1cc13f7cc2c5cf8c.zip meson-68c23a61203fc35dd11c7a0b1cc13f7cc2c5cf8c.tar.gz meson-68c23a61203fc35dd11c7a0b1cc13f7cc2c5cf8c.tar.bz2 |
Add option to to transpile Cython to C++
This patch adds a new meson built-in option for cython, allowing it to
target C++ instead of C as the intermediate language. This can, of
course, be done on a per-target basis using the `override_options`
keyword argument, or for the entire project in the project function.
There are some things in this patch that are less than ideal. One of
them is that we have to add compilers in the build layer, but there
isn't a better place to do it because of per target override_options.
There's also some design differences between Meson and setuptools, in
that Meson only allows options on a per-target rather than a per-file
granularity.
Fixes #9015
Diffstat (limited to 'docs/markdown/Cython.md')
-rw-r--r-- | docs/markdown/Cython.md | 29 |
1 files changed, 29 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, +) +``` |