1CMAKE_EXPORT_COMPILE_COMMANDS 2----------------------------- 3 4.. versionadded:: 3.5 5 6Enable/Disable output of compile commands during generation. 7 8If enabled, generates a ``compile_commands.json`` file containing the exact 9compiler calls for all translation units of the project in machine-readable 10form. 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 30This is initialized by the :envvar:`CMAKE_EXPORT_COMPILE_COMMANDS` environment 31variable, and initializes the :prop_tgt:`EXPORT_COMPILE_COMMANDS` target 32property 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. 41