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