mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 22:44:02 +08:00
Detect the correct Python major version
This commit is contained in:
parent
dc3d0cbc22
commit
401537ebab
@ -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…
Reference in New Issue
Block a user