Merge pull request #7307 from Jeroonk:fix_detect_python_majorversion

pull/7321/head
Alexander Alekhin 8 years ago
commit 86f01c254d
  1. 19
      cmake/OpenCVDetectPython.cmake

@ -47,19 +47,24 @@ if(NOT ${found})
endforeach()
endif()
string(REGEX MATCH "^[0-9]+" _preferred_version_major ${preferred_version})
find_host_package(PythonInterp "${preferred_version}")
if(NOT PYTHONINTERP_FOUND)
find_host_package(PythonInterp "${min_version}")
endif()
if(PYTHONINTERP_FOUND)
# Copy outputs
set(_found ${PYTHONINTERP_FOUND})
set(_executable ${PYTHON_EXECUTABLE})
set(_version_string ${PYTHON_VERSION_STRING})
set(_version_major ${PYTHON_VERSION_MAJOR})
set(_version_minor ${PYTHON_VERSION_MINOR})
set(_version_patch ${PYTHON_VERSION_PATCH})
# Check if python major version is correct
if(${_preferred_version_major} EQUAL ${PYTHON_VERSION_MAJOR})
# Copy outputs
set(_found ${PYTHONINTERP_FOUND})
set(_executable ${PYTHON_EXECUTABLE})
set(_version_string ${PYTHON_VERSION_STRING})
set(_version_major ${PYTHON_VERSION_MAJOR})
set(_version_minor ${PYTHON_VERSION_MINOR})
set(_version_patch ${PYTHON_VERSION_PATCH})
endif()
# Clear find_host_package side effects
unset(PYTHONINTERP_FOUND)

Loading…
Cancel
Save