# create compile commands for each file when unity build

**URL:** https://discourse.cmake.org/t/create-compile-commands-for-each-file-when-unity-build/10182
**Category:** Development
**Created:** [February 25, 2024, 9:35am UTC](https://discourse.cmake.org/t/create-compile-commands-for-each-file-when-unity-build/10182 "2024-02-25T09:35:34Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![leiyuhou010](https://discourse.cmake.org/user_avatar/discourse.cmake.org/leiyuhou010/32/4342_2.png) [@leiyuhou010](https://discourse.cmake.org/u/leiyuhou010)
#### Post date: [February 25, 2024, 9:35am UTC](https://discourse.cmake.org/t/create-compile-commands-for-each-file-when-unity-build/10182/1 "2024-02-25T09:35:34Z")

</div>

When a target is build with unity build, only generated unity\_n\_cxx.cxx file’s compile command are exported in the compile\_commands.json , but the raw source files are ignored . actually many c/c++ language server need the original source file’s compile commands information, and the programmer also need them when work in IDE, so , I think it’s necessary to generate all source files compile commands in the result json file.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [February 25, 2024, 9:42pm UTC](https://discourse.cmake.org/t/create-compile-commands-for-each-file-when-unity-build/10182/2 "2024-02-25T21:42:53Z")

</div>

See [issue 19826](https://gitlab.kitware.com/cmake/cmake/-/issues/19826) which discusses this limitation.
