message.rst 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. message
  2. -------
  3. Display a message to the user.
  4. .. code-block:: cmake
  5. message([<mode>] "message to display" ...)
  6. The optional ``<mode>`` keyword determines the type of message:
  7. ``FATAL_ERROR``
  8. CMake Error, stop processing and generation.
  9. ``SEND_ERROR``
  10. CMake Error, continue processing, but skip generation.
  11. ``WARNING``
  12. CMake Warning, continue processing.
  13. ``AUTHOR_WARNING``
  14. CMake Warning (dev), continue processing.
  15. ``DEPRECATION``
  16. CMake Deprecation Error or Warning if variable
  17. :variable:`CMAKE_ERROR_DEPRECATED` or :variable:`CMAKE_WARN_DEPRECATED`
  18. is enabled, respectively, else no message.
  19. (none) or ``NOTICE``
  20. Important message printed to stderr to attract user's attention.
  21. ``STATUS``
  22. The main interesting messages that project users might be interested in.
  23. Ideally these should be concise, no more than a single line, but still
  24. informative.
  25. ``VERBOSE``
  26. Detailed informational messages intended for project users. These messages
  27. should provide additional details that won't be of interest in most cases,
  28. but which may be useful to those building the project when they want deeper
  29. insight into what's happening.
  30. ``DEBUG``
  31. Detailed informational messages intended for developers working on the
  32. project itself as opposed to users who just want to build it. These messages
  33. will not typically be of interest to other users building the project and
  34. will often be closely related to internal implementation details.
  35. ``TRACE``
  36. Fine-grained messages with very low-level implementation details. Messages
  37. using this log level would normally only be temporary and would expect to be
  38. removed before releasing the project, packaging up the files, etc.
  39. The CMake command-line tool displays ``STATUS`` to ``TRACE`` messages on stdout
  40. with the message preceded by two hyphens and a space. All other message types
  41. are sent to stderr and are not prefixed with hyphens. The
  42. :manual:`CMake GUI <cmake-gui(1)>` displays all messages in its log area.
  43. The :manual:`curses interface <ccmake(1)>` shows ``STATUS`` to ``TRACE``
  44. messages one at a time on a status line and other messages in an
  45. interactive pop-up box. The ``--log-level`` command-line option to each of
  46. these tools can be used to control which messages will be shown.
  47. To make a log level persist between CMake runs, the
  48. :variable:`CMAKE_MESSAGE_LOG_LEVEL` variable can be set instead.
  49. Note that the command line option takes precedence over the cache variable.
  50. Messages of log levels ``NOTICE`` and below will have each line preceded
  51. by the content of the :variable:`CMAKE_MESSAGE_INDENT` variable (converted to
  52. a single string by concatenating its list items). For ``STATUS`` to ``TRACE``
  53. messages, this indenting content will be inserted after the hyphens.
  54. Messages of log levels ``NOTICE`` and below can also have each line preceded
  55. with context of the form ``[some.context.example]``. The content between the
  56. square brackets is obtained by converting the :variable:`CMAKE_MESSAGE_CONTEXT`
  57. list variable to a dot-separated string. The message context will always
  58. appear before any indenting content but after any automatically added leading
  59. hyphens. By default, message context is not shown, it has to be explicitly
  60. enabled by giving the :manual:`cmake <cmake(1)>` ``--log-context``
  61. command-line option or by setting the :variable:`CMAKE_MESSAGE_CONTEXT_SHOW`
  62. variable to true. See the :variable:`CMAKE_MESSAGE_CONTEXT` documentation for
  63. usage examples.
  64. CMake Warning and Error message text displays using a simple markup
  65. language. Non-indented text is formatted in line-wrapped paragraphs
  66. delimited by newlines. Indented text is considered pre-formatted.