# Generate Build Database is Empty

**URL:** https://discourse.cmake.org/t/generate-build-database-is-empty/15654
**Category:** Usage
**Created:** [May 17, 2026, 12:47am UTC](https://discourse.cmake.org/t/generate-build-database-is-empty/15654 "2026-05-17T00:47:30Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![mwasplund](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mwasplund/32/6132_2.png) [@mwasplund](https://discourse.cmake.org/u/mwasplund)
#### Post date: [May 17, 2026, 12:47am UTC](https://discourse.cmake.org/t/generate-build-database-is-empty/15654/1 "2026-05-17T00:47:31Z")

</div>

I am attempting to experiment with the experimental CMAKE\_EXPORT\_BUILD\_DATABASE flag. I think I got it up and running to the point where the cmake\_build\_database target is generating a build\_database.json. However the sets list is empty. Is there something I am missing to make sure this database includes all of my targets?

Repro:

> **[scratch/build-database at main · mwasplund/scratch](https://github.com/mwasplund/scratch/tree/main/build-database)**
>
> Public Scratchpad to share examples. Contribute to mwasplund/scratch development by creating an account on GitHub.

Dowload cmake 4.3.2

Install clang-22

```auto
mkdir build
cd build
cmake .. -G Ninja
cd ..
cmake --build build --target cmake_build_database app

```

---

<div class="post-metadata">

### Author: ![mwasplund](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mwasplund/32/6132_2.png) [@mwasplund](https://discourse.cmake.org/u/mwasplund)
#### Post date: [May 17, 2026, 12:48am UTC](https://discourse.cmake.org/t/generate-build-database-is-empty/15654/2 "2026-05-17T00:48:57Z")

</div>

@ben.boeckel

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [May 22, 2026, 5:05pm UTC](https://discourse.cmake.org/t/generate-build-database-is-empty/15654/3 "2026-05-22T17:05:47Z")

</div>

Hmm. The per-target databases are fine. The `_CXX` database’s `merge command has no inputs though. Something is getting lost in translation here…

Thanks for the report!

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [May 22, 2026, 5:12pm UTC](https://discourse.cmake.org/t/generate-build-database-is-empty/15654/4 "2026-05-22T17:12:22Z")

</div>

If you set a non-empty `CMAKE_BUILD_TYPE`, it shows up. I’ll look at what the problem is with empty configs…

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [May 22, 2026, 5:53pm UTC](https://discourse.cmake.org/t/generate-build-database-is-empty/15654/5 "2026-05-22T17:53:30Z")

</div>

MR filed: [https://gitlab.kitware.com/cmake/cmake/-/merge\_requests/12101](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/12101)

---

<div class="post-metadata">

### Author: ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)
#### Post date: [May 23, 2026, 7:10am UTC](https://discourse.cmake.org/t/generate-build-database-is-empty/15654/6 "2026-05-23T07:10:03Z")

</div>

Hi,

as a side question as it’s not clear for me from the documentation or naming:

What’s the difference between a compilation database and a build database?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [May 25, 2026, 3:13am UTC](https://discourse.cmake.org/t/generate-build-database-is-empty/15654/7 "2026-05-25T03:13:06Z")

</div>

A compilation database is “just” a list of JSON objects with:

- output path (optional)
- source path
- working directory
- command

There’s no high-level structure here. If a source path is compiled multiple times, what does one do? It could be in multiple targets or the build could be multi-config and have one rule per configuration.

When completing an `import`, one needs to know the _target-level_ dependency to know what modules are eligible for completion. While there might exist a module `M`, offering to import it in a file which lives in a library that the `M` provider links to is invalid. The build database provides enough context to provide such assistance.

See my talk (which I need to pull back into the docs): [https://www.youtube.com/watch?v=GUqs\_CM7K\_0](https://www.youtube.com/watch?v=GUqs_CM7K_0)

---

<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: [May 25, 2026, 9:13pm UTC](https://discourse.cmake.org/t/generate-build-database-is-empty/15654/8 "2026-05-25T21:13:14Z")

</div>

@ben.boeckel It would probably also help to contrast what the build database provides that is not already provided by the CMake file API. Right now, it seems like it is duplicating the same details, just in a different format (i.e. a single file).

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [May 26, 2026, 1:50pm UTC](https://discourse.cmake.org/t/generate-build-database-is-empty/15654/9 "2026-05-26T13:50:31Z")

</div>

One could probably get a build database from a file-api query. The main difference is that it is a CMake-agnostic file format. I really need to improve the docs based on my talk so I can stop pointing at it as the best source of information 🙂 .
