cmake-developer.7.rst 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. .. cmake-manual-description: CMake Developer Reference
  2. cmake-developer(7)
  3. ******************
  4. .. only:: html
  5. .. contents::
  6. Introduction
  7. ============
  8. This manual is intended for reference by developers working with
  9. :manual:`cmake-language(7)` code, whether writing their own modules,
  10. authoring their own build systems, or working on CMake itself.
  11. See https://cmake.org/get-involved/ to get involved in development of
  12. CMake upstream. It includes links to contribution instructions, which
  13. in turn link to developer guides for CMake itself.
  14. Accessing Windows Registry
  15. ==========================
  16. CMake offers some facilities to access the registry on ``Windows`` platforms.
  17. Query Windows Registry
  18. ----------------------
  19. .. versionadded:: 3.24
  20. The :command:`cmake_host_system_information` command offers the possibility to
  21. query the registry on the local computer. See
  22. :ref:`cmake_host_system(QUERY_WINDOWS_REGISTRY) <Query Windows registry>` for
  23. more information.
  24. .. _`Find Using Windows Registry`:
  25. Find Using Windows Registry
  26. ---------------------------
  27. .. versionchanged:: 3.24
  28. Options ``HINTS`` and ``PATHS`` of :command:`find_file`,
  29. :command:`find_library`, :command:`find_path`, :command:`find_program`, and
  30. :command:`find_package` commands offer the possibility, on ``Windows``
  31. platform, to query the registry.
  32. The formal syntax, as specified using
  33. `BNF <https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form>`_ notation with
  34. the regular extensions, for registry query is the following:
  35. .. raw:: latex
  36. \begin{small}
  37. .. productionlist::
  38. registry_query: '[' `sep_definition`? `root_key`
  39. : ((`key_separator` `sub_key`)? (`value_separator` `value_name`_)?)? ']'
  40. sep_definition: '{' `value_separator` '}'
  41. root_key: 'HKLM' | 'HKEY_LOCAL_MACHINE' | 'HKCU' | 'HKEY_CURRENT_USER' |
  42. : 'HKCR' | 'HKEY_CLASSES_ROOT' | 'HKCC' | 'HKEY_CURRENT_CONFIG' |
  43. : 'HKU' | 'HKEY_USERS'
  44. sub_key: `element` (`key_separator` `element`)*
  45. key_separator: '/' | '\\'
  46. value_separator: `element` | ';'
  47. value_name: `element` | '(default)'
  48. element: `character`\+
  49. character: <any character except `key_separator` and `value_separator`>
  50. .. raw:: latex
  51. \end{small}
  52. The :token:`sep_definition` optional item offers the possibility to specify
  53. the string used to separate the :token:`sub_key` from the :token:`value_name`
  54. item. If not specified, the character ``;`` is used. Multiple
  55. :token:`registry_query` items can be specified as part of a path.
  56. .. code-block:: cmake
  57. # example using default separator
  58. find_file(... PATHS "/root/[HKLM/Stuff;InstallDir]/lib[HKLM\\\\Stuff;Architecture]")
  59. # example using different specified separators
  60. find_library(... HINTS "/root/[{|}HKCU/Stuff|InstallDir]/lib[{@@}HKCU\\\\Stuff@@Architecture]")
  61. If the :token:`value_name` item is not specified or has the special name
  62. ``(default)``, the content of the default value, if any, will be returned. The
  63. supported types for the :token:`value_name` are:
  64. * ``REG_SZ``.
  65. * ``REG_EXPAND_SZ``. The returned data is expanded.
  66. * ``REG_DWORD``.
  67. * ``REG_QWORD``.
  68. When the registry query failed, typically because the key does not exist or
  69. the data type is not supported, the string ``/REGISTRY-NOTFOUND`` is substituted
  70. to the ``[]`` query expression.
  71. .. _`Find Modules`:
  72. Find Modules
  73. ============
  74. A "find module" is a ``Find<PackageName>.cmake`` file to be loaded by the
  75. :command:`find_package` command when invoked for ``<PackageName>``.
  76. The primary task of a find module is to determine whether a package is
  77. available, set the ``<PackageName>_FOUND`` variable to reflect this and
  78. provide any variables, macros and imported targets required to use the
  79. package. A find module is useful in cases where an upstream library does
  80. not provide a :ref:`config file package <Config File Packages>`.
  81. The traditional approach is to use variables for everything, including
  82. libraries and executables: see the `Standard Variable Names`_ section
  83. below. This is what most of the existing find modules provided by CMake
  84. do.
  85. The more modern approach is to behave as much like
  86. :ref:`config file packages <Config File Packages>` files as possible, by
  87. providing :ref:`imported target <Imported targets>`. This has the advantage
  88. of propagating :ref:`usage requirements <Target Usage Requirements>`
  89. to consumers.
  90. In either case (or even when providing both variables and imported
  91. targets), find modules should provide backwards compatibility with old
  92. versions that had the same name.
  93. A FindFoo.cmake module will typically be loaded by the command:
  94. .. code-block:: cmake
  95. find_package(Foo [major[.minor[.patch[.tweak]]]]
  96. [EXACT] [QUIET] [REQUIRED]
  97. [[COMPONENTS] [components...]]
  98. [OPTIONAL_COMPONENTS components...]
  99. [NO_POLICY_SCOPE])
  100. See the :command:`find_package` documentation for details on what
  101. variables are set for the find module. Most of these are dealt with by
  102. using :module:`FindPackageHandleStandardArgs`.
  103. Briefly, the module should only locate versions of the package
  104. compatible with the requested version, as described by the
  105. ``Foo_FIND_VERSION`` family of variables. If ``Foo_FIND_QUIETLY`` is
  106. set to true, it should avoid printing messages, including anything
  107. complaining about the package not being found. If ``Foo_FIND_REQUIRED``
  108. is set to true, the module should issue a ``FATAL_ERROR`` if the package
  109. cannot be found. If neither are set to true, it should print a
  110. non-fatal message if it cannot find the package.
  111. Packages that find multiple semi-independent parts (like bundles of
  112. libraries) should search for the components listed in
  113. ``Foo_FIND_COMPONENTS`` if it is set , and only set ``Foo_FOUND`` to
  114. true if for each searched-for component ``<c>`` that was not found,
  115. ``Foo_FIND_REQUIRED_<c>`` is not set to true. The ``HANDLE_COMPONENTS``
  116. argument of :command:`find_package_handle_standard_args` can be used to
  117. implement this.
  118. If ``Foo_FIND_COMPONENTS`` is not set, which modules are searched for
  119. and required is up to the find module, but should be documented.
  120. For internal implementation, it is a generally accepted convention that
  121. variables starting with underscore are for temporary use only.
  122. .. _`CMake Developer Standard Variable Names`:
  123. Standard Variable Names
  124. -----------------------
  125. For a ``FindXxx.cmake`` module that takes the approach of setting
  126. variables (either instead of or in addition to creating imported
  127. targets), the following variable names should be used to keep things
  128. consistent between Find modules. Note that all variables start with
  129. ``Xxx_``, which (unless otherwise noted) must match exactly the name
  130. of the ``FindXxx.cmake`` file, including upper/lowercase.
  131. This prefix on the variable names ensures that they do not conflict with
  132. variables of other Find modules. The same pattern should also be followed
  133. for any macros, functions and imported targets defined by the Find module.
  134. ``Xxx_INCLUDE_DIRS``
  135. The final set of include directories listed in one variable for use by
  136. client code. This should not be a cache entry (note that this also means
  137. this variable should not be used as the result variable of a
  138. :command:`find_path` command - see ``Xxx_INCLUDE_DIR`` below for that).
  139. ``Xxx_LIBRARIES``
  140. The libraries to use with the module. These may be CMake targets, full
  141. absolute paths to a library binary or the name of a library that the
  142. linker must find in its search path. This should not be a cache entry
  143. (note that this also means this variable should not be used as the
  144. result variable of a :command:`find_library` command - see
  145. ``Xxx_LIBRARY`` below for that).
  146. ``Xxx_DEFINITIONS``
  147. The compile definitions to use when compiling code that uses the module.
  148. This really shouldn't include options such as ``-DHAS_JPEG`` that a client
  149. source-code file uses to decide whether to ``#include <jpeg.h>``
  150. ``Xxx_EXECUTABLE``
  151. The full absolute path to an executable. In this case, ``Xxx`` might not
  152. be the name of the module, it might be the name of the tool (usually
  153. converted to all uppercase), assuming that tool has such a well-known name
  154. that it is unlikely that another tool with the same name exists. It would
  155. be appropriate to use this as the result variable of a
  156. :command:`find_program` command.
  157. ``Xxx_YYY_EXECUTABLE``
  158. Similar to ``Xxx_EXECUTABLE`` except here the ``Xxx`` is always the module
  159. name and ``YYY`` is the tool name (again, usually fully uppercase).
  160. Prefer this form if the tool name is not very widely known or has the
  161. potential to clash with another tool. For greater consistency, also
  162. prefer this form if the module provides more than one executable.
  163. ``Xxx_LIBRARY_DIRS``
  164. Optionally, the final set of library directories listed in one
  165. variable for use by client code. This should not be a cache entry.
  166. ``Xxx_ROOT_DIR``
  167. The base directory of the installation of ``Xxx`` that can be optionally set
  168. by the find module if ``Xxx`` is found. This is useful for large packages
  169. where many files need to be referenced relative to a common base (or root)
  170. directory. Not to be confused with the ``Xxx_ROOT`` hint variable set from the
  171. outside for the find module to know where to look for the ``Xxx``.
  172. ``Xxx_VERSION_VV``
  173. Variables of this form specify whether the ``Xxx`` module being provided
  174. is version ``VV`` of the module. There should not be more than one
  175. variable of this form set to true for a given module. For example, a
  176. module ``Barry`` might have evolved over many years and gone through a
  177. number of different major versions. Version 3 of the ``Barry`` module
  178. might set the variable ``Barry_VERSION_3`` to true, whereas an older
  179. version of the module might set ``Barry_VERSION_2`` to true instead.
  180. It would be an error for both ``Barry_VERSION_3`` and ``Barry_VERSION_2``
  181. to both be set to true.
  182. ``Xxx_WRAP_YY``
  183. When a variable of this form is set to false, it indicates that the
  184. relevant wrapping command should not be used. The wrapping command
  185. depends on the module, it may be implied by the module name or it might
  186. be specified by the ``YY`` part of the variable.
  187. ``Xxx_Yy_FOUND``
  188. For variables of this form, ``Yy`` is the name of a component for the
  189. module. It should match exactly one of the valid component names that
  190. may be passed to the :command:`find_package` command for the module.
  191. If a variable of this form is set to false, it means that the ``Yy``
  192. component of module ``Xxx`` was not found or is not available.
  193. Variables of this form would typically be used for optional components
  194. so that the caller can check whether an optional component is available.
  195. ``Xxx_FOUND``
  196. When the :command:`find_package` command returns to the caller, this
  197. variable will be set to true if the module was deemed to have been found
  198. successfully.
  199. ``Xxx_NOT_FOUND_MESSAGE``
  200. Should be set by config-files in the case that it has set
  201. ``Xxx_FOUND`` to FALSE. The contained message will be printed by the
  202. :command:`find_package` command and by
  203. :command:`find_package_handle_standard_args` to inform the user about the
  204. problem. Use this instead of calling :command:`message` directly to
  205. report a reason for failing to find the module or package.
  206. ``Xxx_RUNTIME_LIBRARY_DIRS``
  207. Optionally, the runtime library search path for use when running an
  208. executable linked to shared libraries. The list should be used by
  209. user code to create the ``PATH`` on windows or ``LD_LIBRARY_PATH`` on
  210. UNIX. This should not be a cache entry.
  211. ``Xxx_VERSION``
  212. The full version string of the package found, if any. Note that some existing
  213. modules may also provide ``Xxx_VERSION_STRING``, as it was traditionally used
  214. before the current naming convention.
  215. ``Xxx_VERSION_MAJOR``
  216. The major version of the package found, if any.
  217. ``Xxx_VERSION_MINOR``
  218. The minor version of the package found, if any.
  219. ``Xxx_VERSION_PATCH``
  220. The patch version of the package found, if any.
  221. The following names should not usually be used in ``CMakeLists.txt`` files.
  222. They are intended for use by Find modules to specify and cache the locations
  223. of specific files or directories. Users are typically able to set and edit
  224. these variables to control the behavior of Find modules (like entering the
  225. path to a library manually):
  226. ``Xxx_LIBRARY``
  227. The path of the library. Use this form only when the module provides a
  228. single library. It is appropriate to use this as the result variable
  229. in a :command:`find_library` command.
  230. ``Xxx_Yy_LIBRARY``
  231. The path of library ``Yy`` provided by the module ``Xxx``. Use this form
  232. when the module provides more than one library or where other modules may
  233. also provide a library of the same name. It is also appropriate to use
  234. this form as the result variable in a :command:`find_library` command.
  235. ``Xxx_INCLUDE_DIR``
  236. When the module provides only a single library, this variable can be used
  237. to specify where to find headers for using the library (or more accurately,
  238. the path that consumers of the library should add to their header search
  239. path). It would be appropriate to use this as the result variable in a
  240. :command:`find_path` command.
  241. ``Xxx_Yy_INCLUDE_DIR``
  242. If the module provides more than one library or where other modules may
  243. also provide a library of the same name, this form is recommended for
  244. specifying where to find headers for using library ``Yy`` provided by
  245. the module. Again, it would be appropriate to use this as the result
  246. variable in a :command:`find_path` command.
  247. To prevent users being overwhelmed with settings to configure, try to
  248. keep as many options as possible out of the cache, leaving at least one
  249. option which can be used to disable use of the module, or locate a
  250. not-found library (e.g. ``Xxx_ROOT_DIR``). For the same reason, mark
  251. most cache options as advanced. For packages which provide both debug
  252. and release binaries, it is common to create cache variables with a
  253. ``_LIBRARY_<CONFIG>`` suffix, such as ``Foo_LIBRARY_RELEASE`` and
  254. ``Foo_LIBRARY_DEBUG``. The :module:`SelectLibraryConfigurations` module
  255. can be helpful for such cases.
  256. While these are the standard variable names, backward compatibility should be
  257. provided for any previously used names in the find module that is replacing an
  258. older version. Old variable names should be documented as deprecated to
  259. discourage further use.
  260. A Sample Find Module
  261. --------------------
  262. We will describe how to create a simple find module for a library ``Foo``.
  263. The top of the module should begin with a license notice, followed by
  264. a blank line, and then followed by a :ref:`Bracket Comment`. The comment
  265. should begin with ``.rst:`` to indicate that the rest of its content is
  266. reStructuredText-format documentation. For example:
  267. ::
  268. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  269. # file LICENSE.rst or https://cmake.org/licensing for details.
  270. #[=======================================================================[.rst:
  271. FindFoo
  272. -------
  273. Finds the Foo library.
  274. Imported Targets
  275. ^^^^^^^^^^^^^^^^
  276. This module provides the following imported targets, if found:
  277. ``Foo::Foo``
  278. The Foo library
  279. Result Variables
  280. ^^^^^^^^^^^^^^^^
  281. This module defines the following variables:
  282. ``Foo_FOUND``
  283. Boolean indicating whether (the requested version of) Foo was found.
  284. ``Foo_VERSION``
  285. The version of the Foo library which was found.
  286. ``Foo_INCLUDE_DIRS``
  287. Include directories needed to use Foo.
  288. ``Foo_LIBRARIES``
  289. Libraries needed to link to Foo.
  290. Cache Variables
  291. ^^^^^^^^^^^^^^^
  292. The following cache variables may also be set:
  293. ``Foo_INCLUDE_DIR``
  294. The directory containing ``foo.h``.
  295. ``Foo_LIBRARY``
  296. The path to the Foo library.
  297. #]=======================================================================]
  298. The module documentation consists of:
  299. * An underlined heading specifying the module name.
  300. * A simple description of what the module finds.
  301. More description may be required for some packages. If there are
  302. caveats or other details users of the module should be aware of,
  303. specify them here.
  304. * A section listing imported targets provided by the module, if any.
  305. * A section listing result variables provided by the module.
  306. * Optionally a section listing cache variables used by the module, if any.
  307. If the package provides any macros or functions, they should be listed in
  308. an additional section, but can be documented by additional ``.rst:``
  309. comment blocks immediately above where those macros or functions are defined.
  310. The find module implementation may begin below the documentation block.
  311. Now the actual libraries and so on have to be found. The code here will
  312. obviously vary from module to module (dealing with that, after all, is the
  313. point of find modules), but there tends to be a common pattern for libraries.
  314. First, we try to use ``pkg-config`` to find the library. Note that we
  315. cannot rely on this, as it may not be available, but it provides a good
  316. starting point.
  317. .. code-block:: cmake
  318. find_package(PkgConfig)
  319. if(PkgConfig_FOUND)
  320. pkg_check_modules(PC_Foo QUIET Foo)
  321. endif()
  322. This should define some variables starting ``PC_Foo_`` that contain the
  323. information from the ``Foo.pc`` file.
  324. Now we need to find the libraries and include files; we use the
  325. information from ``pkg-config`` to provide hints to CMake about where to
  326. look before checking other default paths.
  327. .. code-block:: cmake
  328. find_path(Foo_INCLUDE_DIR
  329. NAMES foo.h
  330. HINTS ${PC_Foo_INCLUDE_DIRS}
  331. PATH_SUFFIXES Foo
  332. )
  333. find_library(Foo_LIBRARY
  334. NAMES foo
  335. HINTS ${PC_Foo_LIBRARY_DIRS}
  336. )
  337. Alternatively, if the library is available with multiple configurations, the
  338. :module:`SelectLibraryConfigurations` module can be used to automatically set
  339. the ``Foo_LIBRARY`` variable instead:
  340. .. code-block:: cmake
  341. find_library(Foo_LIBRARY_RELEASE
  342. NAMES foo
  343. HINTS ${PC_Foo_LIBRARY_DIRS}/Release
  344. )
  345. find_library(Foo_LIBRARY_DEBUG
  346. NAMES foo
  347. HINTS ${PC_Foo_LIBRARY_DIRS}/Debug
  348. )
  349. include(SelectLibraryConfigurations)
  350. select_library_configurations(Foo)
  351. If there is a good way of getting the version (from a header file, for
  352. example), that information can be used to set ``Foo_VERSION``. Otherwise,
  353. attempt to use the information from the ``pkg-config``:
  354. .. code-block:: cmake
  355. set(Foo_VERSION ${PC_Foo_VERSION})
  356. Now we can use the :module:`FindPackageHandleStandardArgs` module to handle most
  357. of the remaining steps for us:
  358. .. code-block:: cmake
  359. include(FindPackageHandleStandardArgs)
  360. find_package_handle_standard_args(Foo
  361. REQUIRED_VARS
  362. Foo_LIBRARY
  363. Foo_INCLUDE_DIR
  364. VERSION_VAR Foo_VERSION
  365. )
  366. This will check that the ``REQUIRED_VARS`` contain values (that do not
  367. end in ``-NOTFOUND``) and set ``Foo_FOUND`` appropriately. It will also
  368. cache those values. If ``Foo_VERSION`` is set, and a required version
  369. was passed to :command:`find_package`, it will check the requested version
  370. against the one in ``Foo_VERSION``. It will also print messages as
  371. appropriate; note that if the package was found, it will print the
  372. contents of the first required variable to indicate where it was found.
  373. At this point, we have to provide a way for users of the find module to
  374. link to the library or libraries that were found. There are two
  375. approaches, as discussed in the `Find Modules`_ section above. The
  376. traditional variable approach looks like
  377. .. code-block:: cmake
  378. if(Foo_FOUND)
  379. set(Foo_LIBRARIES ${Foo_LIBRARY})
  380. set(Foo_INCLUDE_DIRS ${Foo_INCLUDE_DIR})
  381. set(Foo_DEFINITIONS ${PC_Foo_CFLAGS_OTHER})
  382. endif()
  383. If more than one library was found, all of them should be included in
  384. these variables (see the `Standard Variable Names`_ section for more
  385. information).
  386. When providing imported targets, these should be namespaced (hence the
  387. ``Foo::`` prefix); CMake will recognize that values passed to
  388. :command:`target_link_libraries` that contain ``::`` in their name are
  389. supposed to be imported targets (rather than just library names), and
  390. will produce appropriate diagnostic messages if that target does not
  391. exist (see policy :policy:`CMP0028`).
  392. .. code-block:: cmake
  393. if(Foo_FOUND AND NOT TARGET Foo::Foo)
  394. add_library(Foo::Foo UNKNOWN IMPORTED)
  395. set_target_properties(Foo::Foo PROPERTIES
  396. IMPORTED_LOCATION "${Foo_LIBRARY}"
  397. INTERFACE_COMPILE_OPTIONS "${PC_Foo_CFLAGS_OTHER}"
  398. INTERFACE_INCLUDE_DIRECTORIES "${Foo_INCLUDE_DIR}"
  399. )
  400. endif()
  401. One thing to note about this is that the ``INTERFACE_INCLUDE_DIRECTORIES`` and
  402. similar properties should only contain information about the target itself, and
  403. not any of its dependencies. Instead, those dependencies should also be
  404. targets, and CMake should be told that they are dependencies of this target.
  405. CMake will then combine all the necessary information automatically.
  406. The type of the :prop_tgt:`IMPORTED` target created in the
  407. :command:`add_library` command can always be specified as ``UNKNOWN``
  408. type. This simplifies the code in cases where static or shared variants may
  409. be found, and CMake will determine the type by inspecting the files.
  410. If the library is available with multiple configurations, the
  411. :prop_tgt:`IMPORTED_CONFIGURATIONS` target property should also be
  412. populated:
  413. .. code-block:: cmake
  414. if(Foo_FOUND)
  415. if (NOT TARGET Foo::Foo)
  416. add_library(Foo::Foo UNKNOWN IMPORTED)
  417. endif()
  418. if (Foo_LIBRARY_RELEASE)
  419. set_property(TARGET Foo::Foo APPEND PROPERTY
  420. IMPORTED_CONFIGURATIONS RELEASE
  421. )
  422. set_target_properties(Foo::Foo PROPERTIES
  423. IMPORTED_LOCATION_RELEASE "${Foo_LIBRARY_RELEASE}"
  424. )
  425. endif()
  426. if (Foo_LIBRARY_DEBUG)
  427. set_property(TARGET Foo::Foo APPEND PROPERTY
  428. IMPORTED_CONFIGURATIONS DEBUG
  429. )
  430. set_target_properties(Foo::Foo PROPERTIES
  431. IMPORTED_LOCATION_DEBUG "${Foo_LIBRARY_DEBUG}"
  432. )
  433. endif()
  434. set_target_properties(Foo::Foo PROPERTIES
  435. INTERFACE_COMPILE_OPTIONS "${PC_Foo_CFLAGS_OTHER}"
  436. INTERFACE_INCLUDE_DIRECTORIES "${Foo_INCLUDE_DIR}"
  437. )
  438. endif()
  439. The ``RELEASE`` variant should be listed first in the property
  440. so that the variant is chosen if the user uses a configuration which is
  441. not an exact match for any listed ``IMPORTED_CONFIGURATIONS``.
  442. Most of the cache variables should be marked as advanced to remain hidden in GUI
  443. interfaces such as :manual:`cmake-gui(1)` or :manual:`ccmake(1)`, unless the
  444. user explicitly chooses to display and modify them:
  445. .. code-block:: cmake
  446. mark_as_advanced(
  447. Foo_INCLUDE_DIR
  448. Foo_LIBRARY
  449. )
  450. If this find module replaces an older module version that provided variables
  451. before the current standard variables naming conventions, also backward
  452. compatibility variables should be provided to cause the least disruption
  453. possible. For example:
  454. .. code-block:: cmake
  455. # Backward compatibility variables
  456. set(Foo_VERSION_STRING ${Foo_VERSION})