Build both Python 2 and Python 3 bindings

If both Python 2 and Python 3 are found, then build bindings for both of
them during the build process.  Currently, one version of Python is
detected automatically, and building for the other requires changes the
CMake config.

The largest chunk of this change generalizes OpenCVDetectPython.cmake to
find both a Python 2 and Python 3 version of Python.  Secondly, the
opencv_python module is split into two modules, opencv_python2 and
opencv_python3.  Both are built from the same source. but for different
versions of Python.
This commit is contained in:
Michael Pratt
2014-06-29 16:45:24 -04:00
committed by arc
parent 2d81595ed4
commit cac1218eef
11 changed files with 454 additions and 242 deletions

View File

@@ -0,0 +1,26 @@
if(NOT PYTHON2LIBS_FOUND OR NOT PYTHON2_NUMPY_INCLUDE_DIRS)
ocv_module_disable(python2)
endif()
set(the_description "The python2 bindings")
ocv_add_module(python2 BINDINGS opencv_core opencv_flann opencv_imgproc opencv_video opencv_ml opencv_features2d opencv_highgui opencv_calib3d opencv_photo opencv_objdetect OPTIONAL opencv_nonfree)
set(PYTHON_INCLUDE_PATH ${PYTHON2_INCLUDE_PATH})
set(PYTHON_NUMPY_INCLUDE_PATH ${PYTHON2_NUMPY_INCLUDE_PATH})
set(PYTHON_EXECUTABLE ${PYTHON2_EXECUTABLE})
set(PYTHON_DEBUG_LIBRARIES ${PYTHON2_DEBUG_LIBRARIES})
set(PYTHON_LIBRARIES ${PYTHON2_LIBRARIES})
set(PYTHON_PACKAGES_PATH ${PYTHON2_PACKAGES_PATH})
set(PYTHON_VERSION_MAJOR ${PYTHON2_VERSION_MAJOR})
set(PYTHON_VERSION_MINOR ${PYTHON2_VERSION_MINOR})
include(../common.cmake)
unset(PYTHON_INCLUDE_PATH)
unset(PYTHON_NUMPY_INCLUDE_PATH)
unset(PYTHON_EXECUTABLE)
unset(PYTHON_DEBUG_LIBRARIES)
unset(PYTHON_LIBRARIES)
unset(PYTHON_PACKAGES_PATH)
unset(PYTHON_VERSION_MAJOR)
unset(PYTHON_VERSION_MINOR)