-
Notifications
You must be signed in to change notification settings - Fork 19
Toolchain file template
This article explains how to use CMake Toolchain Files with the IAR tools.
<toolchain-file>.cmake is an optional file that allows setting up CMake for cross-compiling scenarios.
Before entering CMake, make sure your compiler is working properly as in the example below (for arm):
echo "main(){}" | /path/to/iccarm --output /tmp/test.o -The template below comes pre-configured to work with cxarm-9.70.1 on Linux or Windows:
# Toolchain file for the IAR C/C++ Compiler for Arm
# Filename: cxarm.cmake
if (LINUX)
set(CMAKE_C_COMPILER "/opt/iar/cxarm/arm/bin/iccarm")
set(CMAKE_CXX_COMPILER "/opt/iar/cxarm/arm/bin/iccarm")
set(CMAKE_ASM_COMPILER "/opt/iar/cxarm/arm/bin/iasmarm")
else()
set(CMAKE_C_COMPILER "C:/iar/cxarm-9.70.1/arm/bin/iccarm.exe")
set(CMAKE_CXX_COMPILER "C:/iar/cxarm-9.70.1/arm/bin/iccarm.exe")
set(CMAKE_ASM_COMPILER "C:/iar/cxarm-9.70.1/arm/bin/iasmarm.exe")
endif()The template below comes pre-configured to work with bxarm-9.70.1 on Linux or Windows:
# Toolchain file for the IAR C/C++ Compiler for Arm
# Filename: bxarm.cmake
if (LINUX)
set(CMAKE_C_COMPILER "/opt/iarsystems/bxarm/arm/bin/iccarm")
set(CMAKE_CXX_COMPILER "/opt/iarsystems/bxarm/arm/bin/iccarm")
set(CMAKE_ASM_COMPILER "/opt/iarsystems/bxarm/arm/bin/iasmarm")
else()
set(CMAKE_C_COMPILER "C:/iar/bxarm-9.70.1/arm/bin/iccarm.exe")
set(CMAKE_CXX_COMPILER "C:/iar/bxarm-9.70.1/arm/bin/iccarm.exe")
set(CMAKE_ASM_COMPILER "C:/iar/bxarm-9.70.1/arm/bin/iasmarm.exe")
endif()The template below comes pre-configured to work with ewarm-9.70.1 on Windows:
# Toolchain file for the IAR C/C++ Compiler for Arm
# Filename: ewarm.cmake
set(CMAKE_C_COMPILER "C:/iar/ewarm-9.70.1/arm/bin/iccarm.exe")
set(CMAKE_CXX_COMPILER "C:/iar/ewarm-9.70.1/arm/bin/iccarm.exe")
set(CMAKE_ASM_COMPILER "C:/iar/ewarm-9.70.1/arm/bin/iasmarm.exe")Below you will find an exemplary sequence of commands on how to build a project using the cxarm.cmake toolchain file template:
# Configure the project
$ cmake -Bbuild -G"Ninja Multi-Config" --toolchain cxarm.cmake
# Build specifying configurations
$ cmake --build build --config Debug --verbose
$ cmake --build build --config Release --verboseCMake toolchain files are a convenient way to file toolchain configurations. They become specially handy when dealing with a number of different toolchain versions, architectures and such. The proposed templates can be used as an starting point, checked into version control, and extended as needed.
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