FindPython3.cmake 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. FindPython3
  5. -----------
  6. Find Python 3 interpreter, compiler and development environment (include
  7. directories and libraries).
  8. Three components are supported:
  9. * ``Interpreter``: search for Python 3 interpreter
  10. * ``Compiler``: search for Python 3 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 (Python3 COMPONENTS Interpreter Development)
  17. This module looks only for version 3 of Python. This module can be used
  18. concurrently with :module:`FindPython2` 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. ``Python3::Interpreter``
  25. Python 3 interpreter. Target defined if component ``Interpreter`` is found.
  26. ``Python3::Compiler``
  27. Python 3 compiler. Target defined if component ``Compiler`` is found.
  28. ``Python3::Python``
  29. Python 3 library. Target defined if component ``Development`` is found.
  30. Result Variables
  31. ^^^^^^^^^^^^^^^^
  32. This module will set the following variables in your project
  33. (see :ref:`Standard Variable Names <CMake Developer Standard Variable Names>`):
  34. ``Python3_FOUND``
  35. System has the Python 3 requested components.
  36. ``Python3_Interpreter_FOUND``
  37. System has the Python 3 interpreter.
  38. ``Python3_EXECUTABLE``
  39. Path to the Python 3 interpreter.
  40. ``Python3_INTERPRETER_ID``
  41. A short string unique to the interpreter. Possible values include:
  42. * Python
  43. * ActivePython
  44. * Anaconda
  45. * Canopy
  46. * IronPython
  47. ``Python3_STDLIB``
  48. Standard platform independent installation directory.
  49. Information returned by
  50. ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True)``.
  51. ``Python3_STDARCH``
  52. Standard platform dependent installation directory.
  53. Information returned by
  54. ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True)``.
  55. ``Python3_SITELIB``
  56. Third-party platform independent installation directory.
  57. Information returned by
  58. ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)``.
  59. ``Python3_SITEARCH``
  60. Third-party platform dependent installation directory.
  61. Information returned by
  62. ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)``.
  63. ``Python3_Compiler_FOUND``
  64. System has the Python 3 compiler.
  65. ``Python3_COMPILER``
  66. Path to the Python 3 compiler. Only offered by IronPython.
  67. ``Python3_COMPILER_ID``
  68. A short string unique to the compiler. Possible values include:
  69. * IronPython
  70. ``Python3_Development_FOUND``
  71. System has the Python 3 development artifacts.
  72. ``Python3_INCLUDE_DIRS``
  73. The Python 3 include directories.
  74. ``Python3_LIBRARIES``
  75. The Python 3 libraries.
  76. ``Python3_LIBRARY_DIRS``
  77. The Python 3 library directories.
  78. ``Python3_RUNTIME_LIBRARY_DIRS``
  79. The Python 3 runtime library directories.
  80. ``Python3_VERSION``
  81. Python 3 version.
  82. ``Python3_VERSION_MAJOR``
  83. Python 3 major version.
  84. ``Python3_VERSION_MINOR``
  85. Python 3 minor version.
  86. ``Python3_VERSION_PATCH``
  87. Python 3 patch version.
  88. Hints
  89. ^^^^^
  90. ``Python3_ROOT_DIR``
  91. Define the root directory of a Python 3 installation.
  92. ``Python3_USE_STATIC_LIBS``
  93. * If not defined, search for shared libraries and static libraries in that
  94. order.
  95. * If set to TRUE, search **only** for static libraries.
  96. * If set to FALSE, search **only** for shared libraries.
  97. Commands
  98. ^^^^^^^^
  99. This module defines the command ``Python3_add_library`` which have the same
  100. semantic as :command:`add_library` but take care of Python module naming rules
  101. (only applied if library is of type ``MODULE``) and add dependency to target
  102. ``Python3::Python``::
  103. Python3_add_library (my_module MODULE src1.cpp)
  104. If library type is not specified, ``MODULE`` is assumed.
  105. #]=======================================================================]
  106. set (_PYTHON_PREFIX Python3)
  107. set (_Python3_REQUIRED_VERSION_MAJOR 3)
  108. include (${CMAKE_CURRENT_LIST_DIR}/FindPython/Support.cmake)
  109. if (COMMAND __Python3_add_library)
  110. macro (Python3_add_library)
  111. __Python3_add_library (Python3 ${ARGV})
  112. endmacro()
  113. endif()
  114. unset (_PYTHON_PREFIX)