Skip to content

Commit ca20152

Browse files
authored
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. ```
1 parent e928f2b commit ca20152

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

cmake/findDependencies.cmake

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,23 @@ endif()
3939

4040
set(CMAKE_INCLUDE_CURRENT_DIR ON)
4141

42-
find_package(PythonInterp 3 QUIET)
43-
if (NOT PYTHONINTERP_FOUND)
44-
set(PYTHONINTERP_FOUND "")
45-
find_package(PythonInterp 2.7 QUIET)
46-
if (NOT PYTHONINTERP_FOUND AND NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
42+
if (CMAKE_VERSION VERSION_EQUAL "3.12" OR CMAKE_VERSION VERSION_GREATER "3.12")
43+
find_package(Python COMPONENTS Interpreter)
44+
if (NOT Python_Interpreter_FOUND)
4745
message(WARNING "No python interpreter found. Therefore, the match compiler is switched off.")
4846
set(USE_MATCHCOMPILER_OPT "Off")
47+
else()
48+
set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
49+
endif()
50+
else()
51+
find_package(PythonInterp 3 QUIET)
52+
if (NOT PYTHONINTERP_FOUND)
53+
set(PYTHONINTERP_FOUND "")
54+
find_package(PythonInterp 2.7 QUIET)
55+
if (NOT PYTHONINTERP_FOUND AND NOT USE_MATCHCOMPILER_OPT STREQUAL "Off")
56+
message(WARNING "No python interpreter found. Therefore, the match compiler is switched off.")
57+
set(USE_MATCHCOMPILER_OPT "Off")
58+
endif()
4959
endif()
5060
endif()
5161

0 commit comments

Comments
 (0)