# compile\_commands.json is not created when no commands exist

**URL:** https://discourse.cmake.org/t/compile-commands-json-is-not-created-when-no-commands-exist/1317
**Category:** Development
**Created:** [June 3, 2020, 5:54pm UTC](https://discourse.cmake.org/t/compile-commands-json-is-not-created-when-no-commands-exist/1317 "2020-06-03T17:54:27Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![hex](https://discourse.cmake.org/user_avatar/discourse.cmake.org/hex/32/363_2.png) [@hex](https://discourse.cmake.org/u/hex)
#### Post date: [June 3, 2020, 5:54pm UTC](https://discourse.cmake.org/t/compile-commands-json-is-not-created-when-no-commands-exist/1317/1 "2020-06-03T17:54:27Z")

</div>

currently, CMake does not create the file `compile_commands.json` if the project has no compile commands:

```cmake
cmake_minimum_required( VERSION 3.17.0 )
project(ExportCompileCommands)
# workaround for CMake 3.17.0
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")

```

as a first time user of this feature I did not expect this.

If `CMAKE_EXPORT_COMPILE_COMMANDS` is enabled and no commands exist I suggest that `compile_commands.json` should still be generated. For both human and machine processing the expected file content should be

```auto
[
]

```

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [June 4, 2020, 11:33pm UTC](https://discourse.cmake.org/t/compile-commands-json-is-not-created-when-no-commands-exist/1317/2 "2020-06-04T23:33:24Z")

</div>

Yes, that should be fixed. See [CMake Issue 19758](https://gitlab.kitware.com/cmake/cmake/-/issues/19758).
