-
Notifications
You must be signed in to change notification settings - Fork 18
Creating custom build configurations
CMake brings a number of standard build configurations (Debug
, Release
, RelWithDebInfo
and MinSizeRel
). However there are cases in which the optimization objective is towards the maximum possible speed. In that case, it is necessary to create a custom build configuration. While this interactive example was tailored to work with the IAR C/C++ Compiler for Arm, it can easily ported to other architectures.
A CMake project example is provided at examples/custom:
Project files |
---|
CMakeLists.txt |
iar-cspysim.cmake |
iar-custom.cmake |
sqrt.c |
sqrtf.c |
systick.mac |
The goal of this interactive example is to use 2 custom build configurations created in iar-custom.cmake
, configure the project, build the project using different configurations and finally execute simulated tests for multiple configurations.
- Perform the following tasks (click to show/hide answers):
TODO 1: Include the CMake modules to the project
On the CMakeLists.txt
project file:
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
include(iar-cspysim)
include(iar-custom)
- Save the file.
NOTES
- The
iar-custom.cmake
module creates two new custom build configurations for the CMake project:HighSpeed
andMaxSpeed
. Inspect the contents of the module for details on their configuration flags.
TODO 2: Configure the project
- Configure the project for using the "Ninja Multi-Config" generator:
cmake -Bbuild -G"Ninja Multi-Config"
TODO 3: Build all configurations
- With the project configured, build each existing build configuration:
cmake --build build --config Debug
cmake --build build --config Release
cmake --build build --config RelWithDebInfo
cmake --build build --config MinSizeRel
cmake --build build --config HighSpeed
cmake --build build --config MaxSpeed
NOTES
- You can, instead build with
--verbose
in case you want to see details about the command lines CMake generated for each build configuration.
TODO 4: Test each configuration
- With all build configurations built, you can test them with CTest:
ctest --test-dir build -C debug --verbose
ctest --test-dir build -C maxspeed --verbose
NOTES
- The C-SPY simulator provides sampled rough estimates and should not replace actual hardware for cycle-accurate measurements.
This interactive example covered the basics on how to create custom build configurations in CMake. Now you can make use of the *.cmake
modules on your projects whenever they require custom configurations, not covered by CMake's defaults.
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