FIND_XXX.txt 6.7 KB

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