default value of LIBA_CXX is set to 1
[liba.git] / cmake / FindCython.cmake
blobab6fd52e08a834d4a3af5baa5eb3355a0b90fd94
1 #.rst:
2 # FindCython
3 # ----------
5 # Find cython executable.
7 # Result Variables
8 # ^^^^^^^^^^^^^^^^
10 # This module defines the following variables:
12 # ``CYTHON_FOUND``
14 # ``CYTHON_EXECUTABLE``
16 # ``CYTHON_VERSION``
18 include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
20 if(EXISTS "${Python_EXECUTABLE}")
21   execute_process(COMMAND ${Python_EXECUTABLE} -c "import Cython; print(Cython.__version__)"
22     ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE CYTHON_VERSION
23   )
24 endif()
26 if(CYTHON_VERSION)
27   set(CYTHON_EXECUTABLE ${Python_EXECUTABLE} -m cython)
28 else()
29   find_program(CYTHON_EXECUTABLE NAMES cython)
30   mark_as_advanced(CYTHON_EXECUTABLE)
31   set(CYTHON_VERSION)
32 endif()
34 if(NOT CYTHON_VERSION AND EXISTS "${CYTHON_EXECUTABLE}")
35   execute_process(COMMAND ${CYTHON_EXECUTABLE} --version OUTPUT_QUIET ERROR_VARIABLE CYTHON_VERSION)
36   string(REGEX REPLACE ".*version ([^\n ]+).*" "\\1" CYTHON_VERSION "${CYTHON_VERSION}")
37 endif()
39 find_package_handle_standard_args(Cython
40   FOUND_VAR
41     CYTHON_FOUND
42   REQUIRED_VARS
43     CYTHON_EXECUTABLE
44   VERSION_VAR
45     CYTHON_VERSION