Detect the correct Python major version

pull/7307/head
Jeroen Kromwijk 8 years ago
parent dc3d0cbc22
commit 401537ebab
  1. 5
      cmake/OpenCVDetectPython.cmake

@ -47,12 +47,16 @@ 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)
# 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})
@ -60,6 +64,7 @@ if(NOT ${found})
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