cmake-configure-log.7.rst 9.7 KB

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