mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-04-05 18:27:02 +00:00
CMake: complete transition from FindPythonInterp to FindPython (FindPythonInterp was deprecated in CMake 3.24 and removed in CMake 3.27)
This commit is contained in:
parent
4149490bb6
commit
d15422edba
@ -48,9 +48,25 @@ if(CMAKE_VERSION VERSION_LESS 3.12 OR CMAKE_CROSSCOMPILING)
|
||||
message(STATUS "User set python executable ${PYTHON_EXECUTABLE}")
|
||||
string(FIND "${PYTHON_EXECUTABLE}" "python3" IS_PYTHON3)
|
||||
if(IS_PYTHON3 EQUAL -1)
|
||||
find_package(PythonInterp ${GNSSSDR_PYTHON_MIN_VERSION} REQUIRED)
|
||||
if(CMAKE_VERSION VERSION_LESS "3.24")
|
||||
find_package(PythonInterp ${GNSSSDR_PYTHON_MIN_VERSION} REQUIRED)
|
||||
else()
|
||||
set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
|
||||
find_package(Python2 COMPONENTS Interpreter)
|
||||
set(PYTHONINTERP_FOUND Python2_Interpreter_FOUND)
|
||||
set(PYTHON_VERSION_MAJOR "${Python2_VERSION_MAJOR}")
|
||||
set(PYTHON_VERSION_STRING "${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}")
|
||||
endif()
|
||||
else()
|
||||
find_package(PythonInterp ${GNSSSDR_PYTHON3_MIN_VERSION} REQUIRED)
|
||||
if(CMAKE_VERSION VERSION_LESS "3.24")
|
||||
find_package(PythonInterp ${GNSSSDR_PYTHON3_MIN_VERSION} REQUIRED)
|
||||
else()
|
||||
set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
|
||||
find_package(Python3 COMPONENTS Interpreter)
|
||||
set(PYTHONINTERP_FOUND Python3_Interpreter_FOUND)
|
||||
set(PYTHON_VERSION_MAJOR "${Python3_VERSION_MAJOR}")
|
||||
set(PYTHON_VERSION_STRING "${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}")
|
||||
endif()
|
||||
endif()
|
||||
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)
|
||||
@ -59,21 +75,26 @@ if(CMAKE_VERSION VERSION_LESS 3.12 OR CMAKE_CROSSCOMPILING)
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "PYTHON_EXECUTABLE not set - trying by default python3")
|
||||
set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7 3.8 3.9)
|
||||
if(CMAKE_VERSION VERSION_LESS "3.27")
|
||||
if(CMAKE_VERSION VERSION_LESS "3.24")
|
||||
set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11)
|
||||
find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION})
|
||||
else()
|
||||
find_package(Python COMPONENTS Interpreter)
|
||||
set(PYTHONINTERP_FOUND Python_Interpreter_FOUND)
|
||||
set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}")
|
||||
set(PYTHON_VERSION_MAJOR "${Python_VERSION_MAJOR}")
|
||||
set(PYTHON_VERSION_STRING "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}")
|
||||
endif()
|
||||
if(NOT PYTHONINTERP_FOUND)
|
||||
message(STATUS "python3 not found - trying with python2.7")
|
||||
if(CMAKE_VERSION VERSION_LESS "3.27")
|
||||
if(CMAKE_VERSION VERSION_LESS "3.24")
|
||||
set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11)
|
||||
find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION})
|
||||
else()
|
||||
find_package(Python2 COMPONENTS Interpreter)
|
||||
set(PYTHONINTERP_FOUND Python2_Interpreter_FOUND)
|
||||
set(PYTHON_EXECUTABLE "${Python2_EXECUTABLE}")
|
||||
set(PYTHON_VERSION_MAJOR "${Python2_VERSION_MAJOR}")
|
||||
set(PYTHON_VERSION_STRING "${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}")
|
||||
endif()
|
||||
endif()
|
||||
@ -88,13 +109,17 @@ else()
|
||||
set(_previous ${CMAKE_FIND_FRAMEWORK})
|
||||
set(CMAKE_FIND_FRAMEWORK LAST)
|
||||
endif()
|
||||
if(PYTHON_EXECUTABLE)
|
||||
set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
|
||||
endif()
|
||||
find_package(Python3 COMPONENTS Interpreter)
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(CMAKE_FIND_FRAMEWORK ${_previous})
|
||||
endif()
|
||||
if(Python3_FOUND)
|
||||
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
|
||||
set(PYTHON_VERSION_MAJOR ${Python3_VERSION_MAJOR})
|
||||
set(PYTHON_VERSION_MAJOR "${Python3_VERSION_MAJOR}")
|
||||
set(PYTHON_VERSION_STRING "${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}")
|
||||
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)
|
||||
endif()
|
||||
@ -103,18 +128,21 @@ else()
|
||||
if(Python2_FOUND)
|
||||
set(PYTHON_EXECUTABLE ${Python2_EXECUTABLE})
|
||||
set(PYTHON_VERSION_MAJOR ${Python2_VERSION_MAJOR})
|
||||
set(PYTHON_VERSION_STRING "${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}")
|
||||
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)
|
||||
endif()
|
||||
if(NOT MAKO_FOUND OR NOT SIX_FOUND)
|
||||
unset(PYTHON_EXECUTABLE)
|
||||
if(CMAKE_VERSION VERSION_LESS "3.27")
|
||||
if(CMAKE_VERSION VERSION_LESS "3.24")
|
||||
find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION})
|
||||
else()
|
||||
find_package(Python COMPONENTS Interpreter)
|
||||
set(PYTHONINTERP_FOUND Python_Interpreter_FOUND)
|
||||
set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}")
|
||||
set(PYTHON_VERSION_STRING "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}")
|
||||
set(PYTHON_VERSION_MAJOR "${Python_VERSION_MAJOR}")
|
||||
endif()
|
||||
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)
|
||||
|
@ -52,18 +52,42 @@ set(VOLK_PYTHON3_MIN_VERSION "3.4")
|
||||
if(CMAKE_VERSION VERSION_LESS 3.12 OR CMAKE_CROSSCOMPILING)
|
||||
if(PYTHON_EXECUTABLE)
|
||||
message(STATUS "User set python executable ${PYTHON_EXECUTABLE}")
|
||||
find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION} REQUIRED)
|
||||
if(CMAKE_VERSION VERSION_LESS "3.24") # For cross-compiling
|
||||
find_package(PythonInterp ${VOLK_PYTHON_MIN3_VERSION} REQUIRED)
|
||||
else()
|
||||
set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
|
||||
find_package(Python COMPONENTS Interpreter)
|
||||
set(PYTHONINTERP_FOUND Python_Interpreter_FOUND)
|
||||
set(PYTHON_VERSION_MAJOR "${Python_VERSION_MAJOR}")
|
||||
set(PYTHON_VERSION_STRING "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}")
|
||||
endif()
|
||||
if(PYTHON_VERSION_STRING VERSION_LESS "3.0")
|
||||
volk_python_check_module("six - python 2 and 3 compatibility library" six "True" SIX_FOUND)
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "PYTHON_EXECUTABLE not set - trying by default python3")
|
||||
message(STATUS "Use -DPYTHON_EXECUTABLE=/path/to/python to build for python 2.7")
|
||||
set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7 3.8 3.9)
|
||||
find_package(PythonInterp ${VOLK_PYTHON_MIN3_VERSION})
|
||||
if(CMAKE_VERSION VERSION_LESS "3.24") # For cross-compiling
|
||||
set(Python_ADDITIONAL_VERSIONS 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11)
|
||||
find_package(PythonInterp ${VOLK_PYTHON_MIN3_VERSION} REQUIRED)
|
||||
else()
|
||||
find_package(Python COMPONENTS Interpreter)
|
||||
set(PYTHONINTERP_FOUND Python_Interpreter_FOUND)
|
||||
set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}")
|
||||
set(PYTHON_VERSION_MAJOR "${Python_VERSION_MAJOR}")
|
||||
set(PYTHON_VERSION_STRING "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}")
|
||||
endif()
|
||||
if(NOT PYTHONINTERP_FOUND)
|
||||
message(STATUS "python3 not found - trying with python2.7")
|
||||
find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION} REQUIRED)
|
||||
if(CMAKE_VERSION VERSION_LESS "3.24")
|
||||
find_package(PythonInterp ${VOLK_PYTHON_MIN3_VERSION} REQUIRED)
|
||||
else()
|
||||
find_package(Python2 COMPONENTS Interpreter)
|
||||
set(PYTHONINTERP_FOUND Python2_Interpreter_FOUND)
|
||||
set(PYTHON_VERSION_MAJOR "${Python2_VERSION_MAJOR}")
|
||||
set(PYTHON_EXECUTABLE "${Python2_EXECUTABLE}")
|
||||
set(PYTHON_VERSION_STRING "${Python2_VERSION_MAJOR}.${Python2_VERSION_MINOR}")
|
||||
endif()
|
||||
volk_python_check_module("six - python 2 and 3 compatibility library" six "True" SIX_FOUND)
|
||||
endif()
|
||||
endif()
|
||||
@ -71,11 +95,13 @@ if(CMAKE_VERSION VERSION_LESS 3.12 OR CMAKE_CROSSCOMPILING)
|
||||
else()
|
||||
if(PYTHON_EXECUTABLE)
|
||||
message(STATUS "User set python executable ${PYTHON_EXECUTABLE}")
|
||||
if(CMAKE_VERSION VERSION_LESS "3.27")
|
||||
if(CMAKE_VERSION VERSION_LESS "3.24")
|
||||
find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION} REQUIRED)
|
||||
else()
|
||||
set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
|
||||
find_package(Python COMPONENTS Interpreter)
|
||||
set(PYTHONINTERP_FOUND Python_Interpreter_FOUND)
|
||||
set(PYTHON_VERSION_MAJOR "${Python_VERSION_MAJOR}")
|
||||
set(PYTHON_VERSION_STRING "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}")
|
||||
endif()
|
||||
volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND)
|
||||
@ -108,11 +134,13 @@ else()
|
||||
endif()
|
||||
if(NOT MAKO_FOUND OR NOT SIX_FOUND)
|
||||
unset(PYTHON_EXECUTABLE)
|
||||
if(CMAKE_VERSION VERSION_LESS "3.27")
|
||||
if(CMAKE_VERSION VERSION_LESS "3.24")
|
||||
find_package(PythonInterp ${VOLK_PYTHON_MIN_VERSION})
|
||||
else()
|
||||
find_package(Python COMPONENTS Interpreter)
|
||||
set(PYTHONINTERP_FOUND Python_Interpreter_FOUND)
|
||||
set(PYTHON_EXECUTABLE "${Python_EXECUTABLE}")
|
||||
set(PYTHON_VERSION_MAJOR "${Python_VERSION_MAJOR}")
|
||||
set(PYTHON_VERSION_STRING "${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}")
|
||||
endif()
|
||||
volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND)
|
||||
@ -121,13 +149,12 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS "3.27")
|
||||
if(${PYTHON_VERSION_MAJOR} VERSION_EQUAL 3)
|
||||
set(PYTHON3 TRUE)
|
||||
endif()
|
||||
if(${PYTHON_VERSION_MAJOR} VERSION_EQUAL 3)
|
||||
set(PYTHON3 TRUE)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
########################################################################
|
||||
# Sets the python installation directory VOLK_PYTHON_DIR
|
||||
########################################################################
|
||||
|
Loading…
x
Reference in New Issue
Block a user