]> git.proxmox.com Git - ceph.git/blob - ceph/cmake/modules/FindPython3.cmake
import 15.2.9
[ceph.git] / ceph / cmake / modules / FindPython3.cmake
1 # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
3
4 #[=======================================================================[.rst:
5 FindPython3
6 -----------
7
8 Find Python 3 interpreter, compiler and development environment (include
9 directories and libraries).
10
11 Three components are supported:
12
13 * ``Interpreter``: search for Python 3 interpreter
14 * ``Compiler``: search for Python 3 compiler. Only offered by IronPython.
15 * ``Development``: search for development artifacts (include directories and
16 libraries)
17 * ``NumPy``: search for NumPy include directories.
18
19 If no ``COMPONENTS`` is specified, ``Interpreter`` is assumed.
20
21 To ensure consistent versions between components ``Interpreter``, ``Compiler``,
22 ``Development`` and ``NumPy``, specify all components at the same time::
23
24 find_package (Python3 COMPONENTS Interpreter Development)
25
26 This module looks only for version 3 of Python. This module can be used
27 concurrently with :module:`FindPython2` module to use both Python versions.
28
29 The :module:`FindPython` module can be used if Python version does not matter
30 for you.
31
32 .. note::
33
34 If components ``Interpreter`` and ``Development`` are both specified, this
35 module search only for interpreter with same platform architecture as the one
36 defined by ``CMake`` configuration. This contraint does not apply if only
37 ``Interpreter`` component is specified.
38
39 Imported Targets
40 ^^^^^^^^^^^^^^^^
41
42 This module defines the following :ref:`Imported Targets <Imported Targets>`
43 (when :prop_gbl:`CMAKE_ROLE` is ``PROJECT``):
44
45 ``Python3::Interpreter``
46 Python 3 interpreter. Target defined if component ``Interpreter`` is found.
47 ``Python3::Compiler``
48 Python 3 compiler. Target defined if component ``Compiler`` is found.
49 ``Python3::Python``
50 Python 3 library. Target defined if component ``Development`` is found.
51 ``Python3::NumPy``
52 NumPy library for Python 3. Target defined if component ``NumPy`` is found.
53
54 Result Variables
55 ^^^^^^^^^^^^^^^^
56
57 This module will set the following variables in your project
58 (see :ref:`Standard Variable Names <CMake Developer Standard Variable Names>`):
59
60 ``Python3_FOUND``
61 System has the Python 3 requested components.
62 ``Python3_Interpreter_FOUND``
63 System has the Python 3 interpreter.
64 ``Python3_EXECUTABLE``
65 Path to the Python 3 interpreter.
66 ``Python3_INTERPRETER_ID``
67 A short string unique to the interpreter. Possible values include:
68 * Python
69 * ActivePython
70 * Anaconda
71 * Canopy
72 * IronPython
73 ``Python3_STDLIB``
74 Standard platform independent installation directory.
75
76 Information returned by
77 ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True)``.
78 ``Python3_STDARCH``
79 Standard platform dependent installation directory.
80
81 Information returned by
82 ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True)``.
83 ``Python3_SITELIB``
84 Third-party platform independent installation directory.
85
86 Information returned by
87 ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)``.
88 ``Python3_SITEARCH``
89 Third-party platform dependent installation directory.
90
91 Information returned by
92 ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)``.
93 ``Python3_Compiler_FOUND``
94 System has the Python 3 compiler.
95 ``Python3_COMPILER``
96 Path to the Python 3 compiler. Only offered by IronPython.
97 ``Python3_COMPILER_ID``
98 A short string unique to the compiler. Possible values include:
99 * IronPython
100 ``Python3_Development_FOUND``
101 System has the Python 3 development artifacts.
102 ``Python3_INCLUDE_DIRS``
103 The Python 3 include directories.
104 ``Python3_LIBRARIES``
105 The Python 3 libraries.
106 ``Python3_LIBRARY_DIRS``
107 The Python 3 library directories.
108 ``Python3_RUNTIME_LIBRARY_DIRS``
109 The Python 3 runtime library directories.
110 ``Python3_VERSION``
111 Python 3 version.
112 ``Python3_VERSION_MAJOR``
113 Python 3 major version.
114 ``Python3_VERSION_MINOR``
115 Python 3 minor version.
116 ``Python3_VERSION_PATCH``
117 Python 3 patch version.
118 ``Python3_NumPy_FOUND``
119 System has the NumPy.
120 ``Python3_NumPy_INCLUDE_DIRS``
121 The NumPy include directries.
122 ``Python3_NumPy_VERSION``
123 The NumPy version.
124
125 Hints
126 ^^^^^
127
128 ``Python3_ROOT_DIR``
129 Define the root directory of a Python 3 installation.
130
131 ``Python3_USE_STATIC_LIBS``
132 * If not defined, search for shared libraries and static libraries in that
133 order.
134 * If set to TRUE, search **only** for static libraries.
135 * If set to FALSE, search **only** for shared libraries.
136
137 ``Python3_FIND_REGISTRY``
138 On Windows the ``Python3_FIND_REGISTRY`` variable determine the order
139 of preference between registry and environment variables.
140 the ``Python3_FIND_REGISTRY`` variable can be set to empty or one of the
141 following:
142
143 * ``FIRST``: Try to use registry before environment variables.
144 This is the default.
145 * ``LAST``: Try to use registry after environment variables.
146 * ``NEVER``: Never try to use registry.
147
148 ``CMAKE_FIND_FRAMEWORK``
149 On OS X the :variable:`CMAKE_FIND_FRAMEWORK` variable determine the order of
150 preference between Apple-style and unix-style package components.
151
152 .. note::
153
154 Value ``ONLY`` is not supported so ``FIRST`` will be used instead.
155
156 .. note::
157
158 If a Python virtual environment is configured, set variable
159 ``Python_FIND_REGISTRY`` (Windows) or ``CMAKE_FIND_FRAMEWORK`` (macOS) with
160 value ``LAST`` or ``NEVER`` to select it preferably.
161
162 Commands
163 ^^^^^^^^
164
165 This module defines the command ``Python3_add_library`` (when
166 :prop_gbl:`CMAKE_ROLE` is ``PROJECT``), which has the same semantics as
167 :command:`add_library`, but takes care of Python module naming rules
168 (only applied if library is of type ``MODULE``), and adds a dependency to target
169 ``Python3::Python``::
170
171 Python3_add_library (my_module MODULE src1.cpp)
172
173 If library type is not specified, ``MODULE`` is assumed.
174 #]=======================================================================]
175
176
177 set (_PYTHON_PREFIX Python3)
178
179 set (_Python3_REQUIRED_VERSION_MAJOR 3)
180
181 include (${CMAKE_CURRENT_LIST_DIR}/FindPython/Support.cmake)
182
183 if (COMMAND __Python3_add_library)
184 macro (Python3_add_library)
185 __Python3_add_library (Python3 ${ARGV})
186 endmacro()
187 endif()
188
189 unset (_PYTHON_PREFIX)