CMAKE_EXPORT_BUILD_DATABASE.rst 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. CMAKE_EXPORT_BUILD_DATABASE
  2. ---------------------------
  3. .. versionadded:: 3.31
  4. .. note ::
  5. This variable is meaningful only when experimental support for build
  6. databases has been enabled by the
  7. ``CMAKE_EXPERIMENTAL_EXPORT_BUILD_DATABASE`` gate.
  8. Enable/Disable output of module compile commands during the build.
  9. If enabled, generates a ``build_database.json`` file containing the
  10. information necessary to compile a target's C++ module sources with any
  11. tooling. The format of the JSON file looks like:
  12. .. code-block:: javascript
  13. {
  14. "version": 1,
  15. "revision": 0,
  16. "sets": [
  17. {
  18. "family-name" : "export_build_database",
  19. "name" : "export_build_database@Debug",
  20. "translation-units" : [
  21. {
  22. "arguments": [
  23. "/path/to/compiler",
  24. "...",
  25. ],
  26. "baseline-arguments" :
  27. [
  28. "...",
  29. ],
  30. "local-arguments" :
  31. [
  32. "...",
  33. ],
  34. "object": "CMakeFiles/target.dir/source.cxx.o",
  35. "private": true,
  36. "provides": {
  37. "importable": "path/to/bmi"
  38. },
  39. "requires" : [],
  40. "source": "path/to/source.cxx",
  41. "work-directory": "/path/to/working/directory"
  42. }
  43. ],
  44. "visible-sets" : []
  45. }
  46. ]
  47. }
  48. This is initialized by the :envvar:`CMAKE_EXPORT_BUILD_DATABASE` environment
  49. variable, and initializes the :prop_tgt:`EXPORT_BUILD_DATABASE` target
  50. property for all targets.
  51. .. note::
  52. This option is implemented only by the :ref:`Ninja Generators`. It is
  53. ignored on other generators.
  54. When supported and enabled, numerous targets are created in order to make it
  55. possible to build a file containing just the commands that are needed for the
  56. tool in question.
  57. ``cmake_build_database-<CONFIG>``
  58. Writes ``build_database_<CONFIG>.json``. Writes a build database for the
  59. entire build for the given configuration and all languages. Not available if
  60. the configuration name is the empty string.
  61. ``cmake_build_database-<LANG>-<CONFIG>``
  62. Writes ``build_database_<LANG>_<CONFIG>.json``. Writes build database for
  63. the entire build for the given configuration and language. Not available if
  64. the configuration name is the empty string.
  65. ``cmake_build_database-<LANG>``
  66. Writes ``build_database_<LANG>.json``. Writes build database for the entire
  67. build for the given language and all configurations. In a multi-config
  68. generator, other build configuration database may be assumed to exist.
  69. ``cmake_build_database``
  70. Writes to ``build_database.json``. Writes build database for all languages
  71. and configurations. In a multi-config generator, other build configuration
  72. database may be assumed to exist.