Since CMake 3.13, target_link_options exists that adds "options to the link step".
Near the bottom of that page it says:
To pass options to the linker tool, each compiler driver has its own syntax. The
LINKER:prefix and,separator can be used to specify, in a portable way, options to pass to the linker tool
Could someone give an example of how you would use target_link_options() with the LINKER: helper?
Thank you for any help!
The idea is to put all linker options as a string of comma-separated items prepended by 'LINKER:'. Say I have these set of flags which I use with the compiler invocation (gcc):
-Wl,--gc-sections,-Tbootloader.ld,-Map=bootloader.map
Then cmake portion should look like.
...
add_executable(bootloader ${SRC})
target_link_options(bootloader PUBLIC "LINKER:--gc-sections,-Tbootloader.ld,-Map=bootloader.map")
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With