change code style in src/math.c
[liba.git] / cmake / FindPython.cmake
blob8f6a62309e1f4a04bb0ac7c56d4c8c150aa5f2dc
1 #.rst:
2 # FindPython
3 # ----------
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
9 # Result Variables
10 # ^^^^^^^^^^^^^^^^
12 # This module defines the following variables:
14 # ``Python_FOUND``
16 # ``Python_Interpreter_FOUND``
18 # ``Python_EXECUTABLE``
20 # ``Python_Development_FOUND``
22 # ``Python_INCLUDE_DIRS``
24 # ``Python_LIBRARIES``
26 # ``Python_VERSION``
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)
37   endif()
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
50           Python_EXECUTABLE
51         )
52       endif()
53     endif()
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
63           Python_INCLUDE_DIRS
64           Python_LIBRARIES
65         )
66       endif()
67     endif()
68   endforeach()
69   find_package_handle_standard_args(Python
70     FOUND_VAR
71       Python_FOUND
72     REQUIRED_VARS
73       ${Python_REQUIRED_VARS}
74     VERSION_VAR
75       Python_VERSION
76     HANDLE_COMPONENTS
77   )
78 else()
79   include(${CMAKE_ROOT}/Modules/FindPython.cmake)
80 endif()