diff --git a/CMakeLists.txt b/CMakeLists.txt index 4932c448d..da6f04331 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -567,25 +567,31 @@ if(NOT VOLK_GNSSSDR_FOUND) ############################### # Find Python required modules ############################### - include(SetupPython) #sets PYTHON_EXECUTABLE and PYTHON_DASH_B + include(SetupPython) # sets PYTHON_EXECUTABLE and search for required modules GNSSSDR_PYTHON_CHECK_MODULE("python >= ${GNSSSDR_PYTHON_MIN_VERSION}" sys "sys.version.split()[0] >= '${GNSSSDR_PYTHON_MIN_VERSION}'" PYTHON_MIN_VER_FOUND) GNSSSDR_PYTHON_CHECK_MODULE("mako >= ${GNSSSDR_MAKO_MIN_VERSION}" mako "mako.__version__ >= '${GNSSSDR_MAKO_MIN_VERSION}'" MAKO_FOUND) GNSSSDR_PYTHON_CHECK_MODULE("six - python 2 and 3 compatibility library" six "True" SIX_FOUND) if(NOT PYTHON_MIN_VER_FOUND) message(FATAL_ERROR "Python ${GNSSSDR_PYTHON_MIN_VERSION} or greater required to build VOLK_GNSSSDR") - endif() + endif(NOT PYTHON_MIN_VER_FOUND) + + if(${PYTHON3}) + set(PYTHON_NAME "python3") + else(${PYTHON3}) + set(PYTHON_NAME "python") + endif(${PYTHON3}) # Mako if(NOT MAKO_FOUND) - message(STATUS "Mako templates not found. See http://www.makotemplates.org/ ") + message(STATUS "Mako template library not found. See http://www.makotemplates.org/ ") message(STATUS " You can try to install it by typing:") if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(STATUS " sudo yum install python-mako") + message(STATUS " sudo yum install ${PYTHON_NAME}-mako") elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") - message(STATUS " sudo zypper install python-Mako") + message(STATUS " sudo zypper install ${PYTHON_NAME}-Mako") else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(STATUS " sudo apt-get install python-mako") + message(STATUS " sudo apt-get install ${PYTHON_NAME}-mako") endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") message(FATAL_ERROR "Mako templates required to build VOLK_GNSSSDR") endif(NOT MAKO_FOUND) @@ -595,11 +601,11 @@ if(NOT VOLK_GNSSSDR_FOUND) message(STATUS "python-six not found. See https://pythonhosted.org/six/ ") message(STATUS " You can try to install it by typing:") if(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(STATUS " sudo yum install python-six") + message(STATUS " sudo yum install ${PYTHON_NAME}-six") elseif(${LINUX_DISTRIBUTION} MATCHES "openSUSE") - message(STATUS " sudo zypper install python-six") + message(STATUS " sudo zypper install ${PYTHON_NAME}-six") else(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") - message(STATUS " sudo apt-get install python-six") + message(STATUS " sudo apt-get install ${PYTHON_NAME}-six") endif(${LINUX_DISTRIBUTION} MATCHES "Fedora" OR ${LINUX_DISTRIBUTION} MATCHES "Red Hat") message(FATAL_ERROR "six - python 2 and 3 compatibility library required to build VOLK_GNSSSDR") endif(NOT SIX_FOUND) diff --git a/cmake/Modules/SetupPython.cmake b/cmake/Modules/SetupPython.cmake index d5c799a9f..01fc9a512 100644 --- a/cmake/Modules/SetupPython.cmake +++ b/cmake/Modules/SetupPython.cmake @@ -24,13 +24,18 @@ if (PYTHON_EXECUTABLE) message(STATUS "User set python executable ${PYTHON_EXECUTABLE}") - find_package(PythonInterp ${GNSSSDR_PYTHON_MIN_VERSION} REQUIRED) + string(FIND "${PYTHON_EXECUTABLE}" "python3" IS_PYTHON3) + if(IS_PYTHON3 EQUAL -1) + find_package(PythonInterp ${GNSSSDR_PYTHON_MIN_VERSION} REQUIRED) + else(IS_PYTHON3 EQUAL -1) + find_package(PythonInterp ${GNSSSDR_PYTHON3_MIN_VERSION} REQUIRED) + endif(IS_PYTHON3 EQUAL -1) else (PYTHON_EXECUTABLE) message(STATUS "PYTHON_EXECUTABLE not set - using default python2") + message(STATUS "Use -DPYTHON_EXECUTABLE=/path/to/python3 to build for python3.") find_package(PythonInterp ${GNSSSDR_PYTHON_MIN_VERSION}) if(NOT PYTHONINTERP_FOUND) - # message(STATUS "Use -DPYTHON_EXECUTABLE=/path/to/python2 to build for python2.") - message(STATUS "python2 not found - using python3") + message(STATUS "python2 not found - trying with python3") find_package(PythonInterp ${GNSSSDR_PYTHON3_MIN_VERSION} REQUIRED) endif(NOT PYTHONINTERP_FOUND) endif (PYTHON_EXECUTABLE)