From 9888cac80e003597a1e79188cd1dd81152fece04 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 9 Jul 2018 17:13:21 +0800 Subject: [PATCH] cmake: cleanup FindCython.cmake print out error message if cython module is not found. Signed-off-by: Kefu Chai --- cmake/modules/FindCython.cmake | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/cmake/modules/FindCython.cmake b/cmake/modules/FindCython.cmake index 0048bf7f9bd..6017a398081 100644 --- a/cmake/modules/FindCython.cmake +++ b/cmake/modules/FindCython.cmake @@ -2,25 +2,15 @@ # Cython # -SET(Cython${PYTHON_VERSION}_FOUND FALSE) # Try to run Cython, to make sure it works: execute_process( - COMMAND ${PYTHON${PYTHON_VERSION}_EXECUTABLE} -m cython --version - RESULT_VARIABLE CYTHON_RESULT - OUTPUT_QUIET - ERROR_QUIET - ) -if (CYTHON_RESULT EQUAL 0) - SET(Cython${PYTHON_VERSION}_FOUND TRUE) -endif (CYTHON_RESULT EQUAL 0) - - -IF (Cython${PYTHON_VERSION}_FOUND) - IF (NOT Cython_FIND_QUIETLY) - MESSAGE(STATUS "Found cython${PYTHON_VERSION}") - ENDIF (NOT Cython_FIND_QUIETLY) -ELSE (Cython${PYTHON_VERSION}_FOUND) - IF (Cython_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "Could not find cython${PYTHON_VERSION}. Please install Cython.") - ENDIF (Cython_FIND_REQUIRED) -ENDIF (Cython${PYTHON_VERSION}_FOUND) + COMMAND ${PYTHON${PYTHON_VERSION}_EXECUTABLE} -m cython --version + RESULT_VARIABLE cython_result + ERROR_VARIABLE cython_output) +if(cython_result EQUAL 0) + string(REGEX REPLACE "^Cython version ([0-9]+\\.[0-9]+).*" "\\1" CYTHON_VERSION "${cython_output}") +else() + message(SEND_ERROR "Could not find cython${PYTHON_VERSION}: ${cython_output}") +endif() +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Cython${PYTHON_VERSION} DEFAULT_MSG CYTHON_VERSION) -- 2.47.3