find_package.rst 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. find_package
  2. ------------
  3. .. only:: html
  4. .. contents::
  5. Find an external project, and load its settings.
  6. .. _`basic signature`:
  7. Basic Signature and Module Mode
  8. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  9. .. code-block:: cmake
  10. find_package(<PackageName> [version] [EXACT] [QUIET] [MODULE]
  11. [REQUIRED] [[COMPONENTS] [components...]]
  12. [OPTIONAL_COMPONENTS components...]
  13. [NO_POLICY_SCOPE])
  14. Finds and loads settings from an external project. ``<PackageName>_FOUND``
  15. will be set to indicate whether the package was found. When the
  16. package is found package-specific information is provided through
  17. variables and :ref:`Imported Targets` documented by the package itself. The
  18. ``QUIET`` option disables informational messages, including those indicating
  19. that the package cannot be found if it is not ``REQUIRED``. The ``REQUIRED``
  20. option stops processing with an error message if the package cannot be found.
  21. A package-specific list of required components may be listed after the
  22. ``COMPONENTS`` option (or after the ``REQUIRED`` option if present).
  23. Additional optional components may be listed after
  24. ``OPTIONAL_COMPONENTS``. Available components and their influence on
  25. whether a package is considered to be found are defined by the target
  26. package.
  27. .. _FIND_PACKAGE_VERSION_FORMAT:
  28. The ``[version]`` argument requests a version with which the package found
  29. should be compatible. There are two possible forms in which it may be
  30. specified:
  31. * A single version with the format ``major[.minor[.patch[.tweak]]]``.
  32. * A version range with the format ``versionMin...[<]versionMax`` where
  33. ``versionMin`` and ``versionMax`` have the same format as the single
  34. version. By default, both end points are included. By specifying ``<``,
  35. the upper end point will be excluded. Version ranges are only supported
  36. with CMake 3.19 or later.
  37. The ``EXACT`` option requests that the version be matched exactly. This option
  38. is incompatible with the specification of a version range.
  39. If no ``[version]`` and/or component list is given to a recursive invocation
  40. inside a find-module, the corresponding arguments are forwarded
  41. automatically from the outer call (including the ``EXACT`` flag for
  42. ``[version]``). Version support is currently provided only on a
  43. package-by-package basis (see the `Version Selection`_ section below).
  44. When a version range is specified but the package is only designed to expect
  45. a single version, the package will ignore the upper end point of the range and
  46. only take the single version at the lower end of the range into account.
  47. See the :command:`cmake_policy` command documentation for discussion
  48. of the ``NO_POLICY_SCOPE`` option.
  49. The command has two modes by which it searches for packages: "Module"
  50. mode and "Config" mode. The above signature selects Module mode.
  51. If no module is found the command falls back to Config mode, described
  52. below. This fall back is disabled if the ``MODULE`` option is given.
  53. In Module mode, CMake searches for a file called ``Find<PackageName>.cmake``.
  54. The file is first searched in the :variable:`CMAKE_MODULE_PATH`,
  55. then among the :ref:`Find Modules` provided by the CMake installation.
  56. If the file is found, it is read and processed by CMake. It is responsible
  57. for finding the package, checking the version, and producing any needed
  58. messages. Some find-modules provide limited or no support for versioning;
  59. check the module documentation.
  60. If the ``MODULE`` option is not specified in the above signature,
  61. CMake first searches for the package using Module mode. Then, if the
  62. package is not found, it searches again using Config mode. A user
  63. may set the variable :variable:`CMAKE_FIND_PACKAGE_PREFER_CONFIG` to
  64. ``TRUE`` to direct CMake first search using Config mode before falling
  65. back to Module mode.
  66. Full Signature and Config Mode
  67. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  68. User code should generally look for packages using the above `basic
  69. signature`_. The remainder of this command documentation specifies the
  70. full command signature and details of the search process. Project
  71. maintainers wishing to provide a package to be found by this command
  72. are encouraged to read on.
  73. The complete Config mode command signature is
  74. .. code-block:: cmake
  75. find_package(<PackageName> [version] [EXACT] [QUIET]
  76. [REQUIRED] [[COMPONENTS] [components...]]
  77. [OPTIONAL_COMPONENTS components...]
  78. [CONFIG|NO_MODULE]
  79. [NO_POLICY_SCOPE]
  80. [NAMES name1 [name2 ...]]
  81. [CONFIGS config1 [config2 ...]]
  82. [HINTS path1 [path2 ... ]]
  83. [PATHS path1 [path2 ... ]]
  84. [PATH_SUFFIXES suffix1 [suffix2 ...]]
  85. [NO_DEFAULT_PATH]
  86. [NO_PACKAGE_ROOT_PATH]
  87. [NO_CMAKE_PATH]
  88. [NO_CMAKE_ENVIRONMENT_PATH]
  89. [NO_SYSTEM_ENVIRONMENT_PATH]
  90. [NO_CMAKE_PACKAGE_REGISTRY]
  91. [NO_CMAKE_BUILDS_PATH] # Deprecated; does nothing.
  92. [NO_CMAKE_SYSTEM_PATH]
  93. [NO_CMAKE_SYSTEM_PACKAGE_REGISTRY]
  94. [CMAKE_FIND_ROOT_PATH_BOTH |
  95. ONLY_CMAKE_FIND_ROOT_PATH |
  96. NO_CMAKE_FIND_ROOT_PATH])
  97. The ``CONFIG`` option, the synonymous ``NO_MODULE`` option, or the use
  98. of options not specified in the `basic signature`_ all enforce pure Config
  99. mode. In pure Config mode, the command skips Module mode search and
  100. proceeds at once with Config mode search.
  101. Config mode search attempts to locate a configuration file provided by the
  102. package to be found. A cache entry called ``<PackageName>_DIR`` is created to
  103. hold the directory containing the file. By default the command
  104. searches for a package with the name ``<PackageName>``. If the ``NAMES`` option
  105. is given the names following it are used instead of ``<PackageName>``.
  106. The command searches for a file called ``<PackageName>Config.cmake`` or
  107. ``<lower-case-package-name>-config.cmake`` for each name specified.
  108. A replacement set of possible configuration file names may be given
  109. using the ``CONFIGS`` option. The search procedure is specified below.
  110. Once found, the configuration file is read and processed by CMake.
  111. Since the file is provided by the package it already knows the
  112. location of package contents. The full path to the configuration file
  113. is stored in the cmake variable ``<PackageName>_CONFIG``.
  114. All configuration files which have been considered by CMake while
  115. searching for an installation of the package with an appropriate
  116. version are stored in the cmake variable ``<PackageName>_CONSIDERED_CONFIGS``,
  117. the associated versions in ``<PackageName>_CONSIDERED_VERSIONS``.
  118. If the package configuration file cannot be found CMake will generate
  119. an error describing the problem unless the ``QUIET`` argument is
  120. specified. If ``REQUIRED`` is specified and the package is not found a
  121. fatal error is generated and the configure step stops executing. If
  122. ``<PackageName>_DIR`` has been set to a directory not containing a
  123. configuration file CMake will ignore it and search from scratch.
  124. Package maintainers providing CMake package configuration files are
  125. encouraged to name and install them such that the `Search Procedure`_
  126. outlined below will find them without requiring use of additional options.
  127. Version Selection
  128. ^^^^^^^^^^^^^^^^^
  129. When the ``[version]`` argument is given, Config mode will only find a
  130. version of the package that claims compatibility with the requested
  131. version (see :ref:`format specification <FIND_PACKAGE_VERSION_FORMAT>`). If the
  132. ``EXACT`` option is given, only a version of the package claiming an exact match
  133. of the requested version may be found. CMake does not establish any
  134. convention for the meaning of version numbers. Package version
  135. numbers are checked by "version" files provided by the packages
  136. themselves. For a candidate package configuration file
  137. ``<config-file>.cmake`` the corresponding version file is located next
  138. to it and named either ``<config-file>-version.cmake`` or
  139. ``<config-file>Version.cmake``. If no such version file is available
  140. then the configuration file is assumed to not be compatible with any
  141. requested version. A basic version file containing generic version
  142. matching code can be created using the
  143. :module:`CMakePackageConfigHelpers` module. When a version file
  144. is found it is loaded to check the requested version number. The
  145. version file is loaded in a nested scope in which the following
  146. variables have been defined:
  147. ``PACKAGE_FIND_NAME``
  148. The ``<PackageName>``
  149. ``PACKAGE_FIND_VERSION``
  150. Full requested version string
  151. ``PACKAGE_FIND_VERSION_MAJOR``
  152. Major version if requested, else 0
  153. ``PACKAGE_FIND_VERSION_MINOR``
  154. Minor version if requested, else 0
  155. ``PACKAGE_FIND_VERSION_PATCH``
  156. Patch version if requested, else 0
  157. ``PACKAGE_FIND_VERSION_TWEAK``
  158. Tweak version if requested, else 0
  159. ``PACKAGE_FIND_VERSION_COUNT``
  160. Number of version components, 0 to 4
  161. When a version range is specified, the above version variables will hold
  162. values based on the lower end of the version range. This is to preserve
  163. compatibility with packages that have not been implemented to expect version
  164. ranges. In addition, the version range will be described by the following
  165. variables:
  166. ``PACKAGE_FIND_VERSION_RANGE``
  167. Full requested version range string
  168. ``PACKAGE_FIND_VERSION_RANGE_MIN``
  169. This specifies whether the lower end point of the version range should be
  170. included or excluded. Currently, the only supported value for this variable
  171. is ``INCLUDE``.
  172. ``PACKAGE_FIND_VERSION_RANGE_MAX``
  173. This specifies whether the upper end point of the version range should be
  174. included or excluded. The supported values for this variable are
  175. ``INCLUDE`` and ``EXCLUDE``.
  176. ``PACKAGE_FIND_VERSION_MIN``
  177. Full requested version string of the lower end point of the range
  178. ``PACKAGE_FIND_VERSION_MIN_MAJOR``
  179. Major version of the lower end point if requested, else 0
  180. ``PACKAGE_FIND_VERSION_MIN_MINOR``
  181. Minor version of the lower end point if requested, else 0
  182. ``PACKAGE_FIND_VERSION_MIN_PATCH``
  183. Patch version of the lower end point if requested, else 0
  184. ``PACKAGE_FIND_VERSION_MIN_TWEAK``
  185. Tweak version of the lower end point if requested, else 0
  186. ``PACKAGE_FIND_VERSION_MIN_COUNT``
  187. Number of version components of the lower end point, 0 to 4
  188. ``PACKAGE_FIND_VERSION_MAX``
  189. Full requested version string of the upper end point of the range
  190. ``PACKAGE_FIND_VERSION_MAX_MAJOR``
  191. Major version of the upper end point if requested, else 0
  192. ``PACKAGE_FIND_VERSION_MAX_MINOR``
  193. Minor version of the upper end point if requested, else 0
  194. ``PACKAGE_FIND_VERSION_MAX_PATCH``
  195. Patch version of the upper end point if requested, else 0
  196. ``PACKAGE_FIND_VERSION_MAX_TWEAK``
  197. Tweak version of the upper end point if requested, else 0
  198. ``PACKAGE_FIND_VERSION_MAX_COUNT``
  199. Number of version components of the upper end point, 0 to 4
  200. Regardless of whether a single version or a version range is specified, the
  201. variable ``PACKAGE_FIND_VERSION_COMPLETE`` will be defined and will hold
  202. the full requested version string as specified.
  203. The version file checks whether it satisfies the requested version and
  204. sets these variables:
  205. ``PACKAGE_VERSION``
  206. Full provided version string
  207. ``PACKAGE_VERSION_EXACT``
  208. True if version is exact match
  209. ``PACKAGE_VERSION_COMPATIBLE``
  210. True if version is compatible
  211. ``PACKAGE_VERSION_UNSUITABLE``
  212. True if unsuitable as any version
  213. These variables are checked by the ``find_package`` command to determine
  214. whether the configuration file provides an acceptable version. They
  215. are not available after the ``find_package`` call returns. If the version
  216. is acceptable the following variables are set:
  217. ``<PackageName>_VERSION``
  218. Full provided version string
  219. ``<PackageName>_VERSION_MAJOR``
  220. Major version if provided, else 0
  221. ``<PackageName>_VERSION_MINOR``
  222. Minor version if provided, else 0
  223. ``<PackageName>_VERSION_PATCH``
  224. Patch version if provided, else 0
  225. ``<PackageName>_VERSION_TWEAK``
  226. Tweak version if provided, else 0
  227. ``<PackageName>_VERSION_COUNT``
  228. Number of version components, 0 to 4
  229. and the corresponding package configuration file is loaded.
  230. When multiple package configuration files are available whose version files
  231. claim compatibility with the version requested it is unspecified which
  232. one is chosen: unless the variable :variable:`CMAKE_FIND_PACKAGE_SORT_ORDER`
  233. is set no attempt is made to choose a highest or closest version number.
  234. To control the order in which ``find_package`` checks for compatibility use
  235. the two variables :variable:`CMAKE_FIND_PACKAGE_SORT_ORDER` and
  236. :variable:`CMAKE_FIND_PACKAGE_SORT_DIRECTION`.
  237. For instance in order to select the highest version one can set
  238. .. code-block:: cmake
  239. SET(CMAKE_FIND_PACKAGE_SORT_ORDER NATURAL)
  240. SET(CMAKE_FIND_PACKAGE_SORT_DIRECTION DEC)
  241. before calling ``find_package``.
  242. Search Procedure
  243. ^^^^^^^^^^^^^^^^
  244. CMake constructs a set of possible installation prefixes for the
  245. package. Under each prefix several directories are searched for a
  246. configuration file. The tables below show the directories searched.
  247. Each entry is meant for installation trees following Windows (``W``), UNIX
  248. (``U``), or Apple (``A``) conventions::
  249. <prefix>/ (W)
  250. <prefix>/(cmake|CMake)/ (W)
  251. <prefix>/<name>*/ (W)
  252. <prefix>/<name>*/(cmake|CMake)/ (W)
  253. <prefix>/(lib/<arch>|lib*|share)/cmake/<name>*/ (U)
  254. <prefix>/(lib/<arch>|lib*|share)/<name>*/ (U)
  255. <prefix>/(lib/<arch>|lib*|share)/<name>*/(cmake|CMake)/ (U)
  256. <prefix>/<name>*/(lib/<arch>|lib*|share)/cmake/<name>*/ (W/U)
  257. <prefix>/<name>*/(lib/<arch>|lib*|share)/<name>*/ (W/U)
  258. <prefix>/<name>*/(lib/<arch>|lib*|share)/<name>*/(cmake|CMake)/ (W/U)
  259. On systems supporting macOS :prop_tgt:`FRAMEWORK` and :prop_tgt:`BUNDLE`, the
  260. following directories are searched for Frameworks or Application Bundles
  261. containing a configuration file::
  262. <prefix>/<name>.framework/Resources/ (A)
  263. <prefix>/<name>.framework/Resources/CMake/ (A)
  264. <prefix>/<name>.framework/Versions/*/Resources/ (A)
  265. <prefix>/<name>.framework/Versions/*/Resources/CMake/ (A)
  266. <prefix>/<name>.app/Contents/Resources/ (A)
  267. <prefix>/<name>.app/Contents/Resources/CMake/ (A)
  268. In all cases the ``<name>`` is treated as case-insensitive and corresponds
  269. to any of the names specified (``<PackageName>`` or names given by ``NAMES``).
  270. Paths with ``lib/<arch>`` are enabled if the
  271. :variable:`CMAKE_LIBRARY_ARCHITECTURE` variable is set. ``lib*`` includes one
  272. or more of the values ``lib64``, ``lib32``, ``libx32`` or ``lib`` (searched in
  273. that order).
  274. * Paths with ``lib64`` are searched on 64 bit platforms if the
  275. :prop_gbl:`FIND_LIBRARY_USE_LIB64_PATHS` property is set to ``TRUE``.
  276. * Paths with ``lib32`` are searched on 32 bit platforms if the
  277. :prop_gbl:`FIND_LIBRARY_USE_LIB32_PATHS` property is set to ``TRUE``.
  278. * Paths with ``libx32`` are searched on platforms using the x32 ABI
  279. if the :prop_gbl:`FIND_LIBRARY_USE_LIBX32_PATHS` property is set to ``TRUE``.
  280. * The ``lib`` path is always searched.
  281. If ``PATH_SUFFIXES`` is specified, the suffixes are appended to each
  282. (``W``) or (``U``) directory entry one-by-one.
  283. This set of directories is intended to work in cooperation with
  284. projects that provide configuration files in their installation trees.
  285. Directories above marked with (``W``) are intended for installations on
  286. Windows where the prefix may point at the top of an application's
  287. installation directory. Those marked with (``U``) are intended for
  288. installations on UNIX platforms where the prefix is shared by multiple
  289. packages. This is merely a convention, so all (``W``) and (``U``) directories
  290. are still searched on all platforms. Directories marked with (``A``) are
  291. intended for installations on Apple platforms. The
  292. :variable:`CMAKE_FIND_FRAMEWORK` and :variable:`CMAKE_FIND_APPBUNDLE`
  293. variables determine the order of preference.
  294. The set of installation prefixes is constructed using the following
  295. steps. If ``NO_DEFAULT_PATH`` is specified all ``NO_*`` options are
  296. enabled.
  297. 1. .. versionadded:: 3.12
  298. Search paths specified in the :variable:`<PackageName>_ROOT` CMake
  299. variable and the :envvar:`<PackageName>_ROOT` environment variable,
  300. where ``<PackageName>`` is the package to be found.
  301. The package root variables are maintained as a stack so if
  302. called from within a find module, root paths from the parent's find
  303. module will also be searched after paths for the current package.
  304. This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting
  305. the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``.
  306. See policy :policy:`CMP0074`.
  307. 2. Search paths specified in cmake-specific cache variables. These
  308. are intended to be used on the command line with a ``-DVAR=value``.
  309. The values are interpreted as :ref:`semicolon-separated lists <CMake Language Lists>`.
  310. This can be skipped if ``NO_CMAKE_PATH`` is passed or by setting the
  311. :variable:`CMAKE_FIND_USE_CMAKE_PATH` to ``FALSE``:
  312. * :variable:`CMAKE_PREFIX_PATH`
  313. * :variable:`CMAKE_FRAMEWORK_PATH`
  314. * :variable:`CMAKE_APPBUNDLE_PATH`
  315. 3. Search paths specified in cmake-specific environment variables.
  316. These are intended to be set in the user's shell configuration,
  317. and therefore use the host's native path separator
  318. (``;`` on Windows and ``:`` on UNIX).
  319. This can be skipped if ``NO_CMAKE_ENVIRONMENT_PATH`` is passed or by setting
  320. the :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH` to ``FALSE``:
  321. * ``<PackageName>_DIR``
  322. * :envvar:`CMAKE_PREFIX_PATH`
  323. * ``CMAKE_FRAMEWORK_PATH``
  324. * ``CMAKE_APPBUNDLE_PATH``
  325. 4. Search paths specified by the ``HINTS`` option. These should be paths
  326. computed by system introspection, such as a hint provided by the
  327. location of another item already found. Hard-coded guesses should
  328. be specified with the ``PATHS`` option.
  329. 5. Search the standard system environment variables. This can be
  330. skipped if ``NO_SYSTEM_ENVIRONMENT_PATH`` is passed or by setting the
  331. :variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH` to ``FALSE``. Path entries
  332. ending in ``/bin`` or ``/sbin`` are automatically converted to their
  333. parent directories:
  334. * ``PATH``
  335. 6. Search paths stored in the CMake :ref:`User Package Registry`.
  336. This can be skipped if ``NO_CMAKE_PACKAGE_REGISTRY`` is passed or by
  337. setting the variable :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`
  338. to ``FALSE`` or the deprecated variable
  339. :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY` to ``TRUE``.
  340. See the :manual:`cmake-packages(7)` manual for details on the user
  341. package registry.
  342. 7. Search cmake variables defined in the Platform files for the
  343. current system. This can be skipped if ``NO_CMAKE_SYSTEM_PATH`` is
  344. passed or by setting the :variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`
  345. to ``FALSE``:
  346. * :variable:`CMAKE_SYSTEM_PREFIX_PATH`
  347. * :variable:`CMAKE_SYSTEM_FRAMEWORK_PATH`
  348. * :variable:`CMAKE_SYSTEM_APPBUNDLE_PATH`
  349. The platform paths that these variables contain are locations that
  350. typically include installed software. An example being ``/usr/local`` for
  351. UNIX based platforms.
  352. 8. Search paths stored in the CMake :ref:`System Package Registry`.
  353. This can be skipped if ``NO_CMAKE_SYSTEM_PACKAGE_REGISTRY`` is passed
  354. or by setting the :variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY`
  355. variable to ``FALSE`` or the deprecated variable
  356. :variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` to ``TRUE``.
  357. See the :manual:`cmake-packages(7)` manual for details on the system
  358. package registry.
  359. 9. Search paths specified by the ``PATHS`` option. These are typically
  360. hard-coded guesses.
  361. .. versionadded:: 3.16
  362. Added the ``CMAKE_FIND_USE_<CATEGORY>_PATH`` variables to globally disable
  363. various search locations.
  364. .. |FIND_XXX| replace:: find_package
  365. .. |FIND_ARGS_XXX| replace:: <PackageName>
  366. .. |CMAKE_FIND_ROOT_PATH_MODE_XXX| replace::
  367. :variable:`CMAKE_FIND_ROOT_PATH_MODE_PACKAGE`
  368. .. include:: FIND_XXX_ROOT.txt
  369. .. include:: FIND_XXX_ORDER.txt
  370. By default the value stored in the result variable will be the path at
  371. which the file is found. The :variable:`CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS`
  372. variable may be set to ``TRUE`` before calling ``find_package`` in order
  373. to resolve symbolic links and store the real path to the file.
  374. Every non-REQUIRED ``find_package`` call can be disabled by setting the
  375. :variable:`CMAKE_DISABLE_FIND_PACKAGE_<PackageName>` variable to ``TRUE``.
  376. Package File Interface Variables
  377. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  378. When loading a find module or package configuration file ``find_package``
  379. defines variables to provide information about the call arguments (and
  380. restores their original state before returning):
  381. ``CMAKE_FIND_PACKAGE_NAME``
  382. The ``<PackageName>`` which is searched for
  383. ``<PackageName>_FIND_REQUIRED``
  384. True if ``REQUIRED`` option was given
  385. ``<PackageName>_FIND_QUIETLY``
  386. True if ``QUIET`` option was given
  387. ``<PackageName>_FIND_VERSION``
  388. Full requested version string
  389. ``<PackageName>_FIND_VERSION_MAJOR``
  390. Major version if requested, else 0
  391. ``<PackageName>_FIND_VERSION_MINOR``
  392. Minor version if requested, else 0
  393. ``<PackageName>_FIND_VERSION_PATCH``
  394. Patch version if requested, else 0
  395. ``<PackageName>_FIND_VERSION_TWEAK``
  396. Tweak version if requested, else 0
  397. ``<PackageName>_FIND_VERSION_COUNT``
  398. Number of version components, 0 to 4
  399. ``<PackageName>_FIND_VERSION_EXACT``
  400. True if ``EXACT`` option was given
  401. ``<PackageName>_FIND_COMPONENTS``
  402. List of requested components
  403. ``<PackageName>_FIND_REQUIRED_<c>``
  404. True if component ``<c>`` is required,
  405. false if component ``<c>`` is optional
  406. When a version range is specified, the above version variables will hold
  407. values based on the lower end of the version range. This is to preserve
  408. compatibility with packages that have not been implemented to expect version
  409. ranges. In addition, the version range will be described by the following
  410. variables:
  411. ``<PackageName>_FIND_VERSION_RANGE``
  412. Full requested version range string
  413. ``<PackageName>_FIND_VERSION_RANGE_MIN``
  414. This specifies whether the lower end point of the version range is
  415. included or excluded. Currently, ``INCLUDE`` is the only supported value.
  416. ``<PackageName>_FIND_VERSION_RANGE_MAX``
  417. This specifies whether the upper end point of the version range is
  418. included or excluded. The possible values for this variable are
  419. ``INCLUDE`` or ``EXCLUDE``.
  420. ``<PackageName>_FIND_VERSION_MIN``
  421. Full requested version string of the lower end point of the range
  422. ``<PackageName>_FIND_VERSION_MIN_MAJOR``
  423. Major version of the lower end point if requested, else 0
  424. ``<PackageName>_FIND_VERSION_MIN_MINOR``
  425. Minor version of the lower end point if requested, else 0
  426. ``<PackageName>_FIND_VERSION_MIN_PATCH``
  427. Patch version of the lower end point if requested, else 0
  428. ``<PackageName>_FIND_VERSION_MIN_TWEAK``
  429. Tweak version of the lower end point if requested, else 0
  430. ``<PackageName>_FIND_VERSION_MIN_COUNT``
  431. Number of version components of the lower end point, 0 to 4
  432. ``<PackageName>_FIND_VERSION_MAX``
  433. Full requested version string of the upper end point of the range
  434. ``<PackageName>_FIND_VERSION_MAX_MAJOR``
  435. Major version of the upper end point if requested, else 0
  436. ``<PackageName>_FIND_VERSION_MAX_MINOR``
  437. Minor version of the upper end point if requested, else 0
  438. ``<PackageName>_FIND_VERSION_MAX_PATCH``
  439. Patch version of the upper end point if requested, else 0
  440. ``<PackageName>_FIND_VERSION_MAX_TWEAK``
  441. Tweak version of the upper end point if requested, else 0
  442. ``<PackageName>_FIND_VERSION_MAX_COUNT``
  443. Number of version components of the upper end point, 0 to 4
  444. Regardless of whether a single version or a version range is specified, the
  445. variable ``<PackageName>_FIND_VERSION_COMPLETE`` will be defined and will hold
  446. the full requested version string as specified.
  447. In Module mode the loaded find module is responsible to honor the
  448. request detailed by these variables; see the find module for details.
  449. In Config mode ``find_package`` handles ``REQUIRED``, ``QUIET``, and
  450. ``[version]`` options automatically but leaves it to the package
  451. configuration file to handle components in a way that makes sense
  452. for the package. The package configuration file may set
  453. ``<PackageName>_FOUND`` to false to tell ``find_package`` that component
  454. requirements are not satisfied.