5 # Find Python components such as the interpreter, C libraries, or Python modules. 7 # This module uses find_package to look for these components using the 8 # specialized Find modules named FindPythonInterp.cmake, FindPythonLibs.cmake, 9 # and FindPythonModules.cmake. A Python_FIND_COMPONENTS list entry that does 10 # not match either "Interp" or "Libs" is assumed to be the name of a Python 11 # module to be searched. See the aforementioned Find modules for more details. 13 #============================================================================= 14 # Copyright 2016 Andreas Schuh <andreas.schuh.84@gmail.com> 16 # Distributed under the OSI-approved BSD License (the "License"); 17 # see accompanying file Copyright.txt for details. 19 # This software is distributed WITHOUT ANY WARRANTY; without even the 20 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 21 # See the License for more information. 22 #============================================================================= 23 # (To distribute this file outside of CMake, substitute the full 24 # License text for the above reference.) 26 # ------------------------------------------------------------------------------ 27 # Components to look for 31 set (_Python_FIND_Modules_OPTIONAL)
32 set (_Python_FIND_Modules_REQUIRED)
35 set (Python_FIND_COMPONENTS Interp)
38 foreach (_Python_COMPONENT IN LISTS Python_FIND_COMPONENTS)
39 if (_Python_COMPONENT MATCHES
"^(Interp|Libs)$")
40 set (_Python_FIND_${_Python_COMPONENT} TRUE)
43 if (Python_FIND_REQUIRED_${_Python_COMPONENT})
44 list (APPEND _Python_FIND_Modules_REQUIRED ${_Python_COMPONENT})
46 list (APPEND _Python_FIND_Modules_OPTIONAL ${_Python_COMPONENT})
51 # ------------------------------------------------------------------------------ 53 if (NOT Python_FIND_QUIETLY)
55 if (NOT Python_FIND_REQUIRED)
58 message(STATUS
"${_Python_FIND_STATUS}...")
61 # ------------------------------------------------------------------------------ 62 # Look for Python components 63 set (_Python_REQUIRED_VARS)
68 list (APPEND _Python_REQUIRED_VARS PYTHON_EXECUTABLE)
74 list (APPEND _Python_REQUIRED_VARS PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS)
77 if (Python_FIND_Modules)
79 COMPONENTS ${Python_FIND_Modules_REQUIRED}
80 OPTIONAL_COMPONENTS ${Python_FIND_Modules_OPTIONAL}
82 foreach (_Python_COMPONENT IN LISTS _Python_FIND_Modules_REQUIRED _Python_FIND_Modules_OPTIONAL)
83 set (Python_${_Python_COMPONENT}_FOUND ${PythonModules_${_Python_COMPONENT}_FOUND})
87 # ------------------------------------------------------------------------------ 88 # Handle QUIET, REQUIRED, and [EXACT] VERSION arguments and set Python_FOUND 95 if (_Python_REQUIRED_VARS)
96 include(FindPackageHandleStandardArgs)
97 find_package_handle_standard_args(Python
98 REQUIRED_VARS ${_Python_REQUIRED_VARS}
107 # ------------------------------------------------------------------------------ 109 if (NOT Python_FIND_QUIETLY)
112 message(STATUS
"${_Python_FIND_STATUS}... - found v${_Python_VERSION}")
121 # ------------------------------------------------------------------------------ 122 # Unset local variables 123 unset (_Python_VERSION) 124 unset (_Python_FIND_STATUS) 125 unset (_Python_FIND_Interp) 126 unset (_Python_FIND_Libs) 127 unset (_Python_FIND_Modules) 128 unset (_Python_FIND_Modules_REQUIRED) 129 unset (_Python_FIND_Modules_OPTIONAL) 130 unset (_Python_COMPONENT) 131 unset (_Python_REQUIRED_VARS) cmake Python_Interp_FOUND
cmake _Python_FIND_STATUS
cmake _Python_FIND_Interp
cmake _Python_FIND_Modules
macro find_package()
Overloaded find_package() command.
cmake Python_FIND_COMPONENTS
cmake PYTHON_VERSION_STRING