From d811a324c27f6c004361d5c976eeddfe2b62e456 Mon Sep 17 00:00:00 2001
From: Lars Bilke <lars.bilke@ufz.de>
Date: Mon, 11 Feb 2019 22:03:08 +0100
Subject: [PATCH] [CMake] Use newer Python find module.

---
 CMakeLists.txt               | 3 +++
 scripts/cmake/Coverage.cmake | 2 +-
 scripts/cmake/Find.cmake     | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 21df0f32443..679dbeb4629 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -235,6 +235,9 @@ option(OGS_ENABLE_ELEMENT_PYRAMID "Build FEM elements for pyramids." ON)
 option(OGS_CHECK_HEADER_COMPILATION "Check header for standalone compilation." OFF)
 
 option(OGS_USE_PYTHON "Interface with Python" OFF)
+if(OGS_USE_PYTHON AND NOT Python_FOUND)
+    message(FATAL_ERROR "Python not found but required for OGS_USE_PYTHON=ON!")
+endif()
 
 option(OGS_USE_MFRONT "Enable solid material models by MFront (https://tfel.sourceforge.net)" OFF)
 
diff --git a/scripts/cmake/Coverage.cmake b/scripts/cmake/Coverage.cmake
index 338782428bc..2fd9f9274dc 100644
--- a/scripts/cmake/Coverage.cmake
+++ b/scripts/cmake/Coverage.cmake
@@ -22,7 +22,7 @@ else()
     message(STATUS "No lcov coverage report generated because lcov or genhtml was not found.")
 endif()
 
-if(PYTHON_EXECUTABLE)
+if(Python_EXECUTABLE)
     setup_target_for_coverage_gcovr_xml(
         NAME testrunner_coverage_cobertura
         EXECUTABLE ${CMAKE_COMMAND} --build . --target tests
diff --git a/scripts/cmake/Find.cmake b/scripts/cmake/Find.cmake
index 1eab719e943..9a608772534 100644
--- a/scripts/cmake/Find.cmake
+++ b/scripts/cmake/Find.cmake
@@ -9,7 +9,7 @@ find_program(GPROF_PATH gprof DOC "GNU profiler gprof" QUIET)
 
 find_program(CPPCHECK_TOOL_PATH cppcheck)
 
-find_package(PythonInterp QUIET)
+find_package(Python COMPONENTS Interpreter Development)
 
 # Find bash itself ...
 find_program(BASH_TOOL_PATH bash
-- 
GitLab