cmake-configure-log.7.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  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. .. code-block:: cmake
  18. ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeConfigureLog.yaml
  19. However, the *location and name of the log file may change* in future
  20. versions of CMake. Tools that read the configure log should get its
  21. location using a :ref:`configureLog <file-api configureLog>` query to
  22. the :manual:`cmake-file-api(7)`.
  23. See the `Log Versioning`_ section below for details.
  24. Log Structure
  25. =============
  26. The configure log is designed to be both machine- and human-readable.
  27. The log file is a YAML document stream containing zero or more YAML
  28. documents separated by document markers. Each document begins
  29. with a ``---`` document marker line, contains a single YAML mapping
  30. that logs events from one CMake "configure" step, and, if the configure
  31. step finished normally, ends with a ``...`` document marker line:
  32. .. code-block:: yaml
  33. ---
  34. events:
  35. -
  36. kind: "try_compile-v1"
  37. # (other fields omitted)
  38. -
  39. kind: "try_compile-v1"
  40. # (other fields omitted)
  41. ...
  42. A new document is appended to the log every time CMake configures
  43. the build tree and logs new events.
  44. The keys of each document root mapping are:
  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. Log Versioning
  50. --------------
  51. Each of the `Event Kinds`_ is versioned independently. The set of
  52. keys an event's log entry provides is specific to its major version.
  53. When an event is logged, the latest version of its event kind that is
  54. known to the running version of CMake is always written to the log.
  55. Tools reading the configure log must ignore event kinds and versions
  56. they do not understand:
  57. * A future version of CMake may introduce a new event kind or version.
  58. * If an existing build tree is re-configured with a different version of
  59. CMake, the log may contain different versions of the same event kind.
  60. * If :manual:`cmake-file-api(7)` queries request one or more
  61. :ref:`configureLog <file-api configureLog>` object versions,
  62. the log may contain multiple entries for the same event, each
  63. with a different version of its event kind.
  64. IDEs should write a :manual:`cmake-file-api(7)` query requesting a
  65. specific :ref:`configureLog <file-api configureLog>` object version,
  66. before running CMake, and then read the configure log only as described
  67. by the file-api reply.
  68. Text Block Encoding
  69. -------------------
  70. In order to make the log human-readable, text blocks are always
  71. represented using YAML literal block scalars (``|``).
  72. Since literal block scalars do not support escaping, backslashes
  73. and non-printable characters are encoded at the application layer:
  74. * ``\\`` encodes a backslash.
  75. * ``\xXX`` encodes a byte using two hexadecimal digits, ``XX``.
  76. .. _`configure-log event kinds`:
  77. Event Kinds
  78. ===========
  79. Every event kind is represented by a YAML mapping of the form:
  80. .. code-block:: yaml
  81. kind: "<kind>-v<major>"
  82. backtrace:
  83. - "<file>:<line> (<function>)"
  84. checks:
  85. - "Checking for something"
  86. #...event-specific keys...
  87. The keys common to all events are:
  88. ``kind``
  89. A string identifying the event kind and major version.
  90. ``backtrace``
  91. A YAML block sequence reporting the call stack of CMake source
  92. locations at which the event occurred, from most-recent to
  93. least-recent. Each node is a string specifying one location
  94. formatted as ``<file>:<line> (<function>)``.
  95. ``checks``
  96. An optional key that is present when the event occurred with
  97. at least one pending :command:`message(CHECK_START)`. Its value
  98. is a YAML block sequence reporting the stack of pending checks,
  99. from most-recent to least-recent. Each node is a string containing
  100. a pending check message.
  101. Additional mapping keys are specific to each (versioned) event kind,
  102. described below.
  103. .. _`message configure-log event`:
  104. Event Kind ``message``
  105. ----------------------
  106. The :command:`message(CONFIGURE_LOG)` command logs ``message`` events.
  107. There is only one ``message`` event major version, version 1.
  108. .. _`message-v1 event`:
  109. ``message-v1`` Event
  110. ^^^^^^^^^^^^^^^^^^^^
  111. A ``message-v1`` event is a YAML mapping:
  112. .. code-block:: yaml
  113. kind: "message-v1"
  114. backtrace:
  115. - "CMakeLists.txt:123 (message)"
  116. checks:
  117. - "Checking for something"
  118. message: |
  119. # ...
  120. The keys specific to ``message-v1`` mappings are:
  121. ``message``
  122. A YAML literal block scalar containing the message text,
  123. represented using our `Text Block Encoding`_.
  124. .. _`try_compile configure-log event`:
  125. Event Kind ``try_compile``
  126. --------------------------
  127. The :command:`try_compile` command logs ``try_compile`` events.
  128. There is only one ``try_compile`` event major version, version 1.
  129. .. _`try_compile-v1 event`:
  130. ``try_compile-v1`` Event
  131. ^^^^^^^^^^^^^^^^^^^^^^^^
  132. A ``try_compile-v1`` event is a YAML mapping:
  133. .. code-block:: yaml
  134. kind: "try_compile-v1"
  135. backtrace:
  136. - "CMakeLists.txt:123 (try_compile)"
  137. checks:
  138. - "Checking for something"
  139. description: "Explicit LOG_DESCRIPTION"
  140. directories:
  141. source: "/path/to/.../TryCompile-01234"
  142. binary: "/path/to/.../TryCompile-01234"
  143. cmakeVariables:
  144. SOME_VARIABLE: "Some Value"
  145. buildResult:
  146. variable: "COMPILE_RESULT"
  147. cached: true
  148. stdout: |
  149. # ...
  150. exitCode: 0
  151. The keys specific to ``try_compile-v1`` mappings are:
  152. ``description``
  153. An optional key that is present when the ``LOG_DESCRIPTION <text>`` option
  154. was used. Its value is a string containing the description ``<text>``.
  155. ``directories``
  156. A mapping describing the directories associated with the
  157. compilation attempt. It has the following keys:
  158. ``source``
  159. String specifying the source directory of the
  160. :command:`try_compile` project.
  161. ``binary``
  162. String specifying the binary directory of the
  163. :command:`try_compile` project.
  164. For non-project invocations, this is often the same as
  165. the source directory.
  166. ``cmakeVariables``
  167. An optional key that is present when CMake propagates variables
  168. into the test project, either automatically or due to the
  169. :variable:`CMAKE_TRY_COMPILE_PLATFORM_VARIABLES` variable.
  170. Its value is a mapping from variable names to their values.
  171. ``buildResult``
  172. A mapping describing the result of compiling the test code.
  173. It has the following keys:
  174. ``variable``
  175. A string specifying the name of the CMake variable
  176. storing the result of trying to build the test project.
  177. ``cached``
  178. A boolean indicating whether the above result ``variable``
  179. is stored in the CMake cache.
  180. ``stdout``
  181. A YAML literal block scalar containing the output from building
  182. the test project, represented using our `Text Block Encoding`_.
  183. This contains build output from both stdout and stderr.
  184. ``exitCode``
  185. An integer specifying the build tool exit code from trying
  186. to build the test project.
  187. .. _`try_run configure-log event`:
  188. Event Kind ``try_run``
  189. ----------------------
  190. The :command:`try_run` command logs ``try_run`` events.
  191. There is only one ``try_run`` event major version, version 1.
  192. .. _`try_run-v1 event`:
  193. ``try_run-v1`` Event
  194. ^^^^^^^^^^^^^^^^^^^^
  195. A ``try_run-v1`` event is a YAML mapping:
  196. .. code-block:: yaml
  197. kind: "try_run-v1"
  198. backtrace:
  199. - "CMakeLists.txt:456 (try_run)"
  200. checks:
  201. - "Checking for something"
  202. description: "Explicit LOG_DESCRIPTION"
  203. directories:
  204. source: "/path/to/.../TryCompile-56789"
  205. binary: "/path/to/.../TryCompile-56789"
  206. buildResult:
  207. variable: "COMPILE_RESULT"
  208. cached: true
  209. stdout: |
  210. # ...
  211. exitCode: 0
  212. runResult:
  213. variable: "RUN_RESULT"
  214. cached: true
  215. stdout: |
  216. # ...
  217. stderr: |
  218. # ...
  219. exitCode: 0
  220. The keys specific to ``try_run-v1`` mappings include those
  221. documented by the `try_compile-v1 event`_, plus:
  222. ``runResult``
  223. A mapping describing the result of running the test code.
  224. It has the following keys:
  225. ``variable``
  226. A string specifying the name of the CMake variable
  227. storing the result of trying to run the test executable.
  228. ``cached``
  229. A boolean indicating whether the above result ``variable``
  230. is stored in the CMake cache.
  231. ``stdout``
  232. An optional key that is present when the test project built successfully.
  233. Its value is a YAML literal block scalar containing output from running
  234. the test executable, represented using our `Text Block Encoding`_.
  235. If ``RUN_OUTPUT_VARIABLE`` was used, stdout and stderr are captured
  236. together, so this will contain both. Otherwise, this will contain
  237. only the stdout output.
  238. ``stderr``
  239. An optional key that is present when the test project built successfully
  240. and the ``RUN_OUTPUT_VARIABLE`` option was not used.
  241. Its value is a YAML literal block scalar containing output from running
  242. the test executable, represented using our `Text Block Encoding`_.
  243. If ``RUN_OUTPUT_VARIABLE`` was used, stdout and stderr are captured
  244. together in the ``stdout`` key, and this key will not be present.
  245. Otherwise, this will contain the stderr output.
  246. ``exitCode``
  247. An optional key that is present when the test project built successfully.
  248. Its value is an integer specifying the exit code, or a string containing
  249. an error message, from trying to run the test executable.
  250. .. _`find configure-log event`:
  251. Event Kind ``find``
  252. -------------------
  253. The :command:`find_file`, :command:`find_path`, :command:`find_library`, and
  254. :command:`find_program` commands log ``find`` events.
  255. There is only one ``find`` event major version, version 1.
  256. .. _`find-v1 event`:
  257. ``find-v1`` Event
  258. ^^^^^^^^^^^^^^^^^
  259. .. versionadded:: 4.1
  260. A ``find-v1`` event is a YAML mapping:
  261. .. code-block:: yaml
  262. kind: "find-v1"
  263. backtrace:
  264. - "CMakeLists.txt:456 (find_program)"
  265. mode: "program"
  266. variable: "PROGRAM_PATH"
  267. description: "Docstring for variable"
  268. settings:
  269. SearchFramework: "NEVER"
  270. SearchAppBundle: "NEVER"
  271. CMAKE_FIND_USE_CMAKE_PATH: true
  272. CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: true
  273. CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: true
  274. CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: true
  275. CMAKE_FIND_USE_INSTALL_PREFIX: true
  276. names:
  277. - "name1"
  278. - "name2"
  279. candidate_directories:
  280. - "/path/to/search"
  281. - "/other/path/to/search"
  282. - "/path/to/found"
  283. - "/further/path/to/search"
  284. searched_directories:
  285. - "/path/to/search"
  286. - "/other/path/to/search"
  287. found: "/path/to/found/program"
  288. The keys specific to ``find-v1`` mappings are:
  289. ``mode``
  290. A string describing the command using the search performed. One of ``file``,
  291. ``path``, ``program``, or ``library``.
  292. ``variable``
  293. The variable to which the search stored its result.
  294. ``description``
  295. The documentation string of the variable.
  296. ``settings``
  297. Search settings active for the search.
  298. ``SearchFramework``
  299. A string describing how framework search is performed. One of ``FIRST``,
  300. ``LAST``, ``ONLY``, or ``NEVER``. See :variable:`CMAKE_FIND_FRAMEWORK`.
  301. ``SearchAppBundle``
  302. A string describing how application bundle search is performed. One of
  303. ``FIRST``, ``LAST``, ``ONLY``, or ``NEVER``. See
  304. :variable:`CMAKE_FIND_APPBUNDLE`.
  305. ``CMAKE_FIND_USE_CMAKE_PATH``
  306. A boolean indicating whether or not CMake-specific cache variables are
  307. used when searching. See :variable:`CMAKE_FIND_USE_CMAKE_PATH`.
  308. ``CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH``
  309. A boolean indicating whether or not CMake-specific environment variables
  310. are used when searching. See
  311. :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`.
  312. ``CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH``
  313. A boolean indicating whether or not platform-specific environment
  314. variables are used when searching. See
  315. :variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH`.
  316. ``CMAKE_FIND_USE_CMAKE_SYSTEM_PATH``
  317. A boolean indicating whether or not platform-specific CMake variables are
  318. used when searching. See :variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`.
  319. ``CMAKE_FIND_USE_INSTALL_PREFIX``
  320. A boolean indicating whether or not the install prefix is used when
  321. searching. See :variable:`CMAKE_FIND_USE_INSTALL_PREFIX`.
  322. ``names``
  323. The names to look for the queries.
  324. ``candidate_directories``
  325. Candidate directories, in order, to look in during the search.
  326. ``searched_directories``
  327. Directories, in order, looked at during the search process.
  328. ``found``
  329. Either a string representing the found value or ``false`` if it was not
  330. found.