A short-hand signature is:
find_path (<VAR> name1 [path1 path2 ...])
The general signature is:
find_path ( <VAR> name | NAMES name1 [name2 ...] [HINTS path1 [path2 ... ENV var]] [PATHS path1 [path2 ... ENV var]] [PATH_SUFFIXES suffix1 [suffix2 ...]] [DOC "cache documentation string"] [NO_DEFAULT_PATH] [NO_CMAKE_ENVIRONMENT_PATH] [NO_CMAKE_PATH] [NO_SYSTEM_ENVIRONMENT_PATH] [NO_CMAKE_SYSTEM_PATH] [CMAKE_FIND_ROOT_PATH_BOTH | ONLY_CMAKE_FIND_ROOT_PATH | NO_CMAKE_FIND_ROOT_PATH] )
This command is used to find a directory containing the named file.
A cache entry named by
<VAR> is created to store the result
of this command.
If the file in a directory is found the result is stored in the variable
and the search will not be repeated unless the variable is cleared.
If nothing is found, the result will be
<VAR>-NOTFOUND, and the search will be attempted again the
next time find_path is invoked with the same variable.
Specify one or more possible names for the file in a directory.
When using this to specify names with and without a version suffix, we recommend specifying the unversioned name first so that locally-built packages can be found before those provided by distributions.
- Specify directories to search in addition to the default locations.
ENV varsub-option reads paths from a system environment variable.
- Specify additional subdirectories to check below each directory location otherwise considered.
- Specify the documentation string for the
NO_DEFAULT_PATH is specified, then no additional paths are
added to the search.
NO_DEFAULT_PATH is not specified, the search process is as follows:
- Search paths specified in cmake-specific cache variables.
These are intended to be used on the command line with a
-DVAR=value. This can be skipped if
- Search paths specified in cmake-specific environment variables.
These are intended to be set in the user’s shell configuration.
This can be skipped if
- Search the paths specified by the
HINTSoption. These should be paths computed by system introspection, such as a hint provided by the location of another item already found. Hard-coded guesses should be specified with the
- Search the standard system environment variables.
This can be skipped if
NO_SYSTEM_ENVIRONMENT_PATHis an argument.
- Directories in
INCLUDE. On Windows hosts:
CMAKE_LIBRARY_ARCHITECTUREis set, and
<entry>/includefor other entries in
PATH, and the directories in
- Directories in
- Search cmake variables defined in the Platform files
for the current system. This can be skipped if
- Search the paths specified by the PATHS option or in the short-hand version of the command. These are typically hard-coded guesses.
The CMake variable
CMAKE_FIND_ROOT_PATH specifies one or more
directories to be prepended to all other search directories. This
effectively “re-roots” the entire search under given locations.
Paths which are descendants of the
CMAKE_STAGING_PREFIX are excluded
from this re-rooting, because that variable is always a path on the host system.
By default the
CMAKE_FIND_ROOT_PATH is empty.
These variables are especially useful when cross-compiling to
point to the root directory of the target environment and CMake will
search there too. By default at first the directories listed in
CMAKE_FIND_ROOT_PATH are searched, then the
directory is searched, and then the non-rooted directories will be
searched. The default behavior can be adjusted by setting
CMAKE_FIND_ROOT_PATH_MODE_INCLUDE. This behavior can be manually
overridden on a per-call basis using options:
- Search in the order described above.
- Do not use the
- Search only the re-rooted directories and directories below
The default search order is designed to be most-specific to
least-specific for common use cases.
Projects may override the order by simply calling the command
multiple times and using the
find_path (<VAR> NAMES name PATHS paths... NO_DEFAULT_PATH) find_path (<VAR> NAMES name)
Once one of the calls succeeds the result variable will be set and stored in the cache so that no call will search again.
When searching for frameworks, if the file is specified as
the framework search will look for
A.framework/Headers/b.h. If that
is found the path will be set to the path to the framework. CMake
will convert this to the correct
-F option to include the file.