41 lines
990 B
CMake
41 lines
990 B
CMake
cmake_minimum_required(VERSION 3.15)
|
|
|
|
# Project name and version
|
|
project(tool_probe VERSION 1.0)
|
|
|
|
|
|
# enable_language(C ASM)
|
|
|
|
# toolchain file for AVR
|
|
# set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/avr-gcc-toolchain.cmake)
|
|
|
|
# Set executable name
|
|
add_executable(${PROJECT_NAME})
|
|
|
|
# generate hex file
|
|
add_custom_command(
|
|
TARGET ${PROJECT_NAME} POST_BUILD
|
|
COMMAND avr-objcopy -O ihex -R .eeprom ${PROJECT_NAME}.elf ${PROJECT_NAME}.hex
|
|
COMMAND avr-size ${PROJECT_NAME}.elf
|
|
COMMENT "Generating HEX file"
|
|
)
|
|
|
|
# add custom target for uploading
|
|
add_custom_target(flash
|
|
COMMAND avrdude -p ${AVR_MCU} -c ${AVR_PROGRAMMER} -U flash:w:${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.hex:i
|
|
DEPENDS ${PROJECT_NAME}
|
|
COMMENT "Uploading HEX file to microcontroller"
|
|
)
|
|
|
|
# Link directories setup
|
|
target_link_directories(${PROJECT_NAME} PRIVATE
|
|
src
|
|
)
|
|
|
|
# Add sources to executable
|
|
target_sources(${PROJECT_NAME} PRIVATE
|
|
src/main.c
|
|
src/input_handler.c
|
|
src/timer_counter.c
|
|
)
|