Detect the correct Python major version

pull/7307/head
Jeroen Kromwijk 8 years ago
parent dc3d0cbc22
commit 401537ebab
  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