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