Cython

Find cython executable.

This module will set the following variables in your project:

CYTHON_EXECUTABLE
path to the cython program
CYTHON_VERSION
version of cython
CYTHON_FOUND
true if the program was found

For more information on the Cython project, see http://cython.org/.

Cython is a language that makes writing C extensions for the Python language as easy as Python itself.

The following functions are defined:

add_cython_target

Create a custom rule to generate the source code for a Python extension module using cython.

add_cython_target(<Name> [<CythonInput>]
[EMBED_MAIN] [C | CXX] [PY2 | PY3] [OUTPUT_VAR <OutputVar>])

<Name> is the name of the new target, and <CythonInput> is the path to a cython source file. Note that, despite the name, no new targets are created by this function. Instead, see OUTPUT_VAR for retrieving the path to the generated source for subsequent targets.

If only <Name> is provided, and it ends in the ”.pyx” extension, then it is assumed to be the <CythonInput>. The name of the input without the extension is used as the target name. If only <Name> is provided, and it does not end in the ”.pyx” extension, then the <CythonInput> is assumed to be <Name>.pyx.

The Cython include search path is amended with any entries found in the INCLUDE_DIRECTORIES property of the directory containing the <CythonInput> file. Use iunclude_directories to add to the Cython include search path.

Options:

EMBED_MAIN
Embed a main() function in the generated output (for stand-alone applications that initialize their own Python runtime).
C | CXX
Force the generation of either a C or C++ file. By default, a C file is generated, unless the C language is not enabled for the project; in this case, a C++ file is generated by default.
PY2 | PY3
Force compilation using either Python-2 or Python-3 syntax and code semantics. By default, Python-2 syntax and semantics are used if the major version of Python found is 2. Otherwise, Python-3 syntax and sematics are used.
OUTPUT_VAR <OutputVar>
Set the variable <OutputVar> in the parent scope to the path to the generated source file. By default, <Name> is used as the output variable name.

Defined variables:

<OutputVar>
The path of the generated source file.

Cache variables that effect the behavior include:

CYTHON_ANNOTATE
whether to create an annotated .html file when compiling
CYTHON_FLAGS
additional flags to pass to the Cython compiler

Example usage

find_package(Cython)

# Note: In this case, either one of these arguments may be omitted; their
# value would have been inferred from that of the other.
add_cython_target(cy_code cy_code.pyx)

add_library(cy_code MODULE ${cy_code})
target_link_libraries(cy_code ...)