-
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.
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.cmakemodule creates two new custom build configurations for the CMake project:HighSpeedandMaxSpeed. 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 MaxSpeedNOTES
- You can, instead build with
--verbosein 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 --verboseNOTES
- 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.
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