Find Python 2 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, Development and NumPy, specify all components at the same time:
find_package (Python2 COMPONENTS Interpreter Development)
This module looks only for version 2 of Python. This module can be used concurrently with FindPython3 module to use both Python versions.
The FindPython module can be used if Python version does not matter for you.
Note
If components Interpreter and Development are both specified, this module search only for interpreter with same platform architecture as the one defined by CMake configuration. This contraint does not apply if only Interpreter component is specified.
This module defines the following Imported Targets (when CMAKE_ROLE is PROJECT):
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 Python2_FIND_REGISTRY variable determine the order of preference between registry and environment variables. the Python2_FIND_REGISTRY variable can be set to empty or one of the following:
On macOS 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 Python2_add_library (when CMAKE_ROLE is PROJECT), which has the same semantics as add_library(), but takes care of Python module naming rules (only applied if library is of type MODULE), and adds a dependency to target Python2::Python:
Python2_add_library (my_module MODULE src1.cpp)
If library type is not specified, MODULE is assumed.