cmake-policies.7.rst 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. .. cmake-manual-description: CMake Policies Reference
  2. cmake-policies(7)
  3. *****************
  4. .. only:: html or latex
  5. .. contents::
  6. Introduction
  7. ============
  8. Policies in CMake are used to preserve backward compatible behavior
  9. across multiple releases. When a new policy is introduced, newer CMake
  10. versions will begin to warn about the backward compatible behavior. It
  11. is possible to disable the warning by explicitly requesting the OLD, or
  12. backward compatible behavior using the :command:`cmake_policy` command.
  13. It is also possible to request NEW, or non-backward compatible behavior
  14. for a policy, also avoiding the warning.
  15. The :command:`cmake_minimum_required` command does more than report an
  16. error if a too-old version of CMake is used to build a project. It
  17. also sets all policies introduced in that CMake version or earlier to
  18. NEW behavior. To manage policies without increasing the minimum required
  19. CMake version, the :command:`if(POLICY)` command may be used:
  20. .. code-block:: cmake
  21. if(POLICY CMP0990)
  22. cmake_policy(SET CMP0990 NEW)
  23. endif()
  24. This has the effect of using the NEW behavior with newer CMake releases which
  25. users may be using and not issuing a compatibility warning.
  26. The setting of a policy is confined in some cases to not propagate to the
  27. parent scope. For example, if the files read by the :command:`include` command
  28. or the :command:`find_package` command contain a use of :command:`cmake_policy`,
  29. that policy setting will not affect the caller by default. Both commands accept
  30. an optional ``NO_POLICY_SCOPE`` keyword to control this behavior.
  31. The :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` variable may also be used
  32. to determine whether to report an error on use of deprecated macros or
  33. functions.
  34. All Policies
  35. ============
  36. .. toctree::
  37. :maxdepth: 1
  38. /policy/CMP0000
  39. /policy/CMP0001
  40. /policy/CMP0002
  41. /policy/CMP0003
  42. /policy/CMP0004
  43. /policy/CMP0005
  44. /policy/CMP0006
  45. /policy/CMP0007
  46. /policy/CMP0008
  47. /policy/CMP0009
  48. /policy/CMP0010
  49. /policy/CMP0011
  50. /policy/CMP0012
  51. /policy/CMP0013
  52. /policy/CMP0014
  53. /policy/CMP0015
  54. /policy/CMP0016
  55. /policy/CMP0017
  56. /policy/CMP0018
  57. /policy/CMP0019
  58. /policy/CMP0020
  59. /policy/CMP0021
  60. /policy/CMP0022
  61. /policy/CMP0023
  62. /policy/CMP0024
  63. /policy/CMP0025
  64. /policy/CMP0026
  65. /policy/CMP0027
  66. /policy/CMP0028
  67. /policy/CMP0029
  68. /policy/CMP0030
  69. /policy/CMP0031
  70. /policy/CMP0032
  71. /policy/CMP0033
  72. /policy/CMP0034
  73. /policy/CMP0035
  74. /policy/CMP0036
  75. /policy/CMP0037
  76. /policy/CMP0038
  77. /policy/CMP0039
  78. /policy/CMP0040
  79. /policy/CMP0041
  80. /policy/CMP0042