cmake-configure-log.7.rst 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. version:
  29. major: 1
  30. minor: 0
  31. events:
  32. -
  33. kind: "try_compile"
  34. # (other fields omitted)
  35. -
  36. kind: "try_compile"
  37. # (other fields omitted)
  38. ...
  39. A new document is appended to the log every time CMake configures
  40. the build tree and logs new events.
  41. The keys of the each document root mapping are:
  42. ``version``
  43. A YAML mapping that describes the schema version of the log document.
  44. It has keys ``major`` and ``minor`` holding non-negative integer values.
  45. ``events``
  46. A YAML block sequence of nodes corresponding to events logged during
  47. one CMake "configure" step. Each event is a YAML node containing one
  48. of the `Event Kinds`_ documented below.
  49. Text Block Encoding
  50. -------------------
  51. In order to make the log human-readable, text blocks are always
  52. represented using YAML literal block scalars (``|``).
  53. Since literal block scalars do not support escaping, backslashes
  54. and non-printable characters are encoded at the application layer:
  55. * ``\\`` encodes a backslash.
  56. * ``\xXX`` encodes a byte using two hexadecimal digits, ``XX``.
  57. .. _`configure-log event kinds`:
  58. Event Kinds
  59. ===========
  60. Every event kind is represented by a YAML mapping of the form:
  61. .. code-block:: yaml
  62. kind: "<kind>"
  63. backtrace:
  64. - "<file>:<line> (<function>)"
  65. #...event-specific keys...
  66. The keys common to all events are:
  67. ``kind``
  68. A string identifying the event kind.
  69. ``backtrace``
  70. A YAML block sequence reporting the call stack of CMake source
  71. locations at which the event occurred. Each node is a string
  72. specifying one location formatted as ``<file>:<line> (<function>)``.
  73. Additional mapping keys are specific to each event kind,
  74. described below.
  75. .. _`try_compile event`:
  76. Event Kind ``try_compile``
  77. --------------------------
  78. The :command:`try_compile` command logs ``try_compile`` events.
  79. A ``try_compile`` event is a YAML mapping:
  80. .. code-block:: yaml
  81. kind: "try_compile"
  82. backtrace:
  83. - "CMakeLists.txt:123 (try_compile)"
  84. directories:
  85. source: "/path/to/.../TryCompile-01234"
  86. binary: "/path/to/.../TryCompile-01234"
  87. buildResult:
  88. variable: "COMPILE_RESULT"
  89. cached: true
  90. stdout: |
  91. # ...
  92. exitCode: 0
  93. The keys specific to ``try_compile`` mappings are:
  94. ``directories``
  95. A mapping describing the directories associated with the
  96. compilation attempt. It has the following keys:
  97. ``source``
  98. String specifying the source directory of the
  99. :command:`try_compile` project.
  100. ``binary``
  101. String specifying the binary directory of the
  102. :command:`try_compile` project.
  103. For non-project invocations, this is often the same as
  104. the source directory.
  105. ``buildResult``
  106. A mapping describing the result of compiling the test code.
  107. It has the following keys:
  108. ``variable``
  109. A string specifying the name of the CMake variable
  110. storing the result of trying to build the test project.
  111. ``cached``
  112. A boolean indicating whether the above result ``variable``
  113. is stored in the CMake cache.
  114. ``stdout``
  115. A YAML literal block scalar containing the output from building
  116. the test project, represented using our `Text Block Encoding`_.
  117. This contains build output from both stdout and stderr.
  118. ``exitCode``
  119. An integer specifying the build tool exit code from trying
  120. to build the test project.
  121. Event Kind ``try_run``
  122. ----------------------
  123. The :command:`try_run` command logs ``try_run`` events.
  124. A ``try_run`` event is a YAML mapping:
  125. .. code-block:: yaml
  126. kind: "try_run"
  127. backtrace:
  128. - "CMakeLists.txt:456 (try_run)"
  129. directories:
  130. source: "/path/to/.../TryCompile-56789"
  131. binary: "/path/to/.../TryCompile-56789"
  132. buildResult:
  133. variable: "COMPILE_RESULT"
  134. cached: true
  135. stdout: |
  136. # ...
  137. exitCode: 0
  138. runResult:
  139. variable: "RUN_RESULT"
  140. cached: true
  141. stdout: |
  142. # ...
  143. stderr: |
  144. # ...
  145. exitCode: 0
  146. The keys specific to ``try_run`` mappings include those
  147. documented by the `try_compile event`_, plus:
  148. ``runResult``
  149. A mapping describing the result of running the test code.
  150. It has the following keys:
  151. ``variable``
  152. A string specifying the name of the CMake variable
  153. storing the result of trying to run the test executable.
  154. ``cached``
  155. A boolean indicating whether the above result ``variable``
  156. is stored in the CMake cache.
  157. ``stdout``
  158. An optional key that is present when the test project built successfully.
  159. Its value is a YAML literal block scalar containing output from running
  160. the test executable, represented using our `Text Block Encoding`_.
  161. If ``RUN_OUTPUT_VARIABLE`` was used, stdout and stderr are captured
  162. together, so this will contain both. Otherwise, this will contain
  163. only the stdout output.
  164. ``stderr``
  165. An optional key that is present when the test project built successfully
  166. and the ``RUN_OUTPUT_VARIABLE`` option was not used.
  167. Its value is a YAML literal block scalar containing output from running
  168. the test executable, represented using our `Text Block Encoding`_.
  169. If ``RUN_OUTPUT_VARIABLE`` was used, stdout and stderr are captured
  170. together in the ``stdout`` key, and this key will not be present.
  171. Otherwise, this will contain the stderr output.
  172. ``exitCode``
  173. An optional key that is present when the test project built successfully.
  174. Its value is an integer specifying the exit code, or a string containing
  175. an error message, from trying to run the test executable.