From 02bd49bc9379e3062a718b1c16d6e2c23ea2f1a0 Mon Sep 17 00:00:00 2001 From: Oliver Lee Date: Fri, 13 Feb 2015 17:14:00 +0100 Subject: Fix search for Python 2 with CMake Do not assume that Python has already been found by CMake. Fix value of CMake variable PYTHON_EXECUTABLE if Python 3 was found. Change minimum supported Python version to 2.6. This fixes a bug introduced by this commit: d8d3b75e2e3b348d016f48cebc1be764061975d2 --- extra/FindNanopb.cmake | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/extra/FindNanopb.cmake b/extra/FindNanopb.cmake index 513182d8..e65706ac 100644 --- a/extra/FindNanopb.cmake +++ b/extra/FindNanopb.cmake @@ -244,17 +244,16 @@ find_file(NANOPB_GENERATOR_EXECUTABLE ) mark_as_advanced(NANOPB_GENERATOR_EXECUTABLE) -# If python3 has already been found, save it and look for python2.7 -if(${PYTHON_VERSION_MAJOR} EQUAL 3) +# If python3 has already been found, save it and look for python2.6 +if(${PYTHON_VERSION_MAJOR} AND ${PYTHON_VERSION_MAJOR} EQUAL 3) set(PYTHON3_EXECUTABLE ${PYTHON_EXECUTABLE}) set(PYTHON_EXECUTABLE PYTHON_EXECUTABLE-NOTFOUND) -endif() - -find_package(PythonInterp 2.7 REQUIRED) -set(PYTHON2_EXECUTABLE ${PYTHON_EXECUTABLE}) - -if(${PYTHON_VERSION_MAJOR} EQUAL 3) + find_package(PythonInterp 2.6 REQUIRED) + set(PYTHON2_EXECUTABLE ${PYTHON_EXECUTABLE}) set(PYTHON_EXECUTABLE ${PYTHON3_EXECUTABLE}) +else() + find_package(PythonInterp 2.6 REQUIRED) + set(PYTHON2_EXECUTABLE ${PYTHON_EXECUTABLE}) endif() include(FindPackageHandleStandardArgs) -- cgit 1.2.3-korg