FeatureSummary.cmake 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. FeatureSummary
  5. --------------
  6. Functions for generating a summary of enabled/disabled features.
  7. These functions can be used to generate a summary of enabled and disabled
  8. packages and/or feature for a build tree such as::
  9. -- The following OPTIONAL packages have been found:
  10. LibXml2 (required version >= 2.4), XML processing lib, <http://xmlsoft.org>
  11. * Enables HTML-import in MyWordProcessor
  12. * Enables odt-export in MyWordProcessor
  13. PNG, A PNG image library., <http://www.libpng.org/pub/png/>
  14. * Enables saving screenshots
  15. -- The following OPTIONAL packages have not been found:
  16. Lua51, The Lua scripting language., <http://www.lua.org>
  17. * Enables macros in MyWordProcessor
  18. Foo, Foo provides cool stuff.
  19. Functions
  20. ^^^^^^^^^
  21. #]=======================================================================]
  22. function(_FS_GET_FEATURE_SUMMARY _property _var _includeQuiet)
  23. set(_type "ANY")
  24. if("${_property}" MATCHES "REQUIRED_")
  25. set(_type "REQUIRED")
  26. elseif("${_property}" MATCHES "RECOMMENDED_")
  27. set(_type "RECOMMENDED")
  28. elseif("${_property}" MATCHES "RUNTIME_")
  29. set(_type "RUNTIME")
  30. elseif("${_property}" MATCHES "OPTIONAL_")
  31. set(_type "OPTIONAL")
  32. endif()
  33. if("${_property}" MATCHES "PACKAGES_FOUND")
  34. set(_property "PACKAGES_FOUND")
  35. elseif("${_property}" MATCHES "PACKAGES_NOT_FOUND")
  36. set(_property "PACKAGES_NOT_FOUND")
  37. endif()
  38. set(_currentFeatureText "")
  39. get_property(_EnabledFeatures GLOBAL PROPERTY ${_property})
  40. if(_EnabledFeatures)
  41. list(REMOVE_DUPLICATES _EnabledFeatures)
  42. endif(_EnabledFeatures)
  43. foreach(_currentFeature ${_EnabledFeatures})
  44. # does this package belong to the type we currently want to list ?
  45. get_property(_currentType GLOBAL PROPERTY _CMAKE_${_currentFeature}_TYPE)
  46. if(NOT _currentType)
  47. set(_currentType OPTIONAL)
  48. endif()
  49. if("${_type}" STREQUAL ANY OR "${_type}" STREQUAL "${_currentType}")
  50. # check whether the current feature/package should be in the output depending on whether it was QUIET or not
  51. set(includeThisOne TRUE)
  52. # skip QUIET packages, except if they are REQUIRED or INCLUDE_QUIET_PACKAGES has been set
  53. if((NOT "${_currentType}" STREQUAL "REQUIRED") AND NOT _includeQuiet)
  54. get_property(_isQuiet GLOBAL PROPERTY _CMAKE_${_currentFeature}_QUIET)
  55. if(_isQuiet)
  56. set(includeThisOne FALSE)
  57. endif()
  58. endif()
  59. get_property(_isTransitiveDepend
  60. GLOBAL PROPERTY _CMAKE_${_currentFeature}_TRANSITIVE_DEPENDENCY
  61. )
  62. if(_isTransitiveDepend)
  63. set(includeThisOne FALSE)
  64. endif()
  65. if(includeThisOne)
  66. string(APPEND _currentFeatureText "\n * ${_currentFeature}")
  67. get_property(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_REQUIRED_VERSION)
  68. if(_info)
  69. string(APPEND _currentFeatureText " (required version ${_info})")
  70. endif()
  71. get_property(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_DESCRIPTION)
  72. if(_info)
  73. string(APPEND _currentFeatureText ", ${_info}")
  74. endif()
  75. get_property(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_URL)
  76. if(_info)
  77. string(APPEND _currentFeatureText ", <${_info}>")
  78. endif()
  79. get_property(_info GLOBAL PROPERTY _CMAKE_${_currentFeature}_PURPOSE)
  80. foreach(_purpose ${_info})
  81. string(APPEND _currentFeatureText "\n ${_purpose}")
  82. endforeach()
  83. endif()
  84. endif()
  85. endforeach()
  86. set(${_var} "${_currentFeatureText}" PARENT_SCOPE)
  87. endfunction()
  88. #[=======================================================================[.rst:
  89. .. command:: feature_summary
  90. ::
  91. feature_summary( [FILENAME <file>]
  92. [APPEND]
  93. [VAR <variable_name>]
  94. [INCLUDE_QUIET_PACKAGES]
  95. [FATAL_ON_MISSING_REQUIRED_PACKAGES]
  96. [DESCRIPTION "Found packages:"]
  97. WHAT (ALL | PACKAGES_FOUND | PACKAGES_NOT_FOUND
  98. | ENABLED_FEATURES | DISABLED_FEATURES)
  99. )
  100. The ``feature_summary()`` macro can be used to print information about
  101. enabled or disabled packages or features of a project. By default,
  102. only the names of the features/packages will be printed and their
  103. required version when one was specified. Use ``set_package_properties()``
  104. to add more useful information, like e.g. a download URL for the
  105. respective package or their purpose in the project.
  106. The ``WHAT`` option is the only mandatory option. Here you specify what
  107. information will be printed:
  108. ``ALL``
  109. print everything
  110. ``ENABLED_FEATURES``
  111. the list of all features which are enabled
  112. ``DISABLED_FEATURES``
  113. the list of all features which are disabled
  114. ``PACKAGES_FOUND``
  115. the list of all packages which have been found
  116. ``PACKAGES_NOT_FOUND``
  117. the list of all packages which have not been found
  118. ``OPTIONAL_PACKAGES_FOUND``
  119. only those packages which have been found which have the type OPTIONAL
  120. ``OPTIONAL_PACKAGES_NOT_FOUND``
  121. only those packages which have not been found which have the type OPTIONAL
  122. ``RECOMMENDED_PACKAGES_FOUND``
  123. only those packages which have been found which have the type RECOMMENDED
  124. ``RECOMMENDED_PACKAGES_NOT_FOUND``
  125. only those packages which have not been found which have the type RECOMMENDED
  126. ``REQUIRED_PACKAGES_FOUND``
  127. only those packages which have been found which have the type REQUIRED
  128. ``REQUIRED_PACKAGES_NOT_FOUND``
  129. only those packages which have not been found which have the type REQUIRED
  130. ``RUNTIME_PACKAGES_FOUND``
  131. only those packages which have been found which have the type RUNTIME
  132. ``RUNTIME_PACKAGES_NOT_FOUND``
  133. only those packages which have not been found which have the type RUNTIME
  134. With the exception of the ``ALL`` value, these values can be combined
  135. in order to customize the output. For example:
  136. .. code-block:: cmake
  137. feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
  138. If a ``FILENAME`` is given, the information is printed into this file. If
  139. ``APPEND`` is used, it is appended to this file, otherwise the file is
  140. overwritten if it already existed. If the VAR option is used, the
  141. information is "printed" into the specified variable. If ``FILENAME`` is
  142. not used, the information is printed to the terminal. Using the
  143. ``DESCRIPTION`` option a description or headline can be set which will be
  144. printed above the actual content. If ``INCLUDE_QUIET_PACKAGES`` is given,
  145. packages which have been searched with ``find_package(... QUIET)`` will
  146. also be listed. By default they are skipped. If
  147. ``FATAL_ON_MISSING_REQUIRED_PACKAGES`` is given, CMake will abort if a
  148. package which is marked as ``REQUIRED`` has not been found.
  149. Example 1, append everything to a file:
  150. .. code-block:: cmake
  151. include(FeatureSummary)
  152. feature_summary(WHAT ALL
  153. FILENAME ${CMAKE_BINARY_DIR}/all.log APPEND)
  154. Example 2, print the enabled features into the variable
  155. enabledFeaturesText, including QUIET packages:
  156. .. code-block:: cmake
  157. include(FeatureSummary)
  158. feature_summary(WHAT ENABLED_FEATURES
  159. INCLUDE_QUIET_PACKAGES
  160. DESCRIPTION "Enabled Features:"
  161. VAR enabledFeaturesText)
  162. message(STATUS "${enabledFeaturesText}")
  163. #]=======================================================================]
  164. function(FEATURE_SUMMARY)
  165. # CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...)
  166. set(options APPEND INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
  167. set(oneValueArgs FILENAME VAR DESCRIPTION)
  168. set(multiValueArgs WHAT)
  169. CMAKE_PARSE_ARGUMENTS(_FS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN})
  170. if(_FS_UNPARSED_ARGUMENTS)
  171. message(FATAL_ERROR "Unknown keywords given to FEATURE_SUMMARY(): \"${_FS_UNPARSED_ARGUMENTS}\"")
  172. endif()
  173. if(NOT _FS_WHAT)
  174. message(FATAL_ERROR "The call to FEATURE_SUMMARY() doesn't set the required WHAT argument.")
  175. endif()
  176. set(validWhatParts "ENABLED_FEATURES"
  177. "DISABLED_FEATURES"
  178. "PACKAGES_FOUND"
  179. "PACKAGES_NOT_FOUND"
  180. "OPTIONAL_PACKAGES_FOUND"
  181. "OPTIONAL_PACKAGES_NOT_FOUND"
  182. "RECOMMENDED_PACKAGES_FOUND"
  183. "RECOMMENDED_PACKAGES_NOT_FOUND"
  184. "REQUIRED_PACKAGES_FOUND"
  185. "REQUIRED_PACKAGES_NOT_FOUND"
  186. "RUNTIME_PACKAGES_FOUND"
  187. "RUNTIME_PACKAGES_NOT_FOUND")
  188. list(FIND validWhatParts "${_FS_WHAT}" indexInList)
  189. if(NOT "${indexInList}" STREQUAL "-1")
  190. _FS_GET_FEATURE_SUMMARY( ${_FS_WHAT} _featureSummary ${_FS_INCLUDE_QUIET_PACKAGES} )
  191. set(_fullText "${_FS_DESCRIPTION}${_featureSummary}\n")
  192. if (("${_FS_WHAT}" STREQUAL "REQUIRED_PACKAGES_NOT_FOUND") AND _featureSummary)
  193. set(requiredPackagesNotFound TRUE)
  194. endif()
  195. else()
  196. if("${_FS_WHAT}" STREQUAL "ALL")
  197. set(allWhatParts "ENABLED_FEATURES"
  198. "RUNTIME_PACKAGES_FOUND"
  199. "OPTIONAL_PACKAGES_FOUND"
  200. "RECOMMENDED_PACKAGES_FOUND"
  201. "REQUIRED_PACKAGES_FOUND"
  202. "DISABLED_FEATURES"
  203. "RUNTIME_PACKAGES_NOT_FOUND"
  204. "OPTIONAL_PACKAGES_NOT_FOUND"
  205. "RECOMMENDED_PACKAGES_NOT_FOUND"
  206. "REQUIRED_PACKAGES_NOT_FOUND"
  207. )
  208. else()
  209. set(allWhatParts)
  210. foreach(part ${_FS_WHAT})
  211. list(FIND validWhatParts "${part}" indexInList)
  212. if(NOT "${indexInList}" STREQUAL "-1")
  213. list(APPEND allWhatParts "${part}")
  214. else()
  215. if("${part}" STREQUAL "ALL")
  216. message(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() contains ALL, which cannot be combined with other values.")
  217. else()
  218. message(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() contains ${part}, which is not a valid value.")
  219. endif()
  220. endif()
  221. endforeach()
  222. endif()
  223. set(title_ENABLED_FEATURES "The following features have been enabled:")
  224. set(title_DISABLED_FEATURES "The following features have been disabled:")
  225. set(title_PACKAGES_FOUND "The following packages have been found:")
  226. set(title_PACKAGES_NOT_FOUND "The following packages have not been found:")
  227. set(title_OPTIONAL_PACKAGES_FOUND "The following OPTIONAL packages have been found:")
  228. set(title_OPTIONAL_PACKAGES_NOT_FOUND "The following OPTIONAL packages have not been found:")
  229. set(title_RECOMMENDED_PACKAGES_FOUND "The following RECOMMENDED packages have been found:")
  230. set(title_RECOMMENDED_PACKAGES_NOT_FOUND "The following RECOMMENDED packages have not been found:")
  231. set(title_REQUIRED_PACKAGES_FOUND "The following REQUIRED packages have been found:")
  232. set(title_REQUIRED_PACKAGES_NOT_FOUND "The following REQUIRED packages have not been found:")
  233. set(title_RUNTIME_PACKAGES_FOUND "The following RUNTIME packages have been found:")
  234. set(title_RUNTIME_PACKAGES_NOT_FOUND "The following RUNTIME packages have not been found:")
  235. set(_fullText "${_FS_DESCRIPTION}")
  236. foreach(part ${allWhatParts})
  237. set(_tmp)
  238. _FS_GET_FEATURE_SUMMARY( ${part} _tmp ${_FS_INCLUDE_QUIET_PACKAGES})
  239. if(_tmp)
  240. if(_fullText)
  241. string(APPEND _fullText "\n-- ")
  242. endif()
  243. string(APPEND _fullText "${title_${part}}\n${_tmp}\n")
  244. if("${part}" STREQUAL "REQUIRED_PACKAGES_NOT_FOUND")
  245. set(requiredPackagesNotFound TRUE)
  246. endif()
  247. endif()
  248. endforeach()
  249. endif()
  250. if(_FS_FILENAME)
  251. if(_FS_APPEND)
  252. file(APPEND "${_FS_FILENAME}" "${_fullText}")
  253. else()
  254. file(WRITE "${_FS_FILENAME}" "${_fullText}")
  255. endif()
  256. else()
  257. if(NOT _FS_VAR)
  258. message(STATUS "${_fullText}")
  259. endif()
  260. endif()
  261. if(_FS_VAR)
  262. set(${_FS_VAR} "${_fullText}" PARENT_SCOPE)
  263. endif()
  264. if(requiredPackagesNotFound AND _FS_FATAL_ON_MISSING_REQUIRED_PACKAGES)
  265. message(FATAL_ERROR "feature_summary() Error: REQUIRED package(s) are missing, aborting CMake run.")
  266. endif()
  267. endfunction()
  268. #[=======================================================================[.rst:
  269. .. command:: set_package_properties
  270. ::
  271. set_package_properties(<name> PROPERTIES
  272. [ URL <url> ]
  273. [ DESCRIPTION <description> ]
  274. [ TYPE (RUNTIME|OPTIONAL|RECOMMENDED|REQUIRED) ]
  275. [ PURPOSE <purpose> ]
  276. )
  277. Use this macro to set up information about the named package, which
  278. can then be displayed via FEATURE_SUMMARY(). This can be done either
  279. directly in the Find-module or in the project which uses the module
  280. after the find_package() call. The features for which information can
  281. be set are added automatically by the find_package() command.
  282. ``URL <url>``
  283. This should be the homepage of the package, or something similar.
  284. Ideally this is set already directly in the Find-module.
  285. ``DESCRIPTION <description>``
  286. A short description what that package is, at most one sentence.
  287. Ideally this is set already directly in the Find-module.
  288. ``TYPE <type>``
  289. What type of dependency has the using project on that package.
  290. Default is ``OPTIONAL``. In this case it is a package which can be used
  291. by the project when available at buildtime, but it also work without.
  292. ``RECOMMENDED`` is similar to ``OPTIONAL``, i.e. the project will build if
  293. the package is not present, but the functionality of the resulting
  294. binaries will be severly limited. If a ``REQUIRED`` package is not
  295. available at buildtime, the project may not even build. This can be
  296. combined with the ``FATAL_ON_MISSING_REQUIRED_PACKAGES`` argument for
  297. ``feature_summary()``. Last, a ``RUNTIME`` package is a package which is
  298. actually not used at all during the build, but which is required for
  299. actually running the resulting binaries. So if such a package is
  300. missing, the project can still be built, but it may not work later on.
  301. If ``set_package_properties()`` is called multiple times for the same
  302. package with different TYPEs, the ``TYPE`` is only changed to higher
  303. TYPEs (``RUNTIME < OPTIONAL < RECOMMENDED < REQUIRED``), lower TYPEs are
  304. ignored. The ``TYPE`` property is project-specific, so it cannot be set
  305. by the Find-module, but must be set in the project.
  306. ``PURPOSE <purpose>``
  307. This describes which features this package enables in the
  308. project, i.e. it tells the user what functionality he gets in the
  309. resulting binaries. If set_package_properties() is called multiple
  310. times for a package, all PURPOSE properties are appended to a list of
  311. purposes of the package in the project. As the TYPE property, also
  312. the PURPOSE property is project-specific, so it cannot be set by the
  313. Find-module, but must be set in the project.
  314. Example for setting the info for a package:
  315. .. code-block:: cmake
  316. find_package(LibXml2)
  317. set_package_properties(LibXml2 PROPERTIES
  318. DESCRIPTION "A XML processing library."
  319. URL "http://xmlsoft.org/")
  320. # or
  321. set_package_properties(LibXml2 PROPERTIES
  322. TYPE RECOMMENDED
  323. PURPOSE "Enables HTML-import in MyWordProcessor")
  324. # or
  325. set_package_properties(LibXml2 PROPERTIES
  326. TYPE OPTIONAL
  327. PURPOSE "Enables odt-export in MyWordProcessor")
  328. find_package(DBUS)
  329. set_package_properties(DBUS PROPERTIES
  330. TYPE RUNTIME
  331. PURPOSE "Necessary to disable the screensaver during a presentation")
  332. #]=======================================================================]
  333. function(SET_PACKAGE_PROPERTIES _name _props)
  334. if(NOT "${_props}" STREQUAL "PROPERTIES")
  335. message(FATAL_ERROR "PROPERTIES keyword is missing in SET_PACKAGE_PROPERTIES() call.")
  336. endif()
  337. set(options ) # none
  338. set(oneValueArgs DESCRIPTION URL TYPE PURPOSE )
  339. set(multiValueArgs ) # none
  340. CMAKE_PARSE_ARGUMENTS(_SPP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
  341. if(_SPP_UNPARSED_ARGUMENTS)
  342. message(FATAL_ERROR "Unknown keywords given to SET_PACKAGE_PROPERTIES(): \"${_SPP_UNPARSED_ARGUMENTS}\"")
  343. endif()
  344. if(_SPP_DESCRIPTION)
  345. get_property(_info GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION)
  346. if(_info AND NOT "${_info}" STREQUAL "${_SPP_DESCRIPTION}")
  347. message(STATUS "Warning: Property DESCRIPTION for package ${_name} already set to \"${_info}\", overriding it with \"${_SPP_DESCRIPTION}\"")
  348. endif()
  349. set_property(GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION "${_SPP_DESCRIPTION}" )
  350. endif()
  351. if(_SPP_URL)
  352. get_property(_info GLOBAL PROPERTY _CMAKE_${_name}_URL)
  353. if(_info AND NOT "${_info}" STREQUAL "${_SPP_URL}")
  354. message(STATUS "Warning: Property URL already set to \"${_info}\", overriding it with \"${_SPP_URL}\"")
  355. endif()
  356. set_property(GLOBAL PROPERTY _CMAKE_${_name}_URL "${_SPP_URL}" )
  357. endif()
  358. # handle the PURPOSE: use APPEND, since there can be multiple purposes for one package inside a project
  359. if(_SPP_PURPOSE)
  360. set_property(GLOBAL APPEND PROPERTY _CMAKE_${_name}_PURPOSE "${_SPP_PURPOSE}" )
  361. endif()
  362. # handle the TYPE
  363. if(NOT _SPP_TYPE)
  364. set(_SPP_TYPE OPTIONAL)
  365. endif()
  366. # List the supported types, according to their priority
  367. set(validTypes "RUNTIME" "OPTIONAL" "RECOMMENDED" "REQUIRED" )
  368. list(FIND validTypes ${_SPP_TYPE} _typeIndexInList)
  369. if("${_typeIndexInList}" STREQUAL "-1" )
  370. message(FATAL_ERROR "Bad package property type ${_SPP_TYPE} used in SET_PACKAGE_PROPERTIES(). "
  371. "Valid types are OPTIONAL, RECOMMENDED, REQUIRED and RUNTIME." )
  372. endif()
  373. get_property(_previousType GLOBAL PROPERTY _CMAKE_${_name}_TYPE)
  374. list(FIND validTypes "${_previousType}" _prevTypeIndexInList)
  375. # make sure a previously set TYPE is not overridden with a lower new TYPE:
  376. if("${_typeIndexInList}" GREATER "${_prevTypeIndexInList}")
  377. set_property(GLOBAL PROPERTY _CMAKE_${_name}_TYPE "${_SPP_TYPE}" )
  378. endif()
  379. endfunction()
  380. #[=======================================================================[.rst:
  381. .. command:: add_feature_info
  382. ::
  383. add_feature_info(<name> <enabled> <description>)
  384. Use this macro to add information about a feature with the given ``<name>``.
  385. ``<enabled>`` contains whether this feature is enabled or not.
  386. ``<description>`` is a text describing the feature. The information can
  387. be displayed using ``feature_summary()`` for ``ENABLED_FEATURES`` and
  388. ``DISABLED_FEATURES`` respectively.
  389. Example for setting the info for a feature:
  390. .. code-block:: cmake
  391. option(WITH_FOO "Help for foo" ON)
  392. add_feature_info(Foo WITH_FOO "The Foo feature provides very cool stuff.")
  393. #]=======================================================================]
  394. function(ADD_FEATURE_INFO _name _enabled _desc)
  395. if (${_enabled})
  396. set_property(GLOBAL APPEND PROPERTY ENABLED_FEATURES "${_name}")
  397. else ()
  398. set_property(GLOBAL APPEND PROPERTY DISABLED_FEATURES "${_name}")
  399. endif ()
  400. set_property(GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION "${_desc}" )
  401. endfunction()
  402. # The stuff below is only kept for compatibility
  403. #[=======================================================================[.rst:
  404. Legacy Macros
  405. ^^^^^^^^^^^^^
  406. The following macros are provided for compatibility with previous
  407. CMake versions:
  408. .. command:: set_package_info
  409. ::
  410. set_package_info(<name> <description> [ <url> [<purpose>] ])
  411. Use this macro to set up information about the named package, which
  412. can then be displayed via ``feature_summary()``. This can be done either
  413. directly in the Find-module or in the project which uses the module
  414. after the :command:`find_package` call. The features for which information
  415. can be set are added automatically by the ``find_package()`` command.
  416. #]=======================================================================]
  417. function(SET_PACKAGE_INFO _name _desc)
  418. unset(_url)
  419. unset(_purpose)
  420. if(ARGC GREATER 2)
  421. set(_url "${ARGV2}")
  422. endif()
  423. if(ARGC GREATER 3)
  424. set(_purpose "${ARGV3}")
  425. endif()
  426. set_property(GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION "${_desc}" )
  427. if(NOT _url STREQUAL "")
  428. set_property(GLOBAL PROPERTY _CMAKE_${_name}_URL "${_url}" )
  429. endif()
  430. if(NOT _purpose STREQUAL "")
  431. set_property(GLOBAL APPEND PROPERTY _CMAKE_${_name}_PURPOSE "${_purpose}" )
  432. endif()
  433. endfunction()
  434. #[=======================================================================[.rst:
  435. .. command:: set_feature_info
  436. ::
  437. set_feature_info(<name> <description> [<url>])
  438. Does the same as::
  439. set_package_info(<name> <description> <url>)
  440. #]=======================================================================]
  441. function(SET_FEATURE_INFO)
  442. SET_PACKAGE_INFO(${ARGN})
  443. endfunction()
  444. #[=======================================================================[.rst:
  445. .. command:: print_enabled_features
  446. ::
  447. print_enabled_features()
  448. Does the same as
  449. .. code-block:: cmake
  450. feature_summary(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
  451. #]=======================================================================]
  452. function(PRINT_ENABLED_FEATURES)
  453. FEATURE_SUMMARY(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
  454. endfunction()
  455. #[=======================================================================[.rst:
  456. .. command:: print_disabled_features
  457. ::
  458. print_disabled_features()
  459. Does the same as
  460. .. code-block:: cmake
  461. feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")
  462. #]=======================================================================]
  463. function(PRINT_DISABLED_FEATURES)
  464. FEATURE_SUMMARY(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")
  465. endfunction()