# Is it possible to force an executable target to pre-req another one

**URL:** https://discourse.cmake.org/t/is-it-possible-to-force-an-executable-target-to-pre-req-another-one/14009
**Category:** Usage
**Created:** [April 28, 2025, 3:37pm UTC](https://discourse.cmake.org/t/is-it-possible-to-force-an-executable-target-to-pre-req-another-one/14009 "2025-04-28T15:37:46Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![perdrix](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/a8b319/32.png) [@perdrix](https://discourse.cmake.org/u/perdrix)
#### Post date: [April 28, 2025, 3:37pm UTC](https://discourse.cmake.org/t/is-it-possible-to-force-an-executable-target-to-pre-req-another-one/14009/1 "2025-04-28T15:37:46Z")

</div>

I have two projects for executables: DeepSkyStacker (DSS for short) and DeepSkyStackerCL (DSSCL for short).

The top level CMakelists.txt does this

add\_subdirectory(DeepSkyStackerKernel)  
add\_subdirectory(ZClass)  
add\_subdirectory(DeepSkyStackerCL)  
add\_subdirectory(DeepSkyStacker)

so if I simply run the top level CMakelist.txt then the libraries in the DSSKernel and ZClass projects and then DSSCL are built first. This is good because DSS wants to copy the executable built by DSSCL into the SharedSupport directory of the macOS bundle. However it’s possible (at least using Visual Studio to drive CMake) to request that DSS be built. In that case the libraries it needs will be built prior to building DSS, but DSSCL won’t be built as I can’t see a way to make DSS dependent on DSSCL?

Is there a way to tell CMake that this dependency exists? If not does anyone have any suggestions on how best to handle this?

Thanks  
David

---

<div class="post-metadata">

### Author: ![LegalizeAdulthood](https://discourse.cmake.org/user_avatar/discourse.cmake.org/legalizeadulthood/32/5282_2.png) [@LegalizeAdulthood](https://discourse.cmake.org/u/LegalizeAdulthood)
#### Post date: [April 28, 2025, 5:04pm UTC](https://discourse.cmake.org/t/is-it-possible-to-force-an-executable-target-to-pre-req-another-one/14009/2 "2025-04-28T17:04:49Z")

</div>

Typically an executable depends on a library by linking against the library target:

```auto
target_link_libraries(exe PUBLIC lib)

```

---

<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: [April 28, 2025, 6:46pm UTC](https://discourse.cmake.org/t/is-it-possible-to-force-an-executable-target-to-pre-req-another-one/14009/3 "2025-04-28T18:46:06Z")

</div>

Of you do not link, you have to specify the dependency manually with add\_dependencies()
