IAR ILINK linker options in a CMake Project - iarsystems/cmake-tutorial GitHub Wiki
The IAR ILINK Linker comes with a vast amount of options that are described in detail in its accompanying Development Guide. Below you will find a non-exhaustive compendium of frequently used options, alongside their respective meanings, where and how you can use them in your CMake projects.
Some linker options are available regardless of the chosen target architecture. Below you will find relevant information. In CMake, all linker options can be specified in target_link_options().
-
--config <file>.icfreads the linker configuration from<file>.icf.
target_link_options(tgt PRIVATE
--config /opt/iar/bxarm/arm/config/linker/ST/stm32f407xG.icf
# other linker options... )-
--map <file|dir>produces a linker map file in the chosen location. Example:
target_link_options(tgt PRIVATE
--map . # will generate a map file inside ${CMAKE_CURRENT_BUILD_DIR}
# other linker options... )-
--no_wrap_diagnosticsprevents line breaks for linker-related diagnostic messages. In CMake, it is a recommended option for environments where these messages will be logged. -
--redirect=<foo>=<alt_foo>redirects all symbolic reference pointing to<foo>towards<alt_foo>. This option can be specified multiple times although CMake requires theSHELL:prefix for repeated parameters. Example:
target_link_options(tgt PRIVATE
SHELL:--redirect=__write=__write_buffered
SHELL:--redirect=_Printf=_PrintfFullNoMb
# other options... )-
--search <path>or-L <path>specifies a path in which the linker should search for objects and libraries. This option can be specified multiple times although CMake requires theSHELL:prefix for repeated parameters. Example:
target_link_options(tgt PRIVATE
SHELL:--search=/path/to/libs
SHELL:--search=/path/to/more-libs
# other options... )Below you will find details about ILINK's options available for specific architectures.
The semihosting interface is available for both Arm and RISC-V targets.
-
--semihosting[=iarbreakpoint]links the target with semihosting debugging interface. Example:
target_link_options(tgt PRIVATE
--semihosting
# other options... )