1
0

FIND_XXX.txt 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  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 [path | ENV var]... ]
  10. [PATHS [path | ENV var]... ]
  11. [REGISTRY_VIEW (64|32|64_32|32_64|HOST|TARGET|BOTH)]
  12. [PATH_SUFFIXES suffix1 [suffix2 ...]]
  13. [VALIDATOR function]
  14. [DOC "cache documentation string"]
  15. [NO_CACHE]
  16. [REQUIRED]
  17. [NO_DEFAULT_PATH]
  18. [NO_PACKAGE_ROOT_PATH]
  19. [NO_CMAKE_PATH]
  20. [NO_CMAKE_ENVIRONMENT_PATH]
  21. [NO_SYSTEM_ENVIRONMENT_PATH]
  22. [NO_CMAKE_SYSTEM_PATH]
  23. [NO_CMAKE_INSTALL_PREFIX]
  24. [CMAKE_FIND_ROOT_PATH_BOTH |
  25. ONLY_CMAKE_FIND_ROOT_PATH |
  26. NO_CMAKE_FIND_ROOT_PATH]
  27. )
  28. This command is used to find a |SEARCH_XXX_DESC|.
  29. A cache entry, or a normal variable if ``NO_CACHE`` is specified,
  30. named by ``<VAR>`` is created to store the result of this command.
  31. If the |SEARCH_XXX| is found the result is stored in the variable
  32. and the search will not be repeated unless the variable is cleared.
  33. If nothing is found, the result will be ``<VAR>-NOTFOUND``.
  34. Options include:
  35. ``NAMES``
  36. Specify one or more possible names for the |SEARCH_XXX|.
  37. When using this to specify names with and without a version
  38. suffix, we recommend specifying the unversioned name first
  39. so that locally-built packages can be found before those
  40. provided by distributions.
  41. ``HINTS``, ``PATHS``
  42. Specify directories to search in addition to the default locations.
  43. The ``ENV var`` sub-option reads paths from a system environment
  44. variable.
  45. .. versionchanged:: 3.24
  46. On ``Windows`` platform, it is possible to include registry queries as part
  47. of the directories, using a :ref:`dedicated syntax <Find Using Windows Registry>`.
  48. Such specifications will be ignored on all other platforms.
  49. ``REGISTRY_VIEW``
  50. .. versionadded:: 3.24
  51. .. include:: FIND_XXX_REGISTRY_VIEW.txt
  52. ``PATH_SUFFIXES``
  53. Specify additional subdirectories to check below each directory
  54. location otherwise considered.
  55. ``VALIDATOR``
  56. .. versionadded:: 3.25
  57. Specify a :command:`function` (a :command:`macro` is not an acceptable
  58. choice) which will be called for each found item. The search ends when
  59. the validation function returns a successful status.
  60. The validation function expects two arguments: output variable name and item
  61. value. By default, the output variable name already holds a ``TRUE`` value.
  62. .. parsed-literal::
  63. function (MY_CHECK output_status item)
  64. if (NOT item MATCHES ...)
  65. set(${output_status} FALSE PARENT_SCOPE)
  66. endif()
  67. endfunction()
  68. |FIND_XXX| (result NAMES ... VALIDATOR my_check)
  69. ``DOC``
  70. Specify the documentation string for the ``<VAR>`` cache entry.
  71. ``NO_CACHE``
  72. .. versionadded:: 3.21
  73. The result of the search will be stored in a normal variable rather than
  74. a cache entry.
  75. .. note::
  76. If the variable is already set before the call (as a normal or cache
  77. variable) then the search will not occur.
  78. .. warning::
  79. This option should be used with caution because it can greatly increase
  80. the cost of repeated configure steps.
  81. ``REQUIRED``
  82. .. versionadded:: 3.18
  83. Stop processing with an error message if nothing is found, otherwise
  84. the search will be attempted again the next time |FIND_XXX| is invoked
  85. with the same variable.
  86. If ``NO_DEFAULT_PATH`` is specified, then no additional paths are
  87. added to the search.
  88. If ``NO_DEFAULT_PATH`` is not specified, the search process is as follows:
  89. .. |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX_SUBDIR| replace::
  90. |prefix_XXX_SUBDIR| for each ``<prefix>`` in the
  91. :variable:`<PackageName>_ROOT` CMake variable and the
  92. :envvar:`<PackageName>_ROOT` environment variable if
  93. called from within a find module loaded by
  94. :command:`find_package(<PackageName>)`
  95. .. |CMAKE_PREFIX_PATH_XXX_SUBDIR| replace::
  96. |prefix_XXX_SUBDIR| for each ``<prefix>`` in :variable:`CMAKE_PREFIX_PATH`
  97. .. |SYSTEM_ENVIRONMENT_PREFIX_PATH_XXX_SUBDIR| replace::
  98. |prefix_XXX_SUBDIR| for each ``<prefix>/[s]bin`` in ``PATH``, and
  99. |entry_XXX_SUBDIR| for other entries in ``PATH``
  100. .. |CMAKE_SYSTEM_PREFIX_PATH_XXX_SUBDIR| replace::
  101. |prefix_XXX_SUBDIR| for each ``<prefix>`` in
  102. :variable:`CMAKE_SYSTEM_PREFIX_PATH`
  103. 1. .. versionadded:: 3.12
  104. If called from within a find module or any other script loaded by a call to
  105. :command:`find_package(<PackageName>)`, search prefixes unique to the
  106. current package being found. Specifically, look in the
  107. :variable:`<PackageName>_ROOT` CMake variable and the
  108. :envvar:`<PackageName>_ROOT` environment variable.
  109. The package root variables are maintained as a stack, so if called from
  110. nested find modules or config packages, root paths from the parent's find
  111. module or config package will be searched after paths from the current
  112. module or package. In other words, the search order would be
  113. ``<CurrentPackage>_ROOT``, ``ENV{<CurrentPackage>_ROOT}``,
  114. ``<ParentPackage>_ROOT``, ``ENV{<ParentPackage>_ROOT}``, etc.
  115. This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting
  116. the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``.
  117. See policy :policy:`CMP0074`.
  118. * |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX|
  119. 2. Search paths specified in cmake-specific cache variables.
  120. These are intended to be used on the command line with a ``-DVAR=value``.
  121. The values are interpreted as :ref:`semicolon-separated lists <CMake Language Lists>`.
  122. This can be skipped if ``NO_CMAKE_PATH`` is passed or by setting the
  123. :variable:`CMAKE_FIND_USE_CMAKE_PATH` to ``FALSE``.
  124. * |CMAKE_PREFIX_PATH_XXX|
  125. * |CMAKE_XXX_PATH|
  126. * |CMAKE_XXX_MAC_PATH|
  127. 3. Search paths specified in cmake-specific environment variables.
  128. These are intended to be set in the user's shell configuration,
  129. and therefore use the host's native path separator
  130. (``;`` on Windows and ``:`` on UNIX).
  131. This can be skipped if ``NO_CMAKE_ENVIRONMENT_PATH`` is passed or
  132. by setting the :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH` to ``FALSE``.
  133. * |CMAKE_PREFIX_PATH_XXX|
  134. * |CMAKE_XXX_PATH|
  135. * |CMAKE_XXX_MAC_PATH|
  136. 4. Search the paths specified by the ``HINTS`` option.
  137. These should be paths computed by system introspection, such as a
  138. hint provided by the location of another item already found.
  139. Hard-coded guesses should be specified with the ``PATHS`` option.
  140. 5. Search the standard system environment variables.
  141. This can be skipped if ``NO_SYSTEM_ENVIRONMENT_PATH`` is passed or by
  142. setting the :variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH` to ``FALSE``.
  143. * |SYSTEM_ENVIRONMENT_PATH_XXX|
  144. * |SYSTEM_ENVIRONMENT_PATH_WINDOWS_XXX|
  145. 6. Search cmake variables defined in the Platform files
  146. for the current system. The searching of ``CMAKE_INSTALL_PREFIX` can be
  147. skipped if ``NO_CMAKE_INSTALL_PREFIX`` is passed or by setting the
  148. :variable:`CMAKE_FIND_USE_INSTALL_PREFIX` to ``FALSE. All these locations
  149. can be skipped if ``NO_CMAKE_SYSTEM_PATH`` is passed or by setting the
  150. :variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH` to ``FALSE``.
  151. * |CMAKE_SYSTEM_PREFIX_PATH_XXX|
  152. * |CMAKE_SYSTEM_XXX_PATH|
  153. * |CMAKE_SYSTEM_XXX_MAC_PATH|
  154. The platform paths that these variables contain are locations that
  155. typically include installed software. An example being ``/usr/local`` for
  156. UNIX based platforms.
  157. 7. Search the paths specified by the PATHS option
  158. or in the short-hand version of the command.
  159. These are typically hard-coded guesses.
  160. The :variable:`CMAKE_IGNORE_PATH`, :variable:`CMAKE_IGNORE_PREFIX_PATH`,
  161. :variable:`CMAKE_SYSTEM_IGNORE_PATH` and
  162. :variable:`CMAKE_SYSTEM_IGNORE_PREFIX_PATH` variables can also cause some
  163. of the above locations to be ignored.
  164. .. versionadded:: 3.16
  165. Added ``CMAKE_FIND_USE_<CATEGORY>_PATH`` variables to globally disable
  166. various search locations.
  167. .. |FIND_ARGS_XXX| replace:: <VAR> NAMES name
  168. On macOS the :variable:`CMAKE_FIND_FRAMEWORK` and
  169. :variable:`CMAKE_FIND_APPBUNDLE` variables determine the order of
  170. preference between Apple-style and unix-style package components.
  171. .. include:: FIND_XXX_ROOT.txt
  172. .. include:: FIND_XXX_ORDER.txt