# COMPILE\_ONLY generator doesn't seem to create a dependency, should it?

**URL:** https://discourse.cmake.org/t/compile-only-generator-doesnt-seem-to-create-a-dependency-should-it/14445
**Category:** Development
**Created:** [July 25, 2025, 9:50pm UTC](https://discourse.cmake.org/t/compile-only-generator-doesnt-seem-to-create-a-dependency-should-it/14445 "2025-07-25T21:50:22Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Aaron\_Cohen](https://discourse.cmake.org/user_avatar/discourse.cmake.org/aaron_cohen/32/4831_2.png) [@Aaron\_Cohen](https://discourse.cmake.org/u/Aaron_Cohen)
#### Post date: [July 25, 2025, 9:50pm UTC](https://discourse.cmake.org/t/compile-only-generator-doesnt-seem-to-create-a-dependency-should-it/14445/1 "2025-07-25T21:50:23Z")

</div>

We have a target that generates header files using a custom\_target/custom\_command pair in the “build/generated” directory, and then exports that directory with target\_include\_directories.

We recently switched one consumer of that target to use the COMPILE\_ONLY generator when linking.

This creates an intermittent ordering issue in our build as the first target is no longer required to finish generating the header file before the consumer is built.

Is that expected?

---

<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: [July 26, 2025, 2:26am UTC](https://discourse.cmake.org/t/compile-only-generator-doesnt-seem-to-create-a-dependency-should-it/14445/2 "2025-07-26T02:26:25Z")

</div>

No; I think a dependency should be present exactly because of generated headers (generated `INTERFACE` source files as well…). @robert.maynard I assume this is an oversight? We “just” need to add a direct dependency AFAIK.

---

<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: [July 26, 2025, 2:27am UTC](https://discourse.cmake.org/t/compile-only-generator-doesnt-seem-to-create-a-dependency-should-it/14445/3 "2025-07-26T02:27:56Z")

</div>

Note that `Ninja` generators should be able to avoid depending on the _link_ result of the target, but that may need further development.

---

<div class="post-metadata">

### Author: ![robert.maynard](https://discourse.cmake.org/user_avatar/discourse.cmake.org/robert.maynard/32/4_2.png) [@robert.maynard](https://discourse.cmake.org/u/robert.maynard)
#### Post date: [July 28, 2025, 5:46pm UTC](https://discourse.cmake.org/t/compile-only-generator-doesnt-seem-to-create-a-dependency-should-it/14445/4 "2025-07-28T17:46:17Z")

</div>

That does look to be an oversight of `COMPILE_ONLY`. Please report an issue with a simple reproducer (if possible).

---

<div class="post-metadata">

### Author: ![Aaron\_Cohen](https://discourse.cmake.org/user_avatar/discourse.cmake.org/aaron_cohen/32/4831_2.png) [@Aaron\_Cohen](https://discourse.cmake.org/u/Aaron_Cohen)
#### Post date: [July 29, 2025, 11:32pm UTC](https://discourse.cmake.org/t/compile-only-generator-doesnt-seem-to-create-a-dependency-should-it/14445/5 "2025-07-29T23:32:01Z")

</div>

I think I mis-diagnosed what was going on here.

At least, I’m having a hard time reproducing it.

Sorry for the false alarm.
