12 message([<mode>] "message text" ...)
15 message(<checkState> "message text" ...)
23 message([<mode>] "message text" ...)
25 Record the specified message text in the log. If more than one message
26 string is given, they are concatenated into a single message with no
27 separator between the strings.
29 The optional ``<mode>`` keyword determines the type of message, which
30 influences the way the message is handled:
33 CMake Error, stop processing and generation.
35 The :manual:`cmake(1)` executable will return a non-zero
36 :ref:`exit code <CMake Exit Code>`.
39 CMake Error, continue processing, but skip generation.
42 CMake Warning, continue processing.
45 CMake Warning (dev), continue processing.
48 CMake Deprecation Error or Warning if variable
49 :variable:`CMAKE_ERROR_DEPRECATED` or :variable:`CMAKE_WARN_DEPRECATED`
50 is enabled, respectively, else no message.
53 Important message printed to stderr to attract user's attention.
56 The main interesting messages that project users might be interested in.
57 Ideally these should be concise, no more than a single line, but still
61 Detailed informational messages intended for project users. These messages
62 should provide additional details that won't be of interest in most cases,
63 but which may be useful to those building the project when they want deeper
64 insight into what's happening.
67 Detailed informational messages intended for developers working on the
68 project itself as opposed to users who just want to build it. These messages
69 will not typically be of interest to other users building the project and
70 will often be closely related to internal implementation details.
73 Fine-grained messages with very low-level implementation details. Messages
74 using this log level would normally only be temporary and would expect to be
75 removed before releasing the project, packaging up the files, etc.
77 .. versionadded:: 3.15
78 Added the ``NOTICE``, ``VERBOSE``, ``DEBUG``, and ``TRACE`` levels.
80 The CMake command-line tool displays ``STATUS`` to ``TRACE`` messages on stdout
81 with the message preceded by two hyphens and a space. All other message types
82 are sent to stderr and are not prefixed with hyphens. The
83 :manual:`CMake GUI <cmake-gui(1)>` displays all messages in its log area.
84 The :manual:`curses interface <ccmake(1)>` shows ``STATUS`` to ``TRACE``
85 messages one at a time on a status line and other messages in an
86 interactive pop-up box. The ``--log-level`` command-line option to each of
87 these tools can be used to control which messages will be shown.
89 .. versionadded:: 3.17
90 To make a log level persist between CMake runs, the
91 :variable:`CMAKE_MESSAGE_LOG_LEVEL` variable can be set instead.
92 Note that the command line option takes precedence over the cache variable.
94 .. versionadded:: 3.16
95 Messages of log levels ``NOTICE`` and below will have each line preceded
96 by the content of the :variable:`CMAKE_MESSAGE_INDENT` variable (converted to
97 a single string by concatenating its list items). For ``STATUS`` to ``TRACE``
98 messages, this indenting content will be inserted after the hyphens.
100 .. versionadded:: 3.17
101 Messages of log levels ``NOTICE`` and below can also have each line preceded
102 with context of the form ``[some.context.example]``. The content between the
103 square brackets is obtained by converting the :variable:`CMAKE_MESSAGE_CONTEXT`
104 list variable to a dot-separated string. The message context will always
105 appear before any indenting content but after any automatically added leading
106 hyphens. By default, message context is not shown, it has to be explicitly
107 enabled by giving the :manual:`cmake <cmake(1)>` ``--log-context``
108 command-line option or by setting the :variable:`CMAKE_MESSAGE_CONTEXT_SHOW`
109 variable to true. See the :variable:`CMAKE_MESSAGE_CONTEXT` documentation for
112 CMake Warning and Error message text displays using a simple markup
113 language. Non-indented text is formatted in line-wrapped paragraphs
114 delimited by newlines. Indented text is considered pre-formatted.
120 .. versionadded:: 3.17
122 A common pattern in CMake output is a message indicating the start of some
123 sort of check, followed by another message reporting the result of that check.
126 .. code-block:: cmake
128 message(STATUS "Looking for someheader.h")
129 #... do the checks, set checkSuccess with the result
131 message(STATUS "Looking for someheader.h - found")
133 message(STATUS "Looking for someheader.h - not found")
136 This can be more robustly and conveniently expressed using the ``CHECK_...``
137 keyword form of the ``message()`` command:
139 .. code-block:: cmake
141 message(<checkState> "message" ...)
143 where ``<checkState>`` must be one of the following:
146 Record a concise message about the check about to be performed.
149 Record a successful result for a check.
152 Record an unsuccessful result for a check.
154 When recording a check result, the command repeats the message from the most
155 recently started check for which no result has yet been reported, then some
156 separator characters and then the message text provided after the
157 ``CHECK_PASS`` or ``CHECK_FAIL`` keyword. Check messages are always reported
158 at ``STATUS`` log level.
160 Checks may be nested and every ``CHECK_START`` should have exactly one
161 matching ``CHECK_PASS`` or ``CHECK_FAIL``.
162 The :variable:`CMAKE_MESSAGE_INDENT` variable can also be used to add
163 indenting to nested checks if desired. For example:
165 .. code-block:: cmake
167 message(CHECK_START "Finding my things")
168 list(APPEND CMAKE_MESSAGE_INDENT " ")
169 unset(missingComponents)
171 message(CHECK_START "Finding partA")
172 # ... do check, assume we find A
173 message(CHECK_PASS "found")
175 message(CHECK_START "Finding partB")
176 # ... do check, assume we don't find B
177 list(APPEND missingComponents B)
178 message(CHECK_FAIL "not found")
180 list(POP_BACK CMAKE_MESSAGE_INDENT)
181 if(missingComponents)
182 message(CHECK_FAIL "missing components: ${missingComponents}")
184 message(CHECK_PASS "all components found")
187 Output from the above would appear something like the following::
191 -- Finding partA - found
193 -- Finding partB - not found
194 -- Finding my things - missing components: B