findDependencies.cmake: use `FindPython` instead of deprecated `FindPythonInterp` (#5485)

This fixes the following warning with CMake 3.27:
```
CMake Warning (dev) at cmake/findDependencies.cmake:42 (find_package):
  Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
  are removed.  Run "cmake --help-policy CMP0148" for policy details.  Use
  the cmake_policy command to set the policy and suppress this warning.

Call Stack (most recent call first):
  CMakeLists.txt:15 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.
```
This commit is contained in:
Oliver Stöneberg 2023-09-27 10:06:03 +02:00 committed by GitHub
parent e928f2b5aa
commit ca20152e51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 5 deletions

View File

@ -39,13 +39,23 @@ endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(PythonInterp 3 QUIET)
if (NOT PYTHONINTERP_FOUND)
set(PYTHONINTERP_FOUND "")
find_package(PythonInterp 2.7 QUIET)
if (NOT PYTHONINTERP_FOUND AND NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
if (CMAKE_VERSION VERSION_EQUAL "3.12" OR CMAKE_VERSION VERSION_GREATER "3.12")
find_package(Python COMPONENTS Interpreter)
if (NOT Python_Interpreter_FOUND)
message(WARNING "No python interpreter found. Therefore, the match compiler is switched off.")
set(USE_MATCHCOMPILER_OPT "Off")
else()
set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
endif()
else()
find_package(PythonInterp 3 QUIET)
if (NOT PYTHONINTERP_FOUND)
set(PYTHONINTERP_FOUND "")
find_package(PythonInterp 2.7 QUIET)
if (NOT PYTHONINTERP_FOUND AND NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
message(WARNING "No python interpreter found. Therefore, the match compiler is switched off.")
set(USE_MATCHCOMPILER_OPT "Off")
endif()
endif()
endif()