CMake toolchain for AVR microcontroller
- CMake >= 3.23 (to use presets. If you use this without presets, CMake >= 3.12 is acceptable.)
- AVR compiler (see section Appendix: How to install a compiler.)
-
Clone this repository.
git clone https://github.com/Enchan1207/cmake-avr
-
Set environment variable
AVR_SDK_PATHto it.export AVR_SDK_PATH='/path/to/cmake-avr'
-
Configure
CMakePresets.json.{ "version": 10, "cmakeMinimumRequired": { "major": 3, "minor": 12, "patch": 0 }, "configurePresets": [ { "name": "target", "generator": "Ninja", "binaryDir": "${sourceDir}/build/${presetName}", "cacheVariables": { "AVR_MCU": "attiny85", "AVR_FCPU": "8000000" }, "toolchainFile": "$env{AVR_SDK_PATH}/cmake/avr_toolchain.cmake" } ], "buildPresets": [ { "name": "target", "configurePreset": "target" } ] } -
(optional) Add
target_configure_for_avrfor your target inCMakeLists.txt. it provides memory-usage and.hexfile output to specified target.add_executable(main_target) # some configuration... target_configure_for_avr(main_target)
This toolchain provides options: AVR_MCU and AVR_FCPU.
It will be passed to commands and can be set at configure (cmake ...) or at CMakePresets.json.
AVR compilers can be installed from microchip or HomeBrew.
This repository is published under MIT License.