# Remove items from CMAKE\_EXE\_LINKER\_FLAGS\_INIT

**URL:** https://discourse.cmake.org/t/remove-items-from-cmake-exe-linker-flags-init/7785
**Category:** Code
**Created:** [March 28, 2023, 3:17pm UTC](https://discourse.cmake.org/t/remove-items-from-cmake-exe-linker-flags-init/7785 "2023-03-28T15:17:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ingolf](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/i/977dab/32.png) [@ingolf](https://discourse.cmake.org/u/ingolf)
#### Post date: [March 28, 2023, 3:17pm UTC](https://discourse.cmake.org/t/remove-items-from-cmake-exe-linker-flags-init/7785/1 "2023-03-28T15:17:08Z")

</div>

Hi,

how can I remove certain link options of a specific executable which initially came from `CMAKE_EXE_LINKER_FLAGS_INIT`?

For instance, the CMake configuration for the Android platform defines `CMAKE_EXE_LINKER_FLAGS_INIT` to include `-Wl,--gc-sections`. Is there a way to remove this particular option from the link options of an executable?

I tried that by removing `-Wl,--gc-sections` from the `LINK_OPTIONS` property of the corresponding target, but apparently, the `CMAKE_EXE_LINKER_FLAGS_INIT` content is not reflected there. The same seems to be the case for the `LINK_FLAGS` property.

Kind regards  
Ingolf

---

<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: [April 3, 2023, 11:34am UTC](https://discourse.cmake.org/t/remove-items-from-cmake-exe-linker-flags-init/7785/2 "2023-04-03T11:34:30Z")

</div>

Those flags end up being kind of “part of the compiler” as far as CMake is concerned. You’ll likely need to remove it from `CMAKE_EXE_LINKER_FLAGS` and its per-config variants directly.
