5 # https://cmake.org/cmake/help/latest/module/FindPythonInterp.html
6 # https://cmake.org/cmake/help/latest/module/FindPythonLibs.html
7 # https://cmake.org/cmake/help/latest/module/FindPython.html
12 # This module defines the following variables:
16 # ``Python_Interpreter_FOUND``
18 # ``Python_EXECUTABLE``
20 # ``Python_Development_FOUND``
22 # ``Python_INCLUDE_DIRS``
24 # ``Python_LIBRARIES``
28 # ``Python_VERSION_MAJOR``
30 # ``Python_VERSION_MINOR``
32 # ``Python_VERSION_PATCH``
34 if(CMAKE_VERSION VERSION_LESS 3.12)
35 if(NOT Python_FIND_COMPONENTS)
36 set(Python_FIND_COMPONENTS Interpreter)
38 foreach(module ${Python_FIND_COMPONENTS})
39 if(module MATCHES "Interpreter")
40 set(PythonInterp_FIND_VERSION ${Python_FIND_VERSION})
41 include(${CMAKE_ROOT}/Modules/FindPythonInterp.cmake)
42 set(Python_Interpreter_FOUND ${PYTHONINTERP_FOUND})
43 set(Python_VERSION_MAJOR ${PYTHON_VERSION_MAJOR})
44 set(Python_VERSION_MINOR ${PYTHON_VERSION_MINOR})
45 set(Python_VERSION_PATCH ${PYTHON_VERSION_PATCH})
46 set(Python_VERSION ${PYTHON_VERSION_STRING})
47 set(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
48 if(Python_FIND_REQUIRED_Interpreter)
49 list(APPEND Python_REQUIRED_VARS
54 if(module MATCHES "Development")
55 list(INSERT Python_ADDITIONAL_VERSIONS 0 "${Python_FIND_VERSION}")
56 include(${CMAKE_ROOT}/Modules/FindPythonLibs.cmake)
57 set(Python_Development_FOUND ${PYTHONLIBS_FOUND})
58 set(Python_VERSION ${PYTHONLIBS_VERSION_STRING})
59 set(Python_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS})
60 set(Python_LIBRARIES ${PYTHON_LIBRARIES})
61 if(Python_FIND_REQUIRED_Development)
62 list(APPEND Python_REQUIRED_VARS
69 find_package_handle_standard_args(Python
73 ${Python_REQUIRED_VARS}
79 include(${CMAKE_ROOT}/Modules/FindPython.cmake)