From b1f2cbbc819fcf7c57a1cbf6a2326ee8fb30951b Mon Sep 17 00:00:00 2001 From: Bi0T1N Date: Sat, 19 Aug 2023 21:38:55 +0200 Subject: [PATCH] Search for Python3 interpreter but keep libraries mandatory Signed-off-by: Bi0T1N --- CMakeLists.txt | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 891364cd..10848148 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,9 +99,16 @@ else() # the code below can be removed; e.g. pybind needs Interpreter and Development components # see https://pybind11.readthedocs.io/en/stable/cmake/index.html#new-findpython-mode if(${CMAKE_VERSION} VERSION_LESS "3.12.0") - find_package(PythonLibs QUIET) - set(Python3_FOUND ${PYTHONLIBS_FOUND}) - set(Python3_VERSION ${PYTHONLIBS_VERSION_STRING}) + find_package(PythonInterp ${IGN_PYTHON_VERSION} QUIET) + if(PYTHONINTERP_FOUND) + set(Python3_FOUND ${PYTHONINTERP_FOUND}) + set(Python3_Interpreter_FOUND ${PYTHONINTERP_FOUND}) + set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE}) + find_package(PythonLibs QUIET) + # we found the interpreter but did we also find the libs? both are required + set(Python3_FOUND ${PYTHONLIBS_FOUND}) + set(Python3_VERSION ${PYTHONLIBS_VERSION_STRING}) + endif() else() find_package(Python3 QUIET COMPONENTS Interpreter Development) endif()