FeatureSummary.cmake 23 KB

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