FIND_XXX.txt 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. A short-hand signature is:
  2. .. parsed-literal::
  3. |FIND_XXX| (<VAR> name1 [path1 path2 ...])
  4. The general signature is:
  5. .. parsed-literal::
  6. |FIND_XXX| (
  7. <VAR>
  8. name | |NAMES|
  9. [HINTS path1 [path2 ... ENV var]]
  10. [PATHS path1 [path2 ... ENV var]]
  11. [PATH_SUFFIXES suffix1 [suffix2 ...]]
  12. [DOC "cache documentation string"]
  13. [REQUIRED]
  14. [NO_DEFAULT_PATH]
  15. [NO_PACKAGE_ROOT_PATH]
  16. [NO_CMAKE_PATH]
  17. [NO_CMAKE_ENVIRONMENT_PATH]
  18. [NO_SYSTEM_ENVIRONMENT_PATH]
  19. [NO_CMAKE_SYSTEM_PATH]
  20. [CMAKE_FIND_ROOT_PATH_BOTH |
  21. ONLY_CMAKE_FIND_ROOT_PATH |
  22. NO_CMAKE_FIND_ROOT_PATH]
  23. )
  24. This command is used to find a |SEARCH_XXX_DESC|.
  25. A cache entry named by ``<VAR>`` is created to store the result
  26. of this command.
  27. If the |SEARCH_XXX| is found the result is stored in the variable
  28. and the search will not be repeated unless the variable is cleared.
  29. If nothing is found, the result will be ``<VAR>-NOTFOUND``.
  30. Options include:
  31. ``NAMES``
  32. Specify one or more possible names for the |SEARCH_XXX|.
  33. When using this to specify names with and without a version
  34. suffix, we recommend specifying the unversioned name first
  35. so that locally-built packages can be found before those
  36. provided by distributions.
  37. ``HINTS``, ``PATHS``
  38. Specify directories to search in addition to the default locations.
  39. The ``ENV var`` sub-option reads paths from a system environment
  40. variable.
  41. ``PATH_SUFFIXES``
  42. Specify additional subdirectories to check below each directory
  43. location otherwise considered.
  44. ``DOC``
  45. Specify the documentation string for the ``<VAR>`` cache entry.
  46. ``REQUIRED``
  47. .. versionadded:: 3.18
  48. Stop processing with an error message if nothing is found, otherwise
  49. the search will be attempted again the next time |FIND_XXX| is invoked
  50. with the same variable.
  51. If ``NO_DEFAULT_PATH`` is specified, then no additional paths are
  52. added to the search.
  53. If ``NO_DEFAULT_PATH`` is not specified, the search process is as follows:
  54. .. |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX_SUBDIR| replace::
  55. |prefix_XXX_SUBDIR| for each ``<prefix>`` in the
  56. :variable:`<PackageName>_ROOT` CMake variable and the
  57. :envvar:`<PackageName>_ROOT` environment variable if
  58. called from within a find module loaded by
  59. :command:`find_package(<PackageName>)`
  60. .. |CMAKE_PREFIX_PATH_XXX_SUBDIR| replace::
  61. |prefix_XXX_SUBDIR| for each ``<prefix>`` in :variable:`CMAKE_PREFIX_PATH`
  62. .. |SYSTEM_ENVIRONMENT_PREFIX_PATH_XXX_SUBDIR| replace::
  63. |prefix_XXX_SUBDIR| for each ``<prefix>/[s]bin`` in ``PATH``, and
  64. |entry_XXX_SUBDIR| for other entries in ``PATH``
  65. .. |CMAKE_SYSTEM_PREFIX_PATH_XXX_SUBDIR| replace::
  66. |prefix_XXX_SUBDIR| for each ``<prefix>`` in
  67. :variable:`CMAKE_SYSTEM_PREFIX_PATH`
  68. 1. .. versionadded:: 3.12
  69. If called from within a find module or any other script loaded by a call to
  70. :command:`find_package(<PackageName>)`, search prefixes unique to the
  71. current package being found. Specifically, look in the
  72. :variable:`<PackageName>_ROOT` CMake variable and the
  73. :envvar:`<PackageName>_ROOT` environment variable.
  74. The package root variables are maintained as a stack, so if called from
  75. nested find modules or config packages, root paths from the parent's find
  76. module or config package will be searched after paths from the current
  77. module or package. In other words, the search order would be
  78. ``<CurrentPackage>_ROOT``, ``ENV{<CurrentPackage>_ROOT}``,
  79. ``<ParentPackage>_ROOT``, ``ENV{<ParentPackage>_ROOT}``, etc.
  80. This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting
  81. the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``.
  82. See policy :policy:`CMP0074`.
  83. * |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX|
  84. 2. Search paths specified in cmake-specific cache variables.
  85. These are intended to be used on the command line with a ``-DVAR=value``.
  86. The values are interpreted as :ref:`semicolon-separated lists <CMake Language Lists>`.
  87. This can be skipped if ``NO_CMAKE_PATH`` is passed or by setting the
  88. :variable:`CMAKE_FIND_USE_CMAKE_PATH` to ``FALSE``.
  89. * |CMAKE_PREFIX_PATH_XXX|
  90. * |CMAKE_XXX_PATH|
  91. * |CMAKE_XXX_MAC_PATH|
  92. 3. Search paths specified in cmake-specific environment variables.
  93. These are intended to be set in the user's shell configuration,
  94. and therefore use the host's native path separator
  95. (``;`` on Windows and ``:`` on UNIX).
  96. This can be skipped if ``NO_CMAKE_ENVIRONMENT_PATH`` is passed or
  97. by setting the :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH` to ``FALSE``.
  98. * |CMAKE_PREFIX_PATH_XXX|
  99. * |CMAKE_XXX_PATH|
  100. * |CMAKE_XXX_MAC_PATH|
  101. 4. Search the paths specified by the ``HINTS`` option.
  102. These should be paths computed by system introspection, such as a
  103. hint provided by the location of another item already found.
  104. Hard-coded guesses should be specified with the ``PATHS`` option.
  105. 5. Search the standard system environment variables.
  106. This can be skipped if ``NO_SYSTEM_ENVIRONMENT_PATH`` is passed or by
  107. setting the :variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH` to ``FALSE``.
  108. * |SYSTEM_ENVIRONMENT_PATH_XXX|
  109. * |SYSTEM_ENVIRONMENT_PATH_WINDOWS_XXX|
  110. 6. Search cmake variables defined in the Platform files
  111. for the current system. This can be skipped if ``NO_CMAKE_SYSTEM_PATH``
  112. is passed or by setting the :variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`
  113. to ``FALSE``.
  114. * |CMAKE_SYSTEM_PREFIX_PATH_XXX|
  115. * |CMAKE_SYSTEM_XXX_PATH|
  116. * |CMAKE_SYSTEM_XXX_MAC_PATH|
  117. The platform paths that these variables contain are locations that
  118. typically include installed software. An example being ``/usr/local`` for
  119. UNIX based platforms.
  120. 7. Search the paths specified by the PATHS option
  121. or in the short-hand version of the command.
  122. These are typically hard-coded guesses.
  123. .. versionadded:: 3.16
  124. Added ``CMAKE_FIND_USE_<CATEGORY>_PATH`` variables to globally disable
  125. various search locations.
  126. .. |FIND_ARGS_XXX| replace:: <VAR> NAMES name
  127. On macOS the :variable:`CMAKE_FIND_FRAMEWORK` and
  128. :variable:`CMAKE_FIND_APPBUNDLE` variables determine the order of
  129. preference between Apple-style and unix-style package components.
  130. .. include:: FIND_XXX_ROOT.txt
  131. .. include:: FIND_XXX_ORDER.txt