-
Notifications
You must be signed in to change notification settings - Fork 15
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:
cd tutorial
mkdir build
cd build
cmake .. -G Ninja --toolchain ../bxarm.cmake
And then:
cmake --build .
It will give an output similar to:
[2/2] Linking C executable tutorial.elf
To 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, build again:
cmake --build .
CMake will regenerate the build system and, by default, give an output similar to:
[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 V9.40.1.364/LNX for ARM Copyright 2007-2023 IAR Systems AB. 972 bytes of readonly code memory 48 bytes of readonly data memory 16'392 bytes of readwrite data memory Errors: none Warnings: none Link time: 0.00 (CPU) 0.00 (elapsed)
To temporarily disable the -DISPLAY_LINKER_SUMMARY
option, use:
cmake .. -DISPLAY_LINKER_SUMMARY=OFF
-- Configuring done (0.0s) -- Generating done (0.0s) -- Build files have been written to: /path/to/cmake-tutorial/tutorial/build
And rebuild the project:
cmake --build .
The linker output should be again suppressed as in the default CMake behavior.
This is the cmake-tutorial wiki. Back to Wiki Home
- Setting language-specific target options
- Selecting build types
- Using Ninja Multi-Config
- Filing a build log
- Multi-file compilation
- Invoking IAR binary utilities