5 # Find ``cython`` executable.
7 # This module defines the following variables:
9 # ``CYTHON_EXECUTABLE``
10 # path to the ``cython`` program
13 # version of ``cython``
16 # true if the program was found
18 # See also UseCython.cmake
20 #=============================================================================
21 # Copyright 2011 Kitware, Inc.
23 # Licensed under the Apache License, Version 2.0 (the "License");
24 # you may not use this file except in compliance with the License.
25 # You may obtain a copy of the License at
27 # http://www.apache.org/licenses/LICENSE-2.0
29 # Unless required by applicable law or agreed to in writing, software
30 # distributed under the License is distributed on an "AS IS" BASIS,
31 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32 # See the License for the specific language governing permissions and
33 # limitations under the License.
34 #=============================================================================
36 # Use the Cython executable that lives next to the Python executable
37 # if it is a local installation.
38 find_package(PythonInterp)
39 if(PYTHONINTERP_FOUND)
40 get_filename_component(_python_path ${PYTHON_EXECUTABLE} PATH)
41 find_program(CYTHON_EXECUTABLE
42 NAMES cython cython.bat cython3
44 DOC "path to the cython executable")
46 find_program(CYTHON_EXECUTABLE
47 NAMES cython cython.bat cython3
48 DOC "path to the cython executable")
52 set(CYTHON_version_command ${CYTHON_EXECUTABLE} --version)
54 execute_process(COMMAND ${CYTHON_version_command}
55 OUTPUT_VARIABLE CYTHON_version_output
56 ERROR_VARIABLE CYTHON_version_error
57 RESULT_VARIABLE CYTHON_version_result
58 OUTPUT_STRIP_TRAILING_WHITESPACE)
60 if(NOT ${CYTHON_version_result} EQUAL 0)
61 set(_error_msg "Command \"${CYTHON_version_command}\" failed with")
62 set(_error_msg "${_error_msg} output:\n${CYTHON_version_error}")
63 message(SEND_ERROR "${_error_msg}")
65 if("${CYTHON_version_output}" MATCHES "^[Cc]ython version ([^,]+)")
66 set(CYTHON_VERSION "${CMAKE_MATCH_1}")
71 include(FindPackageHandleStandardArgs)
72 FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cython REQUIRED_VARS CYTHON_EXECUTABLE)
74 mark_as_advanced(CYTHON_EXECUTABLE)