Skip to content

Commit

Permalink
findDependencies.cmake: use FindPython instead of deprecated `FindP…
Browse files Browse the repository at this point in the history
…ythonInterp` (#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.
```
  • Loading branch information
firewave committed Sep 27, 2023
1 parent e928f2b commit ca20152
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions cmake/findDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit ca20152

Please sign in to comment.