FindPython2.cmake 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. FindPython2
  5. -----------
  6. Find Python 2 interpreter, compiler and development environment (include
  7. directories and libraries).
  8. Three components are supported:
  9. * ``Interpreter``: search for Python 2 interpreter
  10. * ``Compiler``: search for Python 2 compiler. Only offered by IronPython.
  11. * ``Development``: search for development artifacts (include directories and
  12. libraries)
  13. If no ``COMPONENTS`` is specified, ``Interpreter`` is assumed.
  14. To ensure consistent versions between components ``Interpreter``, ``Compiler``
  15. and ``Development``, specify all components at the same time::
  16. find_package (Python2 COMPONENTS Interpreter Development)
  17. This module looks only for version 2 of Python. This module can be used
  18. concurrently with :module:`FindPython3` module to use both Python versions.
  19. The :module:`FindPython` module can be used if Python version does not matter
  20. for you.
  21. Imported Targets
  22. ^^^^^^^^^^^^^^^^
  23. This module defines the following :ref:`Imported Targets <Imported Targets>`
  24. (when :prop_gbl:`CMAKE_ROLE` is ``PROJECT``):
  25. ``Python2::Interpreter``
  26. Python 2 interpreter. Target defined if component ``Interpreter`` is found.
  27. ``Python2::Compiler``
  28. Python 2 compiler. Target defined if component ``Compiler`` is found.
  29. ``Python2::Python``
  30. Python 2 library. Target defined if component ``Development`` is found.
  31. Result Variables
  32. ^^^^^^^^^^^^^^^^
  33. This module will set the following variables in your project
  34. (see :ref:`Standard Variable Names <CMake Developer Standard Variable Names>`):
  35. ``Python2_FOUND``
  36. System has the Python 2 requested components.
  37. ``Python2_Interpreter_FOUND``
  38. System has the Python 2 interpreter.
  39. ``Python2_EXECUTABLE``
  40. Path to the Python 2 interpreter.
  41. ``Python2_INTERPRETER_ID``
  42. A short string unique to the interpreter. Possible values include:
  43. * Python
  44. * ActivePython
  45. * Anaconda
  46. * Canopy
  47. * IronPython
  48. ``Python2_STDLIB``
  49. Standard platform independent installation directory.
  50. Information returned by
  51. ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True)``.
  52. ``Python2_STDARCH``
  53. Standard platform dependent installation directory.
  54. Information returned by
  55. ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True)``.
  56. ``Python2_SITELIB``
  57. Third-party platform independent installation directory.
  58. Information returned by
  59. ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)``.
  60. ``Python2_SITEARCH``
  61. Third-party platform dependent installation directory.
  62. Information returned by
  63. ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)``.
  64. ``Python2_Compiler_FOUND``
  65. System has the Python 2 compiler.
  66. ``Python2_COMPILER``
  67. Path to the Python 2 compiler. Only offered by IronPython.
  68. ``Python2_COMPILER_ID``
  69. A short string unique to the compiler. Possible values include:
  70. * IronPython
  71. ``Python2_Development_FOUND``
  72. System has the Python 2 development artifacts.
  73. ``Python2_INCLUDE_DIRS``
  74. The Python 2 include directories.
  75. ``Python2_LIBRARIES``
  76. The Python 2 libraries.
  77. ``Python2_LIBRARY_DIRS``
  78. The Python 2 library directories.
  79. ``Python2_RUNTIME_LIBRARY_DIRS``
  80. The Python 2 runtime library directories.
  81. ``Python2_VERSION``
  82. Python 2 version.
  83. ``Python2_VERSION_MAJOR``
  84. Python 2 major version.
  85. ``Python2_VERSION_MINOR``
  86. Python 2 minor version.
  87. ``Python2_VERSION_PATCH``
  88. Python 2 patch version.
  89. Hints
  90. ^^^^^
  91. ``Python2_ROOT_DIR``
  92. Define the root directory of a Python 2 installation.
  93. ``Python2_USE_STATIC_LIBS``
  94. * If not defined, search for shared libraries and static libraries in that
  95. order.
  96. * If set to TRUE, search **only** for static libraries.
  97. * If set to FALSE, search **only** for shared libraries.
  98. ``Python2_FIND_REGISTRY``
  99. On Windows the ``Python2_FIND_REGISTRY`` variable determine the order
  100. of preference between registry and environment variables.
  101. the ``Python2_FIND_REGISTRY`` variable can be set to empty or one of the
  102. following:
  103. * ``FIRST``: Try to use registry before environment variables.
  104. This is the default.
  105. * ``LAST``: Try to use registry after environment variables.
  106. * ``NEVER``: Never try to use registry.
  107. ``CMAKE_FIND_FRAMEWORK``
  108. On macOS the :variable:`CMAKE_FIND_FRAMEWORK` variable determine the order of
  109. preference between Apple-style and unix-style package components.
  110. .. note::
  111. Value ``ONLY`` is not supported so ``FIRST`` will be used instead.
  112. .. note::
  113. If a Python virtual environment is configured, set variable
  114. ``Python_FIND_REGISTRY`` (Windows) or ``CMAKE_FIND_FRAMEWORK`` (macOS) with
  115. value ``LAST`` or ``NEVER`` to select it preferably.
  116. Commands
  117. ^^^^^^^^
  118. This module defines the command ``Python2_add_library`` (when
  119. :prop_gbl:`CMAKE_ROLE` is ``PROJECT``), which has the same semantics as
  120. :command:`add_library`, but takes care of Python module naming rules
  121. (only applied if library is of type ``MODULE``), and adds a dependency to target
  122. ``Python2::Python``::
  123. Python2_add_library (my_module MODULE src1.cpp)
  124. If library type is not specified, ``MODULE`` is assumed.
  125. #]=======================================================================]
  126. set (_PYTHON_PREFIX Python2)
  127. set (_Python2_REQUIRED_VERSION_MAJOR 2)
  128. include (${CMAKE_CURRENT_LIST_DIR}/FindPython/Support.cmake)
  129. if (COMMAND __Python2_add_library)
  130. macro (Python2_add_library)
  131. __Python2_add_library (Python2 ${ARGV})
  132. endmacro()
  133. endif()
  134. unset (_PYTHON_PREFIX)