# Is there a generic way to detect and reject underlinking?

**URL:** https://discourse.cmake.org/t/is-there-a-generic-way-to-detect-and-reject-underlinking/5059
**Category:** Usage
**Tags:** os:linux
**Created:** [February 18, 2022, 4:48pm UTC](https://discourse.cmake.org/t/is-there-a-generic-way-to-detect-and-reject-underlinking/5059 "2022-02-18T16:48:05Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![paterno](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/c37758/32.png) [@paterno](https://discourse.cmake.org/u/paterno)
#### Post date: [February 18, 2022, 4:48pm UTC](https://discourse.cmake.org/t/is-there-a-generic-way-to-detect-and-reject-underlinking/5059/1 "2022-02-18T16:48:05Z")

</div>

In many projects I use:

```auto
set(LINKER_OPTIONS "LINKER:-z,defs")

```

to prevent underlinking. But this requires tests for what platform is being used (macOS does not recognize this flag, and doesn’t need it), and perhaps even depends on the compiler and linker toolchain being used.

Is there a “generic” way to have CMake provide this for me, when it is needed?

---

<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 18, 2022, 9:58pm UTC](https://discourse.cmake.org/t/is-there-a-generic-way-to-detect-and-reject-underlinking/5059/2 "2022-02-18T21:58:34Z")

</div>

There’s no generic CMake feature to do this that I’m aware of.
