diff --git a/cmake/findDependencies.cmake b/cmake/findDependencies.cmake index da6d63975..90b7c137e 100644 --- a/cmake/findDependencies.cmake +++ b/cmake/findDependencies.cmake @@ -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()