1 A short-hand signature is:
5 |FIND_XXX| (<VAR> name1 [path1 path2 ...])
7 The general signature is:
14 [HINTS [path | ENV var]... ]
15 [PATHS [path | ENV var]... ]
16 [REGISTRY_VIEW (64|32|64_32|32_64|HOST|TARGET|BOTH)]
17 [PATH_SUFFIXES suffix1 [suffix2 ...]]
19 [DOC "cache documentation string"]
23 [NO_PACKAGE_ROOT_PATH]
25 [NO_CMAKE_ENVIRONMENT_PATH]
26 [NO_SYSTEM_ENVIRONMENT_PATH]
27 [NO_CMAKE_SYSTEM_PATH]
28 [NO_CMAKE_INSTALL_PREFIX]
29 [CMAKE_FIND_ROOT_PATH_BOTH |
30 ONLY_CMAKE_FIND_ROOT_PATH |
31 NO_CMAKE_FIND_ROOT_PATH]
34 This command is used to find a |SEARCH_XXX_DESC|.
35 A cache entry, or a normal variable if ``NO_CACHE`` is specified,
36 named by ``<VAR>`` is created to store the result of this command.
37 If the |SEARCH_XXX| is found the result is stored in the variable
38 and the search will not be repeated unless the variable is cleared.
39 If nothing is found, the result will be ``<VAR>-NOTFOUND``.
44 Specify one or more possible names for the |SEARCH_XXX|.
46 When using this to specify names with and without a version
47 suffix, we recommend specifying the unversioned name first
48 so that locally-built packages can be found before those
49 provided by distributions.
52 Specify directories to search in addition to the default locations.
53 The ``ENV var`` sub-option reads paths from a system environment
56 .. versionchanged:: 3.24
57 On ``Windows`` platform, it is possible to include registry queries as part
58 of the directories, using a :ref:`dedicated syntax <Find Using Windows Registry>`.
59 Such specifications will be ignored on all other platforms.
62 .. versionadded:: 3.24
64 .. include:: FIND_XXX_REGISTRY_VIEW.txt
67 Specify additional subdirectories to check below each directory
68 location otherwise considered.
71 .. versionadded:: 3.25
73 Specify a :command:`function` to be called for each candidate item found
74 (a :command:`macro` cannot be provided, that will result in an error).
75 Two arguments will be passed to the validator function: the name of a
76 result variable, and the absolute path to the candidate item. The item
77 will be accepted and the search will end unless the function sets the
78 value in the result variable to false in the calling scope. The result
79 variable will hold a true value when the validator function is entered.
83 function(my_check validator_result_var item)
84 if(NOT item MATCHES ...)
85 set(${validator_result_var} FALSE PARENT_SCOPE)
89 |FIND_XXX| (result NAMES ... VALIDATOR my_check)
91 Note that if a cached result is used, the search is skipped and any
92 ``VALIDATOR`` is ignored. The cached result is not required to pass the
96 Specify the documentation string for the ``<VAR>`` cache entry.
99 .. versionadded:: 3.21
101 The result of the search will be stored in a normal variable rather than
106 If the variable is already set before the call (as a normal or cache
107 variable) then the search will not occur.
111 This option should be used with caution because it can greatly increase
112 the cost of repeated configure steps.
115 .. versionadded:: 3.18
117 Stop processing with an error message if nothing is found, otherwise
118 the search will be attempted again the next time |FIND_XXX| is invoked
119 with the same variable.
121 If ``NO_DEFAULT_PATH`` is specified, then no additional paths are
123 If ``NO_DEFAULT_PATH`` is not specified, the search process is as follows:
125 .. |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX_SUBDIR| replace::
126 |prefix_XXX_SUBDIR| for each ``<prefix>`` in the
127 :variable:`<PackageName>_ROOT` CMake variable and the
128 :envvar:`<PackageName>_ROOT` environment variable if
129 called from within a find module loaded by
130 :command:`find_package(<PackageName>)`
132 .. |CMAKE_PREFIX_PATH_XXX_SUBDIR| replace::
133 |prefix_XXX_SUBDIR| for each ``<prefix>`` in :variable:`CMAKE_PREFIX_PATH`
135 .. |SYSTEM_ENVIRONMENT_PREFIX_PATH_XXX_SUBDIR| replace::
136 |prefix_XXX_SUBDIR| for each ``<prefix>/[s]bin`` in ``PATH``, and
137 |entry_XXX_SUBDIR| for other entries in ``PATH``
139 .. |CMAKE_SYSTEM_PREFIX_PATH_XXX_SUBDIR| replace::
140 |prefix_XXX_SUBDIR| for each ``<prefix>`` in
141 :variable:`CMAKE_SYSTEM_PREFIX_PATH`
143 1. .. versionadded:: 3.12
144 If called from within a find module or any other script loaded by a call to
145 :command:`find_package(<PackageName>)`, search prefixes unique to the
146 current package being found. Specifically, look in the
147 :variable:`<PackageName>_ROOT` CMake variable and the
148 :envvar:`<PackageName>_ROOT` environment variable.
149 The package root variables are maintained as a stack, so if called from
150 nested find modules or config packages, root paths from the parent's find
151 module or config package will be searched after paths from the current
152 module or package. In other words, the search order would be
153 ``<CurrentPackage>_ROOT``, ``ENV{<CurrentPackage>_ROOT}``,
154 ``<ParentPackage>_ROOT``, ``ENV{<ParentPackage>_ROOT}``, etc.
155 This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting
156 the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``.
157 See policy :policy:`CMP0074`.
159 * |FIND_PACKAGE_ROOT_PREFIX_PATH_XXX|
161 2. Search paths specified in cmake-specific cache variables.
162 These are intended to be used on the command line with a ``-DVAR=value``.
163 The values are interpreted as :ref:`semicolon-separated lists <CMake Language Lists>`.
164 This can be skipped if ``NO_CMAKE_PATH`` is passed or by setting the
165 :variable:`CMAKE_FIND_USE_CMAKE_PATH` to ``FALSE``.
167 * |CMAKE_PREFIX_PATH_XXX|
169 * |CMAKE_XXX_MAC_PATH|
171 3. Search paths specified in cmake-specific environment variables.
172 These are intended to be set in the user's shell configuration,
173 and therefore use the host's native path separator
174 (``;`` on Windows and ``:`` on UNIX).
175 This can be skipped if ``NO_CMAKE_ENVIRONMENT_PATH`` is passed or
176 by setting the :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH` to ``FALSE``.
178 * |CMAKE_PREFIX_PATH_XXX|
180 * |CMAKE_XXX_MAC_PATH|
182 4. Search the paths specified by the ``HINTS`` option.
183 These should be paths computed by system introspection, such as a
184 hint provided by the location of another item already found.
185 Hard-coded guesses should be specified with the ``PATHS`` option.
187 5. Search the standard system environment variables.
188 This can be skipped if ``NO_SYSTEM_ENVIRONMENT_PATH`` is passed or by
189 setting the :variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH` to ``FALSE``.
191 * |SYSTEM_ENVIRONMENT_PATH_XXX|
192 * |SYSTEM_ENVIRONMENT_PATH_WINDOWS_XXX|
194 6. Search cmake variables defined in the Platform files
195 for the current system. The searching of ``CMAKE_INSTALL_PREFIX`` and
196 ``CMAKE_STAGING_PREFIX`` can be
197 skipped if ``NO_CMAKE_INSTALL_PREFIX`` is passed or by setting the
198 :variable:`CMAKE_FIND_USE_INSTALL_PREFIX` to ``FALSE``. All these locations
199 can be skipped if ``NO_CMAKE_SYSTEM_PATH`` is passed or by setting the
200 :variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH` to ``FALSE``.
202 * |CMAKE_SYSTEM_PREFIX_PATH_XXX|
203 * |CMAKE_SYSTEM_XXX_PATH|
204 * |CMAKE_SYSTEM_XXX_MAC_PATH|
206 The platform paths that these variables contain are locations that
207 typically include installed software. An example being ``/usr/local`` for
208 UNIX based platforms.
210 7. Search the paths specified by the PATHS option
211 or in the short-hand version of the command.
212 These are typically hard-coded guesses.
214 The :variable:`CMAKE_IGNORE_PATH`, :variable:`CMAKE_IGNORE_PREFIX_PATH`,
215 :variable:`CMAKE_SYSTEM_IGNORE_PATH` and
216 :variable:`CMAKE_SYSTEM_IGNORE_PREFIX_PATH` variables can also cause some
217 of the above locations to be ignored.
219 .. versionadded:: 3.16
220 Added ``CMAKE_FIND_USE_<CATEGORY>_PATH`` variables to globally disable
221 various search locations.
223 .. |FIND_ARGS_XXX| replace:: <VAR> NAMES name
225 On macOS the :variable:`CMAKE_FIND_FRAMEWORK` and
226 :variable:`CMAKE_FIND_APPBUNDLE` variables determine the order of
227 preference between Apple-style and unix-style package components.
229 .. include:: FIND_XXX_ROOT.txt
230 .. include:: FIND_XXX_ORDER.txt