]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cmake: cleanup FindCython.cmake 22949/head
authorKefu Chai <kchai@redhat.com>
Mon, 9 Jul 2018 09:13:21 +0000 (17:13 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 9 Jul 2018 09:13:56 +0000 (17:13 +0800)
print out error message if cython module is not found.

Signed-off-by: Kefu Chai <kchai@redhat.com>
cmake/modules/FindCython.cmake

index 0048bf7f9bdfa8121307d2366f8fe62b68f8bdc4..6017a398081db5743b1c2b5937cde57b190291b8 100644 (file)
@@ -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)