# Dependency not being respected - executable not being relinked when necessary

**URL:** https://discourse.cmake.org/t/dependency-not-being-respected-executable-not-being-relinked-when-necessary/8906
**Category:** Usage
**Tags:** os:linux
**Created:** [September 8, 2023, 3:33am UTC](https://discourse.cmake.org/t/dependency-not-being-respected-executable-not-being-relinked-when-necessary/8906 "2023-09-08T03:33:33Z")
**Posts on this page:** 1
**Showing post:** 10

<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: [September 9, 2023, 12:35am UTC](https://discourse.cmake.org/t/dependency-not-being-respected-executable-not-being-relinked-when-necessary/8906/10 "2023-09-09T00:35:10Z")

</div>

I did some digging into this example with Ninja, and from what I can tell, the crux of the problem is that the executable targets end up with an order-only dependency on the `linker.ld-target` custom target. I think that explains why the first build works (no targets are up to date yet), but the second build after modifying ex2.cpp doesn’t cause ex1 to be relinked. That’s a bit of a guess on my part, but I couldn’t see any else immediately obvious which may explain the behavior.

This is getting a bit beyond my understanding of the nitty gritty details of the way dependencies are defined. We may need input from @brad.king on this one. I would have expected your example to work, but maybe there’s some subtle aspect of this I’m overlooking.

---

_[View the full topic](https://discourse.cmake.org/t/dependency-not-being-respected-executable-not-being-relinked-when-necessary/8906)._
