avr-clion/CMakeLists.txt

38 lines
1.5 KiB
CMake
Raw Normal View History

2015-02-05 20:52:15 +03:00
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.4)
SET(CMAKE_SYSTEM_NAME Generic)
#============================================================================================
PROJECT(avr-clion)
SET(DEVICE "atmega8")
SET(FREQ "4000000")
#============================================================================================
2015-02-05 21:30:07 +03:00
SET(CMAKE_C_COMPILER avr-gcc)
2015-02-05 20:52:15 +03:00
SET(CMAKE_CXX_COMPILER avr-g++)
SET(CMAKE_C_FLAGS "-Os -mmcu=${DEVICE} -DF_CPU=${FREQ}UL -std=gnu99 -Wl,--gc-sections")
SET(CMAKE_CXX_FLAGS "-Os -mmcu=${DEVICE} -DF_CPU=${FREQ}UL -Wl,--gc-sections")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
#============================================================================================
SET(SOURCE_FILES
main.c
easyavr.h
)
#============================================================================================
ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCE_FILES})
ADD_CUSTOM_COMMAND(TARGET ${PROJECT_NAME} POST_BUILD COMMAND avr-objcopy -O ihex -R.eeprom ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.hex)
2015-03-09 14:43:52 +03:00
ADD_CUSTOM_COMMAND(TARGET ${PROJECT_NAME} POST_BUILD COMMAND avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.eep)
2015-02-05 20:52:15 +03:00
ADD_CUSTOM_COMMAND(TARGET ${PROJECT_NAME} POST_BUILD COMMAND avr-size ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME} --mcu=${DEVICE} --format=avr)