From 8c6c31b18f92a86464bfebdc7bd987453486ecab Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 17 Jul 2024 11:03:25 -0400 Subject: [PATCH] feat: support UseCython by itself Co-authored-by: Jean-Christophe Fillion-Robin --- src/cython_cmake/cmake/UseCython.cmake | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/cython_cmake/cmake/UseCython.cmake b/src/cython_cmake/cmake/UseCython.cmake index 366f9e2..ac7b95e 100644 --- a/src/cython_cmake/cmake/UseCython.cmake +++ b/src/cython_cmake/cmake/UseCython.cmake @@ -77,6 +77,16 @@ function(Cython_compile_pyx) ${ARGN} ) + if(DEFINED CYTHON_EXECUTABLE) + set(_cython_command "${CYTHON_EXECUTABLE}") + elseif(DEFINED Python_EXECUTABLE) + set(_cython_command "${Python_EXECUTABLE}" -m cython) + elseif(DEFINED Python3_EXECUTABLE) + set(_cython_command "${Python3_EXECUTABLE}" -m cython) + else() + message(FATAL_ERROR "Cython executable not found") + endif() + # Get source file location set(_source_files ${_args_UNPARSED_ARGUMENTS}) @@ -125,7 +135,8 @@ function(Cython_compile_pyx) # Add the command to run the compiler. add_custom_command( OUTPUT ${generated_file} - COMMAND ${CYTHON_EXECUTABLE} + COMMAND + ${_cython_command} ARGS ${_language_arg} ${_args_CYTHON_ARGS}