cython-cmake
raw JSON → 0.2.2 verified Fri May 01 auth: no python
CMake helpers for building Cython modules. Version 0.2.2, with monthly releases. Provides CMake modules to find Cython and compile Cython-generated C/C++ code into Python extension modules.
pip install cython-cmake Common errors
error CMake Error at FindCython.cmake:xxx (find_package): Could not find a package configuration file provided by "Cython" ↓
cause Cython is not installed or not found by CMake.
fix
Ensure Cython is installed (pip install cython) and that find_package can find it. Set Cython_DIR if necessary.
error ModuleNotFoundError: No module named 'Cython' ↓
cause Cython Python package is not installed.
fix
pip install cython or conda install cython.
error CMake Error at FindCython.cmake:xxx (find_package): Could not find Cython (missing: Cython_EXECUTABLE) ↓
cause CMake found Cython Python package but cannot locate the cython executable.
fix
Set Cython_EXECUTABLE to the path of the cython command, or rebuild with a complete Cython installation.
Warnings
breaking v0.2.0 renamed CMake targets and variables. Old FindCython.cmake targets (Cython::cython, Cython::cythonize) changed to Cython::Cython and Cython::Cythonize. ↓
fix Update CMake code to reference Cython::Cython and Cython::Cythonize instead of old names.
breaking v0.2.0 changed how to include CMake modules. Previously modules were installed site-wide; now they must be fetched via FetchContent or vendored. ↓
fix Use FetchContent to download cython-cmake and append its cmake directory to CMAKE_MODULE_PATH.
gotcha Requires Cython to be installed. If Cython is not present, find_package(Cython) will fail. Install Cython via pip or conda. ↓
fix pip install cython or conda install cython before running cmake.
gotcha VERSION_VAR in FindCython.cmake was broken in v0.2.1 and fixed in v0.2.2. If you specify a version, upgrade to v0.2.2. ↓
fix Upgrade to cython-cmake>=0.2.2.
Install
conda install conda-forge::cython-cmake Imports
- FindCython.cmake wrong
Old path cython-cmake/cmake/FindCython.cmakecorrectinclude(FetchContent) then include(${CMAKE_BINARY_DIR}/_deps/cython-cmake-src/cmake/FindCython.cmake)
Quickstart
cmake_minimum_required(VERSION 3.14)
project(MyProject)
include(FetchContent)
FetchContent_Declare(
cython-cmake
GIT_REPOSITORY https://github.com/scikit-build/cython-cmake.git
GIT_TAG v0.2.2
)
FetchContent_MakeAvailable(cython-cmake)
list(APPEND CMAKE_MODULE_PATH ${cython-cmake_SOURCE_DIR}/cmake)
find_package(Cython REQUIRED)
# Now use add_cython_target() etc.