cmake-developer.7.rst 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711
  1. .. cmake-manual-description: CMake Developer Reference
  2. cmake-developer(7)
  3. ******************
  4. .. only:: html or latex
  5. .. contents::
  6. Introduction
  7. ============
  8. This manual is intended for reference by developers modifying the CMake
  9. source tree itself.
  10. Permitted C++ Subset
  11. ====================
  12. CMake is required to build with ancient C++ compilers and standard library
  13. implementations. Some common C++ constructs may not be used in CMake in order
  14. to build with such toolchains.
  15. std::vector::at
  16. ---------------
  17. The ``at()`` member function of ``std::vector`` may not be used. Use
  18. ``operator[]`` instead:
  19. .. code-block:: c++
  20. std::vector<int> someVec = getVec();
  21. int i1 = someVec.at(5); // Wrong
  22. int i2 = someVec[5]; // Ok
  23. std::string::append and std::string::clear
  24. ------------------------------------------
  25. The ``append()`` and ``clear()`` member functions of ``std::string`` may not
  26. be used. Use ``operator+=`` and ``operator=`` instead:
  27. .. code-block:: c++
  28. std::string stringBuilder;
  29. stringBuilder.append("chunk"); // Wrong
  30. stringBuilder.clear(); // Wrong
  31. stringBuilder += "chunk"; // Ok
  32. stringBuilder = ""; // Ok
  33. std::set const iterators
  34. ------------------------
  35. The ``find()`` member function of a ``const`` ``std::set`` instance may not be
  36. used in a comparison with the iterator returned by ``end()``:
  37. .. code-block:: c++
  38. const std::set<cmStdString>& someSet = getSet();
  39. if (someSet.find("needle") == someSet.end()) // Wrong
  40. {
  41. // ...
  42. }
  43. The return value of ``find()`` must be assigned to an intermediate
  44. ``const_iterator`` for comparison:
  45. .. code-block:: c++
  46. const std::set<cmStdString>& someSet;
  47. const std::set<cmStdString>::const_iterator i = someSet.find("needle");
  48. if (i != propSet.end()) // Ok
  49. {
  50. // ...
  51. }
  52. Char Array to ``string`` Conversions with Algorithms
  53. ----------------------------------------------------
  54. In some implementations, algorithms operating on iterators to a container of
  55. ``std::string`` can not accept a ``const char*`` value:
  56. .. code-block:: c++
  57. const char* dir = /*...*/;
  58. std::vector<std::string> vec;
  59. // ...
  60. std::binary_find(vec.begin(), vec.end(), dir); // Wrong
  61. The ``std::string`` may need to be explicitly constructed:
  62. .. code-block:: c++
  63. const char* dir = /*...*/;
  64. std::vector<std::string> vec;
  65. // ...
  66. std::binary_find(vec.begin(), vec.end(), std::string(dir)); // Ok
  67. std::auto_ptr
  68. -------------
  69. Some implementations have a ``std::auto_ptr`` which can not be used as a
  70. return value from a function. ``std::auto_ptr`` may not be used. Use
  71. ``cmsys::auto_ptr`` instead.
  72. std::vector::insert and std::set
  73. --------------------------------
  74. Use of ``std::vector::insert`` with an iterator whose ``element_type`` requires
  75. conversion is not allowed:
  76. .. code-block:: c++
  77. std::set<cmStdString> theSet;
  78. std::vector<std::string> theVector;
  79. theVector.insert(theVector.end(), theSet.begin(), theSet.end()); // Wrong
  80. A loop must be used instead:
  81. .. code-block:: c++
  82. std::set<cmStdString> theSet;
  83. std::vector<std::string> theVector;
  84. for(std::set<cmStdString>::iterator li = theSet.begin();
  85. li != theSet.end(); ++li)
  86. {
  87. theVector.push_back(*li);
  88. }
  89. std::set::insert
  90. ----------------
  91. Use of ``std::set::insert`` is not allowed with any source container:
  92. .. code-block:: c++
  93. std::set<cmTarget*> theSet;
  94. theSet.insert(targets.begin(), targets.end()); // Wrong
  95. A loop must be used instead:
  96. .. code-block:: c++
  97. ConstIterator it = targets.begin();
  98. const ConstIterator end = targets.end();
  99. for ( ; it != end; ++it)
  100. {
  101. theSet.insert(*it);
  102. }
  103. .. MSVC6, SunCC 5.9
  104. Template Parameter Defaults
  105. ---------------------------
  106. On ancient compilers, C++ template must use template parameters in function
  107. arguments. If no parameter of that type is needed, the common workaround is
  108. to add a defaulted pointer to the type to the templated function. However,
  109. this does not work with other ancient compilers:
  110. .. code-block:: c++
  111. template<typename PropertyType>
  112. PropertyType getTypedProperty(cmTarget* tgt, const char* prop,
  113. PropertyType* = 0) // Wrong
  114. {
  115. }
  116. .. code-block:: c++
  117. template<typename PropertyType>
  118. PropertyType getTypedProperty(cmTarget* tgt, const char* prop,
  119. PropertyType*) // Ok
  120. {
  121. }
  122. and invoke it with the value ``0`` explicitly in all cases.
  123. std::min and std::max
  124. ---------------------
  125. ``min`` and ``max`` are defined as macros on some systems. ``std::min`` and
  126. ``std::max`` may not be used. Use ``cmMinimum`` and ``cmMaximum`` instead.
  127. size_t
  128. ------
  129. Various implementations have differing implementation of ``size_t``. When
  130. assigning the result of ``.size()`` on a container for example, the result
  131. should not be assigned to an ``unsigned int`` or similar. ``std::size_t`` must
  132. not be used.
  133. Templates
  134. ---------
  135. Some template code is permitted, but with some limitations. Member templates
  136. may not be used, and template friends may not be used.
  137. Help
  138. ====
  139. The ``Help`` directory contains CMake help manual source files.
  140. They are written using the `reStructuredText`_ markup syntax and
  141. processed by `Sphinx`_ to generate the CMake help manuals.
  142. .. _`reStructuredText`: http://docutils.sourceforge.net/docs/ref/rst/introduction.html
  143. .. _`Sphinx`: http://sphinx-doc.org
  144. Markup Constructs
  145. -----------------
  146. In addition to using Sphinx to generate the CMake help manuals, we
  147. also use a C++-implemented document processor to print documents for
  148. the ``--help-*`` command-line help options. It supports a subset of
  149. reStructuredText markup. When authoring or modifying documents,
  150. please verify that the command-line help looks good in addition to the
  151. Sphinx-generated html and man pages.
  152. The command-line help processor supports the following constructs
  153. defined by reStructuredText, Sphinx, and a CMake extension to Sphinx.
  154. ..
  155. Note: This list must be kept consistent with the cmRST implementation.
  156. CMake Domain directives
  157. Directives defined in the `CMake Domain`_ for defining CMake
  158. documentation objects are printed in command-line help output as
  159. if the lines were normal paragraph text with interpretation.
  160. CMake Domain interpreted text roles
  161. Interpreted text roles defined in the `CMake Domain`_ for
  162. cross-referencing CMake documentation objects are replaced by their
  163. link text in command-line help output. Other roles are printed
  164. literally and not processed.
  165. ``code-block`` directive
  166. Add a literal code block without interpretation. The command-line
  167. help processor prints the block content without the leading directive
  168. line and with common indentation replaced by one space.
  169. ``include`` directive
  170. Include another document source file. The command-line help
  171. processor prints the included document inline with the referencing
  172. document.
  173. literal block after ``::``
  174. A paragraph ending in ``::`` followed by a blank line treats
  175. the following indented block as literal text without interpretation.
  176. The command-line help processor prints the ``::`` literally and
  177. prints the block content with common indentation replaced by one
  178. space. We prefer the ``::`` to appear at the end of a paragraph
  179. line instead of as its own line.
  180. ``note`` directive
  181. Call out a side note. The command-line help processor prints the
  182. block content as if the lines were normal paragraph text with
  183. interpretation.
  184. ``parsed-literal`` directive
  185. Add a literal block with markup interpretation. The command-line
  186. help processor prints the block content without the leading
  187. directive line and with common indentation replaced by one space.
  188. ``productionlist`` directive
  189. Render context-free grammar productions. The command-line help
  190. processor prints the block content as if the lines were normal
  191. paragraph text with interpretation.
  192. ``replace`` directive
  193. Define a ``|substitution|`` replacement.
  194. The command-line help processor requires a substitution replacement
  195. to be defined before it is referenced.
  196. ``|substitution|`` reference
  197. Reference a substitution replacement previously defined by
  198. the ``replace`` directive. The command-line help processor
  199. performs the substitution and replaces all newlines in the
  200. replacement text with spaces.
  201. ``toctree`` directive
  202. Include other document sources in the Table-of-Contents
  203. document tree. The command-line help processor prints
  204. the referenced documents inline as part of the referencing
  205. document.
  206. Inline markup constructs not listed above are printed literally in the
  207. command-line help output. We prefer to use inline markup constructs that
  208. look correct in source form, so avoid use of \\-escapes in favor of inline
  209. literals when possible.
  210. Explicit markup blocks not matching directives listed above are removed from
  211. command-line help output. Do not use them, except for plain ``..`` comments
  212. that are removed by Sphinx too.
  213. Note that nested indentation of blocks is not recognized by the
  214. command-line help processor. Therefore:
  215. * Explicit markup blocks are recognized only when not indented
  216. inside other blocks.
  217. * Literal blocks after paragraphs ending in ``::`` but not
  218. at the top indentation level may consume all indented lines
  219. following them.
  220. Try to avoid these cases in practice.
  221. CMake Domain
  222. ------------
  223. CMake adds a `Sphinx Domain`_ called ``cmake``, also called the
  224. "CMake Domain". It defines several "object" types for CMake
  225. documentation:
  226. ``command``
  227. A CMake language command.
  228. ``generator``
  229. A CMake native build system generator.
  230. See the :manual:`cmake(1)` command-line tool's ``-G`` option.
  231. ``manual``
  232. A CMake manual page, like this :manual:`cmake-developer(7)` manual.
  233. ``module``
  234. A CMake module.
  235. See the :manual:`cmake-modules(7)` manual
  236. and the :command:`include` command.
  237. ``policy``
  238. A CMake policy.
  239. See the :manual:`cmake-policies(7)` manual
  240. and the :command:`cmake_policy` command.
  241. ``prop_cache, prop_dir, prop_gbl, prop_sf, prop_test, prop_tgt``
  242. A CMake cache, directory, global, source file, test, or target
  243. property, respectively. See the :manual:`cmake-properties(7)` manual
  244. and the :command:`set_property` command.
  245. ``variable``
  246. A CMake language variable.
  247. See the :manual:`cmake-variables(7)` manual
  248. and the :command:`set` command.
  249. Documentation objects in the CMake Domain come from two sources.
  250. First, the CMake extension to Sphinx transforms every document named
  251. with the form ``Help/<type>/<file-name>.rst`` to a domain object with
  252. type ``<type>``. The object name is extracted from the document title,
  253. which is expected to be of the form::
  254. <object-name>
  255. -------------
  256. and to appear at or near the top of the ``.rst`` file before any other
  257. lines starting in a letter, digit, or ``<``. If no such title appears
  258. literally in the ``.rst`` file, the object name is the ``<file-name>``.
  259. If a title does appear, it is expected that ``<file-name>`` is equal
  260. to ``<object-name>`` with any ``<`` and ``>`` characters removed.
  261. Second, the CMake Domain provides directives to define objects inside
  262. other documents:
  263. .. code-block:: rst
  264. .. command:: <command-name>
  265. This indented block documents <command-name>.
  266. .. variable:: <variable-name>
  267. This indented block documents <variable-name>.
  268. Object types for which no directive is available must be defined using
  269. the first approach above.
  270. .. _`Sphinx Domain`: http://sphinx-doc.org/domains.html
  271. Cross-References
  272. ----------------
  273. Sphinx uses reStructuredText interpreted text roles to provide
  274. cross-reference syntax. The `CMake Domain`_ provides for each
  275. domain object type a role of the same name to cross-reference it.
  276. CMake Domain roles are inline markup of the forms::
  277. :type:`name`
  278. :type:`text <name>`
  279. where ``type`` is the domain object type and ``name`` is the
  280. domain object name. In the first form the link text will be
  281. ``name`` (or ``name()`` if the type is ``command``) and in
  282. the second form the link text will be the explicit ``text``.
  283. For example, the code:
  284. .. code-block:: rst
  285. * The :command:`list` command.
  286. * The :command:`list(APPEND)` sub-command.
  287. * The :command:`list() command <list>`.
  288. * The :command:`list(APPEND) sub-command <list>`.
  289. * The :variable:`CMAKE_VERSION` variable.
  290. * The :prop_tgt:`OUTPUT_NAME_<CONFIG>` target property.
  291. produces:
  292. * The :command:`list` command.
  293. * The :command:`list(APPEND)` sub-command.
  294. * The :command:`list() command <list>`.
  295. * The :command:`list(APPEND) sub-command <list>`.
  296. * The :variable:`CMAKE_VERSION` variable.
  297. * The :prop_tgt:`OUTPUT_NAME_<CONFIG>` target property.
  298. Note that CMake Domain roles differ from Sphinx and reStructuredText
  299. convention in that the form ``a<b>``, without a space preceding ``<``,
  300. is interpreted as a name instead of link text with an explicit target.
  301. This is necessary because we use ``<placeholders>`` frequently in
  302. object names like ``OUTPUT_NAME_<CONFIG>``. The form ``a <b>``,
  303. with a space preceding ``<``, is still interpreted as a link text
  304. with an explicit target.
  305. Modules
  306. =======
  307. The ``Modules`` directory contains CMake-language ``.cmake`` module files.
  308. Module Documentation
  309. --------------------
  310. To document CMake module ``Modules/<module-name>.cmake``, modify
  311. ``Help/manual/cmake-modules.7.rst`` to reference the module in the
  312. ``toctree`` directive, in sorted order, as::
  313. /module/<module-name>
  314. Then add the module document file ``Help/module/<module-name>.rst``
  315. containing just the line::
  316. .. cmake-module:: ../../Modules/<module-name>.cmake
  317. The ``cmake-module`` directive will scan the module file to extract
  318. reStructuredText markup from comment blocks that start in ``.rst:``.
  319. Add to the top of ``Modules/<module-name>.cmake`` a
  320. :ref:`Line Comment` block of the form:
  321. .. code-block:: cmake
  322. #.rst:
  323. # <module-name>
  324. # -------------
  325. #
  326. # <reStructuredText documentation of module>
  327. or a :ref:`Bracket Comment` of the form:
  328. .. code-block:: cmake
  329. #[[.rst:
  330. <module-name>
  331. -------------
  332. <reStructuredText documentation of module>
  333. #]]
  334. Any number of ``=`` may be used in the opening and closing brackets
  335. as long as they match. Content on the line containing the closing
  336. bracket is excluded if and only if the line starts in ``#``.
  337. Additional such ``.rst:`` comments may appear anywhere in the module file.
  338. All such comments must start with ``#`` in the first column.
  339. For example, a ``Modules/Findxxx.cmake`` module may contain:
  340. .. code-block:: cmake
  341. #.rst:
  342. # FindXxx
  343. # -------
  344. #
  345. # This is a cool module.
  346. # This module does really cool stuff.
  347. # It can do even more than you think.
  348. #
  349. # It even needs two paragraphs to tell you about it.
  350. # And it defines the following variables:
  351. #
  352. # * VAR_COOL: this is great isn't it?
  353. # * VAR_REALLY_COOL: cool right?
  354. <code>
  355. #[========================================[.rst:
  356. .. command:: xxx_do_something
  357. This command does something for Xxx::
  358. xxx_do_something(some arguments)
  359. #]========================================]
  360. macro(xxx_do_something)
  361. <code>
  362. endmacro()
  363. Find Modules
  364. ------------
  365. A "find module" is a ``Modules/Find<package>.cmake`` file to be loaded
  366. by the :command:`find_package` command when invoked for ``<package>``.
  367. We would like all ``FindXxx.cmake`` files to produce consistent variable
  368. names. Please use the following consistent variable names for general use.
  369. Xxx_INCLUDE_DIRS
  370. The final set of include directories listed in one variable for use by client
  371. code. This should not be a cache entry.
  372. Xxx_LIBRARIES
  373. The libraries to link against to use Xxx. These should include full paths.
  374. This should not be a cache entry.
  375. Xxx_DEFINITIONS
  376. Definitions to use when compiling code that uses Xxx. This really shouldn't
  377. include options such as (-DHAS_JPEG)that a client source-code file uses to
  378. decide whether to #include <jpeg.h>
  379. Xxx_EXECUTABLE
  380. Where to find the Xxx tool.
  381. Xxx_Yyy_EXECUTABLE
  382. Where to find the Yyy tool that comes with Xxx.
  383. Xxx_LIBRARY_DIRS
  384. Optionally, the final set of library directories listed in one variable for
  385. use by client code. This should not be a cache entry.
  386. Xxx_ROOT_DIR
  387. Where to find the base directory of Xxx.
  388. Xxx_VERSION_Yy
  389. Expect Version Yy if true. Make sure at most one of these is ever true.
  390. Xxx_WRAP_Yy
  391. If False, do not try to use the relevant CMake wrapping command.
  392. Xxx_Yy_FOUND
  393. If False, optional Yy part of Xxx sytem is not available.
  394. Xxx_FOUND
  395. Set to false, or undefined, if we haven't found, or don't want to use Xxx.
  396. Xxx_NOT_FOUND_MESSAGE
  397. Should be set by config-files in the case that it has set Xxx_FOUND to FALSE.
  398. The contained message will be printed by the find_package() command and by
  399. find_package_handle_standard_args() to inform the user about the problem.
  400. Xxx_RUNTIME_LIBRARY_DIRS
  401. Optionally, the runtime library search path for use when running an
  402. executable linked to shared libraries. The list should be used by user code
  403. to create the PATH on windows or LD_LIBRARY_PATH on unix. This should not be
  404. a cache entry.
  405. Xxx_VERSION_STRING
  406. A human-readable string containing the version of the package found, if any.
  407. Xxx_VERSION_MAJOR
  408. The major version of the package found, if any.
  409. Xxx_VERSION_MINOR
  410. The minor version of the package found, if any.
  411. Xxx_VERSION_PATCH
  412. The patch version of the package found, if any.
  413. You do not have to provide all of the above variables. You should provide
  414. Xxx_FOUND under most circumstances. If Xxx is a library, then Xxx_LIBRARIES,
  415. should also be defined, and Xxx_INCLUDE_DIRS should usually be defined (I
  416. guess libm.a might be an exception)
  417. The following names should not usually be used in CMakeLists.txt files, but
  418. they may be usefully modified in users' CMake Caches to control stuff.
  419. Xxx_LIBRARY
  420. Name of Xxx Library. A User may set this and Xxx_INCLUDE_DIR to ignore to
  421. force non-use of Xxx.
  422. Xxx_Yy_LIBRARY
  423. Name of Yy library that is part of the Xxx system. It may or may not be
  424. required to use Xxx.
  425. Xxx_INCLUDE_DIR
  426. Where to find xxx.h, etc. (Xxx_INCLUDE_PATH was considered bad because a path
  427. includes an actual filename.)
  428. Xxx_Yy_INCLUDE_DIR
  429. Where to find xxx_yy.h, etc.
  430. For tidiness's sake, try to keep as many options as possible out of the cache,
  431. leaving at least one option which can be used to disable use of the module, or
  432. locate a not-found library (e.g. Xxx_ROOT_DIR). For the same reason, mark
  433. most cache options as advanced.
  434. If you need other commands to do special things then it should still begin
  435. with ``Xxx_``. This gives a sort of namespace effect and keeps things tidy for the
  436. user. You should put comments describing all the exported settings, plus
  437. descriptions of any the users can use to control stuff.
  438. You really should also provide backwards compatibility any old settings that
  439. were actually in use. Make sure you comment them as deprecated, so that
  440. no-one starts using them.
  441. To add a module to the CMake documentation, follow the steps in the
  442. `Module Documentation`_ section above. Test the documentation formatting
  443. by running ``cmake --help-module FindXxx``, and also by enabling the
  444. ``SPHINX_HTML`` and ``SPHINX_MAN`` options to build the documentation.
  445. Edit the comments until generated documentation looks satisfactory.
  446. To have a .cmake file in this directory NOT show up in the modules
  447. documentation, simply leave out the ``Help/module/<module-name>.rst`` file
  448. and the ``Help/manual/cmake-modules.7.rst`` toctree entry.
  449. After the documentation, leave a *BLANK* line, and then add a
  450. copyright and licence notice block like this one::
  451. #=============================================================================
  452. # Copyright 2009-2011 Your Name
  453. #
  454. # Distributed under the OSI-approved BSD License (the "License");
  455. # see accompanying file Copyright.txt for details.
  456. #
  457. # This software is distributed WITHOUT ANY WARRANTY; without even the
  458. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  459. # See the License for more information.
  460. #=============================================================================
  461. # (To distribute this file outside of CMake, substitute the full
  462. # License text for the above reference.)
  463. The layout of the notice block is strictly enforced by the ``ModuleNotices``
  464. test. Only the year range and name may be changed freely.
  465. A FindXxx.cmake module will typically be loaded by the command::
  466. FIND_PACKAGE(Xxx [major[.minor[.patch[.tweak]]]] [EXACT]
  467. [QUIET] [[REQUIRED|COMPONENTS] [components...]])
  468. If any version numbers are given to the command it will set the following
  469. variables before loading the module:
  470. Xxx_FIND_VERSION
  471. full requested version string
  472. Xxx_FIND_VERSION_MAJOR
  473. major version if requested, else 0
  474. Xxx_FIND_VERSION_MINOR
  475. minor version if requested, else 0
  476. Xxx_FIND_VERSION_PATCH
  477. patch version if requested, else 0
  478. Xxx_FIND_VERSION_TWEAK
  479. tweak version if requested, else 0
  480. Xxx_FIND_VERSION_COUNT
  481. number of version components, 0 to 4
  482. Xxx_FIND_VERSION_EXACT
  483. true if EXACT option was given
  484. If the find module supports versioning it should locate a version of
  485. the package that is compatible with the version requested. If a
  486. compatible version of the package cannot be found the module should
  487. not report success. The version of the package found should be stored
  488. in "Xxx_VERSION..." version variables documented by the module.
  489. If the QUIET option is given to the command it will set the variable
  490. Xxx_FIND_QUIETLY to true before loading the FindXxx.cmake module. If
  491. this variable is set the module should not complain about not being
  492. able to find the package. If the
  493. REQUIRED option is given to the command it will set the variable
  494. Xxx_FIND_REQUIRED to true before loading the FindXxx.cmake module. If
  495. this variable is set the module should issue a FATAL_ERROR if the
  496. package cannot be found.
  497. If neither the QUIET nor REQUIRED options are given then the
  498. FindXxx.cmake module should look for the package and complain without
  499. error if the module is not found.
  500. FIND_PACKAGE() will set the variable CMAKE_FIND_PACKAGE_NAME to
  501. contain the actual name of the package.
  502. A package can provide sub-components.
  503. Those components can be listed after the COMPONENTS (or REQUIRED) or
  504. OPTIONAL_COMPONENTS keywords. The set of all listed components will be
  505. specified in a Xxx_FIND_COMPONENTS variable.
  506. For each package-specific component, say Yyy, a variable Xxx_FIND_REQUIRED_Yyy
  507. will be set to true if it listed after COMPONENTS and it will be set to false
  508. if it was listed after OPTIONAL_COMPONENTS.
  509. Using those variables a FindXxx.cmake module and also a XxxConfig.cmake
  510. package configuration file can determine whether and which components have
  511. been requested, and whether they were requested as required or as optional.
  512. For each of the requested components a Xxx_Yyy_FOUND variable should be set
  513. accordingly.
  514. The per-package Xxx_FOUND variable should be only set to true if all requested
  515. required components have been found. A missing optional component should not
  516. keep the Xxx_FOUND variable from being set to true.
  517. If the package provides Xxx_INCLUDE_DIRS and Xxx_LIBRARIES variables, the
  518. include dirs and libraries for all components which were requested and which
  519. have been found should be added to those two variables.
  520. To get this behavior you can use the FIND_PACKAGE_HANDLE_STANDARD_ARGS()
  521. macro, as an example see FindJPEG.cmake.
  522. For internal implementation, it's a generally accepted convention that
  523. variables starting with underscore are for temporary use only. (variable
  524. starting with an underscore are not intended as a reserved prefix).