Find Python interpreter, compiler and development environment (include directories and libraries).
Three components are supported:
If no COMPONENTS is specified, Interpreter is assumed.
To ensure consistent versions between components Interpreter, Compiler and Development, specify all components at the same time:
find_package (Python COMPONENTS Interpreter Development)
This module looks preferably for version 3 of Python. If not found, version 2 is searched. To manage concurrent versions 3 and 2 of Python, use FindPython3 and FindPython2 modules rather than this one.
This module defines the following Imported Targets:
This module will set the following variables in your project (see Standard Variable Names):
Standard platform independent installation directory.
Information returned by distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True).
Standard platform dependent installation directory.
Information returned by distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True).
Third-party platform independent installation directory.
Information returned by distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False).
Third-party platform dependent installation directory.
Information returned by distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False).
On Windows the Python_FIND_REGISTRY variable determine the order of preference between registry and environment variables. the Python_FIND_REGISTRY variable can be set to empty or one of the following:
On OS X the CMAKE_FIND_FRAMEWORK variable determine the order of preference between Apple-style and unix-style package components.
Note
Value ONLY is not supported so FIRST will be used instead.
Note
If a Python virtual environment is configured, set variable Python_FIND_REGISTRY (Windows) or CMAKE_FIND_FRAMEWORK (macOS) with value LAST or NEVER to select it preferably.
This module defines the command Python_add_library which have the same semantic as add_library() but take care of Python module naming rules (only applied if library is of type MODULE) and add dependency to target Python::Python:
Python_add_library (my_module MODULE src1.cpp)
If library type is not specified, MODULE is assumed.