diff --git a/cmake/OpenCVDetectPython.cmake b/cmake/OpenCVDetectPython.cmake index 140fb6283c..c3c467002e 100644 --- a/cmake/OpenCVDetectPython.cmake +++ b/cmake/OpenCVDetectPython.cmake @@ -59,15 +59,21 @@ if(NOT ${found}) if(NOT PYTHONINTERP_FOUND) message(STATUS "Python is not found: ${preferred_version} EXACT") endif() - else() + elseif(min_version) set(__python_package_version "${min_version}") find_host_package(PythonInterp "${min_version}") + else() + set(__python_package_version "") + find_host_package(PythonInterp) endif() string(REGEX MATCH "^[0-9]+" _python_version_major "${min_version}") if(PYTHONINTERP_FOUND) # Check if python major version is correct + if(" ${_python_version_major}" STREQUAL " ") + set(_python_version_major "${PYTHON_VERSION_MAJOR}") + endif() if(NOT "${_python_version_major}" STREQUAL "${PYTHON_VERSION_MAJOR}" AND NOT DEFINED ${executable} ) diff --git a/modules/python/standalone.cmake b/modules/python/standalone.cmake index d21420a662..584815175f 100644 --- a/modules/python/standalone.cmake +++ b/modules/python/standalone.cmake @@ -10,7 +10,7 @@ include("${OpenCV_SOURCE_DIR}/cmake/OpenCVUtils.cmake") set(OPENCV_PYTHON_SKIP_DETECTION ON) include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectPython.cmake") -find_python("" "2.7" PYTHON_LIBRARY PYTHON_INCLUDE_DIR +find_python("${OPENCV_PYTHON_VERSION}" "${OPENCV_PYTHON_VERSION}" PYTHON_LIBRARY PYTHON_INCLUDE_DIR PYTHONINTERP_FOUND PYTHON_EXECUTABLE PYTHON_VERSION_STRING PYTHON_VERSION_MAJOR PYTHON_VERSION_MINOR PYTHONLIBS_FOUND PYTHONLIBS_VERSION_STRING PYTHON_LIBRARIES PYTHON_LIBRARY