CMP0159.rst 1.0 KB

123456789101112131415161718192021222324
  1. CMP0159
  2. -------
  3. .. versionadded:: 3.29
  4. :command:`file(STRINGS)` with ``REGEX`` updates :variable:`CMAKE_MATCH_<n>`.
  5. In CMake 3.28 and below the :command:`file(STRINGS)` command's ``REGEX``
  6. option does not affect :variable:`CMAKE_MATCH_<n>` variables. CMake 3.29
  7. and above prefer to update the :variable:`CMAKE_MATCH_<n>` variables using
  8. captures from the last match in the file, similar to the
  9. :command:`string(REGEX MATCHALL)` command. This policy provides
  10. compatibility for projects that have not been updated to expect the behavior.
  11. The ``OLD`` behavior for this policy is for :command:`file(STRINGS)` with
  12. ``REGEX`` to not store capture groups in :variable:`CMAKE_MATCH_<n>`
  13. variables. The ``NEW`` behavior is to store the capture groups.
  14. This policy was introduced in CMake version 3.29. Use the
  15. :command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
  16. Unlike many policies, CMake version |release| does *not* warn
  17. when this policy is not set and simply uses ``OLD`` behavior.
  18. .. include:: DEPRECATED.txt