diff --git a/src/bindings/python/src/compatibility/openvino/CMakeLists.txt b/src/bindings/python/src/compatibility/openvino/CMakeLists.txt index 01aa40b296e54c..6a1c48777cfa70 100644 --- a/src/bindings/python/src/compatibility/openvino/CMakeLists.txt +++ b/src/bindings/python/src/compatibility/openvino/CMakeLists.txt @@ -21,13 +21,11 @@ endif() include (cmake/UseCython.cmake) -# Ticket 119312 -# # Check Cython version -# if(CYTHON_VERSION VERSION_LESS "0.29") -# message(FATAL_ERROR "OpenVINO Python API needs at least Cython version 0.29, found version ${CYTHON_VERSION}") -# else() -# message(STATUS "Found Cython version ${CYTHON_VERSION}") -# endif() +if(CYTHON_VERSION VERSION_LESS 0.29) + message(FATAL_ERROR "OpenVINO Python API needs at least Cython version 0.29, found version ${CYTHON_VERSION}") +else() + message(STATUS "Found Cython version ${CYTHON_VERSION}") +endif() set(pyversion python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) diff --git a/src/bindings/python/src/compatibility/openvino/cmake/CythonConfig.cmake b/src/bindings/python/src/compatibility/openvino/cmake/CythonConfig.cmake index 05f75ceeb51772..4cc32dacec1375 100644 --- a/src/bindings/python/src/compatibility/openvino/cmake/CythonConfig.cmake +++ b/src/bindings/python/src/compatibility/openvino/cmake/CythonConfig.cmake @@ -50,7 +50,30 @@ include( FindPackageHandleStandardArgs ) FIND_PACKAGE_HANDLE_STANDARD_ARGS( Cython REQUIRED_VARS CYTHON_EXECUTABLE ) # Find Cython version -execute_process(COMMAND ${CYTHON_EXECUTABLE} -V ERROR_VARIABLE CYTHON_OUTPUT OUTPUT_QUIET) -string(REGEX REPLACE "^Cython version ([0-9]+\\.[0-9]+(\\.[0-9]+)?).*" "\\1" CYTHON_VERSION "${CYTHON_OUTPUT}") +execute_process(COMMAND ${CYTHON_EXECUTABLE} -V + ERROR_VARIABLE CYTHON_OUTPUT + OUTPUT_VARIABLE CYTHON_ERROR_MESSAGE + RESULT_VARIABLE CYTHON_EXIT_CODE + OUTPUT_STRIP_TRAILING_WHITESPACE) + +if(CYTHON_EXIT_CODE EQUAL 0) + if(NOT CYTHON_OUTPUT) + set(CYTHON_OUTPUT "${CYTHON_ERROR_MESSAGE}") + endif() + string(REGEX REPLACE "^Cython version ([0-9]+\\.[0-9]+(\\.[0-9]+)?).*" "\\1" CYTHON_VERSION "${CYTHON_OUTPUT}") +else() + if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) + set(CYTHON_MESSAGE_MODE TRACE) + endif() + if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED) + set(CYTHON_MESSAGE_MODE FATAL_ERROR) + endif() + message(${CYTHON_MESSAGE_MODE} "Failed to detect cython version: ${CYTHON_ERROR_MESSAGE}") + unset(CYTHON_MESSAGE_MODE) +endif() + +unset(CYTHON_OUTPUT) +unset(CYTHON_EXIT_CODE) +unset(CYTHON_ERROR_MESSAGE) mark_as_advanced( CYTHON_EXECUTABLE CYTHON_VERSION )