Repository navigation
Displaying the IAR Linker summary
By default, CMake will suppress the output provided by the underlying build tools, though sometimes it is convenient to get some output at build-time such as the binary's resource consumption provided by the IAR ILINK linker's summary. In this article, we will explore one way of overriding CMake's default behavior.
Starting from CMake 3.27, the IAR linker's --silent flag is not hardcoded. A CMake option() can be used to choose when to display the linker-provided information.
For example, configuring for the IAR Build Tools for Arm (CX):
$ cd tutorial
$ mkdir build
$ cd build$ cmake .. -G Ninja --toolchain ../cxarm.cmake
-- The C compiler identification is IAR ARM 10.10.2
-- The CXX compiler identification is IAR ARM 10.10.2
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /opt/iar/cxarm/arm/bin/iccarm - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /opt/iar/cxarm/arm/bin/iccarm - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.4s)
-- Generating done (0.0s)
-- Build files have been written to: /path/to/cmake-tutorial/tutorial/buildAnd then:
$ cmake --build .
[2/2] Linking C executable tutorial.elfTo display the summary by default, append the following snippet to your toolchain file:
option(ISPLAY_LINKER_SUMMARY "Display linker resource usage" ON)
if(ISPLAY_LINKER_SUMMARY)
string(REGEX REPLACE "(^| )(--silent|-S)($| )" " " CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
endif()And then, rebuild:
$ cmake --build .
[0/1] Re-running CMake...
-- Configuring done (0.0s)
-- Generating done (0.0s)
-- Build files have been written to: /path/to/cmake-tutorial/tutorial/build
[1/1] Linking C executable tutorial.elf
IAR ELF Linker V10.10.2.628/LNX for ARM
Copyright 2007-2026 IAR Systems AB.
1'086 bytes of readonly code memory
97 bytes of readonly data memory
16'548 bytes of readwrite data memory
Errors: none
Warnings: none
Link time: 0.02 (CPU) 0.11 (elapsed)To temporarily disable the -DISPLAY_LINKER_SUMMARY option, reconfigure the project:
$ cmake .. -DISPLAY_LINKER_SUMMARY=OFF
-- Configuring done (0.0s)
-- Generating done (0.0s)
-- Build files have been written to: /path/to/cmake-tutorial/tutorial/buildAnd rebuild:
$ cmake --build .
[1/1] Linking C executable tutorial.elfThe linker map summary was temporarily suppressed as in the default CMake behavior.
This is the cmake-tutorial wiki. Back to Wiki Home
- IAR Compiler options in a CMake project
- IAR ILINK options in a CMake project
- Language-specific target options
- Selecting build types
- Using Ninja Multi-Config
- Filing a build log
- Multi-file compilation
- Invoking IAR binary utilities
- Use the IAR ELF Tool to convert executable targets to their binary formats
- Using IAR Build Tools with CMake Presets