cmake-policies.7.rst 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. Each policy can also be set to
  15. either ``NEW`` or ``OLD`` behavior explicitly on the command line with the
  16. :variable:`CMAKE_POLICY_DEFAULT_CMP<NNNN>` variable.
  17. The :command:`cmake_minimum_required` command does more than report an
  18. error if a too-old version of CMake is used to build a project. It
  19. also sets all policies introduced in that CMake version or earlier to
  20. ``NEW`` behavior. To manage policies without increasing the minimum required
  21. CMake version, the :command:`if(POLICY)` command may be used:
  22. .. code-block:: cmake
  23. if(POLICY CMP0990)
  24. cmake_policy(SET CMP0990 NEW)
  25. endif()
  26. This has the effect of using the ``NEW`` behavior with newer CMake releases which
  27. users may be using and not issuing a compatibility warning.
  28. The setting of a policy is confined in some cases to not propagate to the
  29. parent scope. For example, if the files read by the :command:`include` command
  30. or the :command:`find_package` command contain a use of :command:`cmake_policy`,
  31. that policy setting will not affect the caller by default. Both commands accept
  32. an optional ``NO_POLICY_SCOPE`` keyword to control this behavior.
  33. The :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` variable may also be used
  34. to determine whether to report an error on use of deprecated macros or
  35. functions.
  36. All Policies
  37. ============
  38. .. toctree::
  39. :maxdepth: 1
  40. /policy/CMP0000
  41. /policy/CMP0001
  42. /policy/CMP0002
  43. /policy/CMP0003
  44. /policy/CMP0004
  45. /policy/CMP0005
  46. /policy/CMP0006
  47. /policy/CMP0007
  48. /policy/CMP0008
  49. /policy/CMP0009
  50. /policy/CMP0010
  51. /policy/CMP0011
  52. /policy/CMP0012
  53. /policy/CMP0013
  54. /policy/CMP0014
  55. /policy/CMP0015
  56. /policy/CMP0016
  57. /policy/CMP0017
  58. /policy/CMP0018
  59. /policy/CMP0019
  60. /policy/CMP0020
  61. /policy/CMP0021
  62. /policy/CMP0022
  63. /policy/CMP0023
  64. /policy/CMP0024
  65. /policy/CMP0025
  66. /policy/CMP0026
  67. /policy/CMP0027
  68. /policy/CMP0028
  69. /policy/CMP0029
  70. /policy/CMP0030
  71. /policy/CMP0031
  72. /policy/CMP0032
  73. /policy/CMP0033
  74. /policy/CMP0034
  75. /policy/CMP0035
  76. /policy/CMP0036
  77. /policy/CMP0037
  78. /policy/CMP0038
  79. /policy/CMP0039
  80. /policy/CMP0040
  81. /policy/CMP0041
  82. /policy/CMP0042
  83. /policy/CMP0043
  84. /policy/CMP0044
  85. /policy/CMP0045
  86. /policy/CMP0046
  87. /policy/CMP0047
  88. /policy/CMP0048
  89. /policy/CMP0049
  90. /policy/CMP0050
  91. /policy/CMP0051