Remove items from CMAKE_EXE_LINKER_FLAGS_INIT

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

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.