From 5e241e7c368389470ba2fe08ef6b95523c570c58 Mon Sep 17 00:00:00 2001 From: Hamdi Sahloul Date: Sun, 9 Sep 2018 13:47:03 +0900 Subject: [PATCH] CMAKE: Improve python detection --- cmake/OpenCVDetectPython.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/OpenCVDetectPython.cmake b/cmake/OpenCVDetectPython.cmake index b6c7a2535c..3a880215d2 100644 --- a/cmake/OpenCVDetectPython.cmake +++ b/cmake/OpenCVDetectPython.cmake @@ -254,10 +254,12 @@ find_python(3.4 "${MIN_VER_PYTHON3}" PYTHON3_LIBRARY PYTHON3_INCLUDE_DIR if(PYTHON_DEFAULT_EXECUTABLE) set(PYTHON_DEFAULT_AVAILABLE "TRUE") -elseif(PYTHON2INTERP_FOUND) # Use Python 2 as default Python interpreter +elseif(PYTHON2_EXECUTABLE AND PYTHON2INTERP_FOUND) + # Use Python 2 as default Python interpreter set(PYTHON_DEFAULT_AVAILABLE "TRUE") set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON2_EXECUTABLE}") -elseif(PYTHON3INTERP_FOUND) # Use Python 3 as fallback Python interpreter (if there is no Python 2) +elseif(PYTHON3_EXECUTABLE AND PYTHON3INTERP_FOUND) + # Use Python 3 as fallback Python interpreter (if there is no Python 2) set(PYTHON_DEFAULT_AVAILABLE "TRUE") set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON3_EXECUTABLE}") endif()