cmake_minimum_required(VERSION 3.13) # Project project(lezyne-rear-light-firmware C) # MCU and clock set(MCU attiny202) set(F_CPU 5000000UL) # 5 MHz # Toolchain executables set(CMAKE_SYSTEM_NAME Generic) set(CMAKE_C_COMPILER avr-gcc) set(OBJCOPY avr-objcopy) # Compiler flags: optimize, warnings, treat warnings as errors set(CMAKE_C_FLAGS "-mmcu=${MCU} -DF_CPU=${F_CPU} -Os -Wall -Werror") # Sources add_executable(main.elf main.c) # HEX file add_custom_command( OUTPUT main.hex COMMAND ${OBJCOPY} -O ihex -R .eeprom main.elf main.hex DEPENDS main.elf ) # BIN file add_custom_command( OUTPUT main.bin COMMAND ${OBJCOPY} -O binary -R .eeprom main.elf main.bin DEPENDS main.elf ) # Targets add_custom_target(hex ALL DEPENDS main.hex) add_custom_target(bin ALL DEPENDS main.bin)