-
Notifications
You must be signed in to change notification settings - Fork 19
Invoking IAR binary utilities
CMake can automatically detect the IAR Build Tools and provide internal variables for them, allowing you to invoke their accompanying binary utilities directly from a CMake project.
The following table describes CMake internal variables that are specific to IAR and return the full path to the executables for the toolchain in use:
cmake_minimum_required() |
Tool | CMake internal variable |
|---|---|---|
| 3.28 | IAR Archive Tool | CMAKE_AR |
| 3.31 | IAR ELF Dumper | CMAKE_IAR_ELFDUMP |
| 3.31 | IAR ELF Tool | CMAKE_IAR_ELFTOOL |
| 3.31 | IAR ELF Exe to Object Tool | CMAKE_IAR_EXE2OBJ |
| 3.31 | IAR Object File Manipulator | CMAKE_IAR_OBJMANIP |
| 3.31 | IAR Absolute Symbol Exporter | CMAKE_IAR_SYMEXPORT |
| 4.1 | IAR C-STAT Command Line Interface | CMAKE_IAR_CSTAT |
| 4.1 | IAR C-STAT Checks Manifest Handler | CMAKE_IAR_CHECKS |
| 4.1 | IAR C-STAT Report Generator | CMAKE_IAR_REPORT |
Important
Please note that these references expect their respective tools to be available in the installed toolchain.
In the example below, the IAR ELF Tool is used at the post-build stage for converting the executable output from myTarget to its binary form, in the Intel Extended format (*.hex):
add_custom_command(TARGET myTarget
POST_BUILD COMMAND ${CMAKE_IAR_ELFTOOL}
--silent
--ihex
$<TARGET_FILE:myTarget>
$<TARGET_FILE_DIR:myTarget>/myTarget.hex
)In the example below, the IAR ELF Tool is used at the post-build stage for checksumming an application within an explicit range. Please note that the --fill and --checksum options require semicolon within its parameters which clash with certain shell rules. A portable solution is to pass those parameters as quoted strings while escaping the semicolon:
add_custom_command(TARGET myTarget
POST_BUILD COMMAND ${CMAKE_IAR_ELFTOOL}
--verbose
--fill="0xFF\;0x0800'0000-0x0800'FFFF"
--checksum="__checksum:4,crc32:Li,0xFFFFFFFF\;0x0800'0000-0x0800'FFFF"
$<TARGET_FILE:myTarget>
$<TARGET_FILE:myTarget>
)Note that the ticks (
') used for separating nibbles in addresses are supported byielftooland entirely optional.
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