CMAKE_EXPORT_COMPILE_COMMANDS.rst 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. CMAKE_EXPORT_COMPILE_COMMANDS
  2. -----------------------------
  3. .. versionadded:: 3.5
  4. Enable/Disable output of compile commands during generation.
  5. If enabled, generates a ``compile_commands.json`` file containing the exact
  6. compiler calls for all translation units of the project in machine-readable
  7. form. The format of the JSON file looks like:
  8. .. code-block:: javascript
  9. [
  10. {
  11. "directory": "/home/user/development/project",
  12. "command": "/usr/bin/c++ ... -c ../foo/foo.cc",
  13. "file": "../foo/foo.cc"
  14. },
  15. ...
  16. {
  17. "directory": "/home/user/development/project",
  18. "command": "/usr/bin/c++ ... -c ../foo/bar.cc",
  19. "file": "../foo/bar.cc"
  20. }
  21. ]
  22. This is initialized by the :envvar:`CMAKE_EXPORT_COMPILE_COMMANDS` environment
  23. variable, and initializes the :prop_tgt:`EXPORT_COMPILE_COMMANDS` target
  24. property for all targets.
  25. .. note::
  26. This option is implemented only by :ref:`Makefile Generators`
  27. and :ref:`Ninja Generators`. It is ignored on other generators.
  28. This option currently does not work well in combination with
  29. the :prop_tgt:`UNITY_BUILD` target property or the
  30. :variable:`CMAKE_UNITY_BUILD` variable.