Invoking IAR binary utilities - iarsystems/cmake-tutorial GitHub Wiki
Introduction
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.
Description
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.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.
Example
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> myTarget.hex)