Find Python 3 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 (Python3 COMPONENTS Interpreter Development)
This module looks only for version 3 of Python. This module can be used concurrently with FindPython2 module to use both Python versions.
The FindPython module can be used if Python version does not matter for you.
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 Python3_FIND_REGISTRY variable determine the order of preference between registry and environment variables. the Python3_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 Python3_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 Python3::Python:
Python3_add_library (my_module MODULE src1.cpp)
If library type is not specified, MODULE is assumed.