cmake-configure-log.7.rst 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. .. cmake-manual-description: CMake Configure Log
  2. cmake-configure-log(7)
  3. **********************
  4. .. versionadded:: 3.26
  5. .. only:: html
  6. .. contents::
  7. Introduction
  8. ============
  9. CMake writes a running log, known as the configure log,
  10. of certain events that occur during the "configure" step.
  11. The log file is located at::
  12. ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeConfigureLog.yaml
  13. The configure log does *not* contain a log of all output, errors,
  14. or messages printed while configuring a project. It is a log of
  15. detailed information about specific events, such as toolchain inspection
  16. by :command:`try_compile`, meant for use in debugging the configuration
  17. of a build tree.
  18. Log Structure
  19. =============
  20. The configure log is designed to be both machine- and human-readable.
  21. The log file is a YAML document stream containing zero or more YAML
  22. documents separated by document markers. Each document begins
  23. with a ``---`` document marker line, contains a single YAML mapping
  24. that logs events from one CMake "configure" step, and, if the configure
  25. step finished normally, ends with a ``...`` document marker line:
  26. .. code-block:: yaml
  27. ---
  28. events:
  29. -
  30. kind: "try_compile-v1"
  31. # (other fields omitted)
  32. -
  33. kind: "try_compile-v1"
  34. # (other fields omitted)
  35. ...
  36. A new document is appended to the log every time CMake configures
  37. the build tree and logs new events.
  38. The keys of the each document root mapping are:
  39. ``events``
  40. A YAML block sequence of nodes corresponding to events logged during
  41. one CMake "configure" step. Each event is a YAML node containing one
  42. of the `Event Kinds`_ documented below.
  43. Log Versioning
  44. --------------
  45. Each of the `Event Kinds`_ is versioned independently. The set of
  46. keys an event's log entry provides is specific to its major version.
  47. When an event is logged, the latest version of its event kind that is
  48. known to the running version of CMake is always written to the log.
  49. Tools reading the configure log must ignore event kinds and versions
  50. they do not understand:
  51. * A future version of CMake may introduce a new event kind or version.
  52. * If an existing build tree is re-configured with a different version of
  53. CMake, the log may contain different versions of the same event kind.
  54. * If :manual:`cmake-file-api(7)` queries request one or more
  55. :ref:`configureLog <file-api configureLog>` object versions,
  56. the log may contain multiple entries for the same event, each
  57. with a different version of its event kind.
  58. IDEs should write a :manual:`cmake-file-api(7)` query requesting a
  59. specific :ref:`configureLog <file-api configureLog>` object version,
  60. before running CMake, and then read the configure log only as described
  61. by the file-api reply.
  62. Text Block Encoding
  63. -------------------
  64. In order to make the log human-readable, text blocks are always
  65. represented using YAML literal block scalars (``|``).
  66. Since literal block scalars do not support escaping, backslashes
  67. and non-printable characters are encoded at the application layer:
  68. * ``\\`` encodes a backslash.
  69. * ``\xXX`` encodes a byte using two hexadecimal digits, ``XX``.
  70. .. _`configure-log event kinds`:
  71. Event Kinds
  72. ===========
  73. Every event kind is represented by a YAML mapping of the form:
  74. .. code-block:: yaml
  75. kind: "<kind>-v<major>"
  76. backtrace:
  77. - "<file>:<line> (<function>)"
  78. checks:
  79. - "Checking for something"
  80. #...event-specific keys...
  81. The keys common to all events are:
  82. ``kind``
  83. A string identifying the event kind and major version.
  84. ``backtrace``
  85. A YAML block sequence reporting the call stack of CMake source
  86. locations at which the event occurred, from most-recent to
  87. least-recent. Each node is a string specifying one location
  88. formatted as ``<file>:<line> (<function>)``.
  89. ``checks``
  90. An optional key that is present when the event occurred with
  91. at least one pending :command:`message(CHECK_START)`. Its value
  92. is a YAML block sequence reporting the stack of pending checks,
  93. from most-recent to least-recent. Each node is a string containing
  94. a pending check message.
  95. Additional mapping keys are specific to each (versioned) event kind,
  96. described below.
  97. .. _`message configure-log event`:
  98. Event Kind ``message``
  99. ----------------------
  100. The :command:`message(CONFIGURE_LOG)` command logs ``message`` events.
  101. There is only one ``message`` event major version, version 1.
  102. .. _`message-v1 event`:
  103. ``message-v1`` Event
  104. ^^^^^^^^^^^^^^^^^^^^
  105. A ``message-v1`` event is a YAML mapping:
  106. .. code-block:: yaml
  107. kind: "message-v1"
  108. backtrace:
  109. - "CMakeLists.txt:123 (message)"
  110. checks:
  111. - "Checking for something"
  112. message: |
  113. # ...
  114. The keys specific to ``message-v1`` mappings are:
  115. ``message``
  116. A YAML literal block scalar containing the message text,
  117. represented using our `Text Block Encoding`_.
  118. .. _`try_compile configure-log event`:
  119. Event Kind ``try_compile``
  120. --------------------------
  121. The :command:`try_compile` command logs ``try_compile`` events.
  122. There is only one ``try_compile`` event major version, version 1.
  123. .. _`try_compile-v1 event`:
  124. ``try_compile-v1`` Event
  125. ^^^^^^^^^^^^^^^^^^^^^^^^
  126. A ``try_compile-v1`` event is a YAML mapping:
  127. .. code-block:: yaml
  128. kind: "try_compile-v1"
  129. backtrace:
  130. - "CMakeLists.txt:123 (try_compile)"
  131. checks:
  132. - "Checking for something"
  133. description: "Explicit LOG_DESCRIPTION"
  134. directories:
  135. source: "/path/to/.../TryCompile-01234"
  136. binary: "/path/to/.../TryCompile-01234"
  137. buildResult:
  138. variable: "COMPILE_RESULT"
  139. cached: true
  140. stdout: |
  141. # ...
  142. exitCode: 0
  143. The keys specific to ``try_compile-v1`` mappings are:
  144. ``description``
  145. An optional key that is present when the ``LOG_DESCRIPTION <text>`` option
  146. was used. Its value is a string containing the description ``<text>``.
  147. ``directories``
  148. A mapping describing the directories associated with the
  149. compilation attempt. It has the following keys:
  150. ``source``
  151. String specifying the source directory of the
  152. :command:`try_compile` project.
  153. ``binary``
  154. String specifying the binary directory of the
  155. :command:`try_compile` project.
  156. For non-project invocations, this is often the same as
  157. the source directory.
  158. ``buildResult``
  159. A mapping describing the result of compiling the test code.
  160. It has the following keys:
  161. ``variable``
  162. A string specifying the name of the CMake variable
  163. storing the result of trying to build the test project.
  164. ``cached``
  165. A boolean indicating whether the above result ``variable``
  166. is stored in the CMake cache.
  167. ``stdout``
  168. A YAML literal block scalar containing the output from building
  169. the test project, represented using our `Text Block Encoding`_.
  170. This contains build output from both stdout and stderr.
  171. ``exitCode``
  172. An integer specifying the build tool exit code from trying
  173. to build the test project.
  174. .. _`try_run configure-log event`:
  175. Event Kind ``try_run``
  176. ----------------------
  177. The :command:`try_run` command logs ``try_run`` events.
  178. There is only one ``try_run`` event major version, version 1.
  179. .. _`try_run-v1 event`:
  180. ``try_run-v1`` Event
  181. ^^^^^^^^^^^^^^^^^^^^
  182. A ``try_run-v1`` event is a YAML mapping:
  183. .. code-block:: yaml
  184. kind: "try_run-v1"
  185. backtrace:
  186. - "CMakeLists.txt:456 (try_run)"
  187. checks:
  188. - "Checking for something"
  189. description: "Explicit LOG_DESCRIPTION"
  190. directories:
  191. source: "/path/to/.../TryCompile-56789"
  192. binary: "/path/to/.../TryCompile-56789"
  193. buildResult:
  194. variable: "COMPILE_RESULT"
  195. cached: true
  196. stdout: |
  197. # ...
  198. exitCode: 0
  199. runResult:
  200. variable: "RUN_RESULT"
  201. cached: true
  202. stdout: |
  203. # ...
  204. stderr: |
  205. # ...
  206. exitCode: 0
  207. The keys specific to ``try_run-v1`` mappings include those
  208. documented by the `try_compile-v1 event`_, plus:
  209. ``runResult``
  210. A mapping describing the result of running the test code.
  211. It has the following keys:
  212. ``variable``
  213. A string specifying the name of the CMake variable
  214. storing the result of trying to run the test executable.
  215. ``cached``
  216. A boolean indicating whether the above result ``variable``
  217. is stored in the CMake cache.
  218. ``stdout``
  219. An optional key that is present when the test project built successfully.
  220. Its value is a YAML literal block scalar containing output from running
  221. the test executable, represented using our `Text Block Encoding`_.
  222. If ``RUN_OUTPUT_VARIABLE`` was used, stdout and stderr are captured
  223. together, so this will contain both. Otherwise, this will contain
  224. only the stdout output.
  225. ``stderr``
  226. An optional key that is present when the test project built successfully
  227. and the ``RUN_OUTPUT_VARIABLE`` option was not used.
  228. Its value is a YAML literal block scalar containing output from running
  229. the test executable, represented using our `Text Block Encoding`_.
  230. If ``RUN_OUTPUT_VARIABLE`` was used, stdout and stderr are captured
  231. together in the ``stdout`` key, and this key will not be present.
  232. Otherwise, this will contain the stderr output.
  233. ``exitCode``
  234. An optional key that is present when the test project built successfully.
  235. Its value is an integer specifying the exit code, or a string containing
  236. an error message, from trying to run the test executable.