tests: Switch from PYTHON_EXECUTABLE to PYTHON_DEFAULT_EXECUTABLE

The DetectPython cmake script now outputs a default python executable.
Updated other cmake scripts to use this concept.  Used default where
python2/3 will work, use explicit PYTHON2/3_EXECUTABLE where an
explicit version is needed.  Also, fail if python is required and NO
version of python was found.

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck
2016-10-05 17:08:42 -07:00
parent edd8df4c50
commit c6610bdf46
3 changed files with 59 additions and 37 deletions

View File

@ -54,11 +54,23 @@ if (BUILDSWIGPYTHON OR BUILDSWIGNODE OR BUILDSWIGJAVA)
include (${SWIG_USE_FILE})
endif ()
# Python is required for swig generated python and for UPM tests
# UPM build can generated modules for both python2 AND python3
# Python is required for swig generated python and for UPM tests.
# The UPM build can generated modules for both python2 AND python3
# with the corresponding PYTHONLIBS. Currently, BUILDTESTS has a
# hard dependency on the PYTHON2INTERP.
# OpenCV python detect will attempt to find python2/3
if (BUILDSWIGPYTHON OR BUILDTESTS)
include (cmake/modules/OpenCVDetectPython.cmake)
# Fail if building tests but no python interpreter was found
if (BUILDTESTS AND NOT PYTHON2INTERP_FOUND)
message(FATAL_ERROR "BUILDTESTS=ON requires the python2 interpreter")
endif (BUILDTESTS AND NOT PYTHON2INTERP_FOUND)
# Fail if no LIBS were found
if (NOT PYTHON2LIBS_FOUND AND NOT PYTHON3LIBS_FOUND)
message(FATAL_ERROR "At least one python lib is required")
endif (NOT PYTHON2LIBS_FOUND AND NOT PYTHON3LIBS_FOUND)
endif (BUILDSWIGPYTHON OR BUILDTESTS)
# Which versions of python were found?