cmake-configure-log.7.rst 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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. cmakeVariables:
  138. SOME_VARIABLE: "Some Value"
  139. buildResult:
  140. variable: "COMPILE_RESULT"
  141. cached: true
  142. stdout: |
  143. # ...
  144. exitCode: 0
  145. The keys specific to ``try_compile-v1`` mappings are:
  146. ``description``
  147. An optional key that is present when the ``LOG_DESCRIPTION <text>`` option
  148. was used. Its value is a string containing the description ``<text>``.
  149. ``directories``
  150. A mapping describing the directories associated with the
  151. compilation attempt. It has the following keys:
  152. ``source``
  153. String specifying the source directory of the
  154. :command:`try_compile` project.
  155. ``binary``
  156. String specifying the binary directory of the
  157. :command:`try_compile` project.
  158. For non-project invocations, this is often the same as
  159. the source directory.
  160. ``cmakeVariables``
  161. An optional key that is present when CMake propagates variables
  162. into the test project, either automatically or due to the
  163. :variable:`CMAKE_TRY_COMPILE_PLATFORM_VARIABLES` variable.
  164. Its value is a mapping from variable names to their values.
  165. ``buildResult``
  166. A mapping describing the result of compiling the test code.
  167. It has the following keys:
  168. ``variable``
  169. A string specifying the name of the CMake variable
  170. storing the result of trying to build the test project.
  171. ``cached``
  172. A boolean indicating whether the above result ``variable``
  173. is stored in the CMake cache.
  174. ``stdout``
  175. A YAML literal block scalar containing the output from building
  176. the test project, represented using our `Text Block Encoding`_.
  177. This contains build output from both stdout and stderr.
  178. ``exitCode``
  179. An integer specifying the build tool exit code from trying
  180. to build the test project.
  181. .. _`try_run configure-log event`:
  182. Event Kind ``try_run``
  183. ----------------------
  184. The :command:`try_run` command logs ``try_run`` events.
  185. There is only one ``try_run`` event major version, version 1.
  186. .. _`try_run-v1 event`:
  187. ``try_run-v1`` Event
  188. ^^^^^^^^^^^^^^^^^^^^
  189. A ``try_run-v1`` event is a YAML mapping:
  190. .. code-block:: yaml
  191. kind: "try_run-v1"
  192. backtrace:
  193. - "CMakeLists.txt:456 (try_run)"
  194. checks:
  195. - "Checking for something"
  196. description: "Explicit LOG_DESCRIPTION"
  197. directories:
  198. source: "/path/to/.../TryCompile-56789"
  199. binary: "/path/to/.../TryCompile-56789"
  200. buildResult:
  201. variable: "COMPILE_RESULT"
  202. cached: true
  203. stdout: |
  204. # ...
  205. exitCode: 0
  206. runResult:
  207. variable: "RUN_RESULT"
  208. cached: true
  209. stdout: |
  210. # ...
  211. stderr: |
  212. # ...
  213. exitCode: 0
  214. The keys specific to ``try_run-v1`` mappings include those
  215. documented by the `try_compile-v1 event`_, plus:
  216. ``runResult``
  217. A mapping describing the result of running the test code.
  218. It has the following keys:
  219. ``variable``
  220. A string specifying the name of the CMake variable
  221. storing the result of trying to run the test executable.
  222. ``cached``
  223. A boolean indicating whether the above result ``variable``
  224. is stored in the CMake cache.
  225. ``stdout``
  226. An optional key that is present when the test project built successfully.
  227. Its value is a YAML literal block scalar containing output from running
  228. the test executable, represented using our `Text Block Encoding`_.
  229. If ``RUN_OUTPUT_VARIABLE`` was used, stdout and stderr are captured
  230. together, so this will contain both. Otherwise, this will contain
  231. only the stdout output.
  232. ``stderr``
  233. An optional key that is present when the test project built successfully
  234. and the ``RUN_OUTPUT_VARIABLE`` option was not used.
  235. Its value is a YAML literal block scalar containing output from running
  236. the test executable, represented using our `Text Block Encoding`_.
  237. If ``RUN_OUTPUT_VARIABLE`` was used, stdout and stderr are captured
  238. together in the ``stdout`` key, and this key will not be present.
  239. Otherwise, this will contain the stderr output.
  240. ``exitCode``
  241. An optional key that is present when the test project built successfully.
  242. Its value is an integer specifying the exit code, or a string containing
  243. an error message, from trying to run the test executable.