Skip to content

Selecting build types

Felipe Torrezan edited this page Apr 13, 2024 · 3 revisions

Introduction

The IAR driver built into CMake provides different compiler optimization flags depending on the selected build type.

Helpful Resources

Description

The CMake variable CMAKE_CONFIGURATION_TYPES provides four build configurations and also allows user custom build configurations.

As per CMake 3.28.1, the default build configuration types and their differences are:

Build configuration Initial options for the IAR compiler
Debug -r
Release -Oh -DNDEBUG
RelWithDebInfo -Oh -DNDEBUG -r
MinSizeRel -Ohz -DNDEBUG

Tasks

  • Select the desired CMAKE_BUILD_TYPE at configure-time. For example, for building using high optimization for minimal binary size:
mkdir build-MinSizeRel
cd build-MinSizeRel
cmake .. -G Ninja --toolchain /path/to/your-iar-toolchain-file.cmake -DCMAKE_BUILD_TYPE=MinSizeRel

Note

When the project is built, the compiler will initially get the selected optimization flags (-Ohz -DNDEBUG).

Clone this wiki locally