CMP0120.rst 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. CMP0120
  2. -------
  3. .. versionadded:: 3.20
  4. The :module:`WriteCompilerDetectionHeader` module is removed.
  5. CMake versions 3.1 through 3.19 provide this module to generate a
  6. C++ compatibility layer by reusing information from CMake's table of
  7. preprocessor checks for :manual:`cmake-compile-features(7)`. However:
  8. * Those granular features have been superseded by meta-features for
  9. :ref:`Requiring Language Standards` such as ``cxx_std_11``. Therefore
  10. no new granular feature checks will be added and projects will need to
  11. use other means to conditionally use new C++ features.
  12. * The module exposes some of CMake's implementation details directly
  13. to C++ translation units.
  14. * The module's approach effectively provides a header file with CMake,
  15. thus tying the version of the header to the version of CMake.
  16. Many projects found that the :module:`WriteCompilerDetectionHeader` was
  17. best used by manually generating its header locally with a recent version
  18. of CMake and then bundling it with the project source so that it could
  19. be used with older CMake versions.
  20. For reasons including the above, CMake 3.20 and above prefer to not
  21. provide the :module:`WriteCompilerDetectionHeader` module. This policy
  22. provides compatibility for projects that have not been ported away from
  23. it. Projects using the module should be updated to stop using it.
  24. Alternatives include:
  25. * Bundle a copy of the generated header in the project's source.
  26. * Use a third-party alternative, such as the CC0-licensed `Hedley`_.
  27. * Drop support for compilers too old to provide the features natively.
  28. The ``OLD`` behavior of this policy is for inclusion of the deprecated
  29. :module:`WriteCompilerDetectionHeader` module to work. The ``NEW``
  30. behavior is for inclusion of the module to fail as if it does not exist.
  31. .. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.20
  32. .. |WARNS_OR_DOES_NOT_WARN| replace:: warns
  33. .. include:: include/STANDARD_ADVICE.rst
  34. .. include:: include/DEPRECATED.rst
  35. .. _`Hedley`: https://nemequ.github.io/hedley/