summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt37
1 files changed, 37 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..d31ff5e
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,37 @@
+cmake_minimum_required(VERSION 2.8.3)
+
+
+SET(BOARD "atmega328p" CACHE STRING "AVR CPU to build for")
+SET(CLOCK "16000000" CACHE STRING "CPU clock")
+
+SET(FLASH_FLAGS "-patmega328p" "-carduino" "-P/dev/ttyUSB0" "-b57600" CACHE STRING "avrdude flags")
+
+
+find_program(AVR_GCC avr-gcc)
+find_program(AVRDUDE avrdude)
+
+SET(CMAKE_SYSTEM_NAME Generic)
+
+
+SET(CMAKE_C_COMPILER ${AVR_GCC})
+
+project(ARDKBD C)
+
+set(CMAKE_MODULE_PATH ${ARDKDB_SOURCE_DIR})
+
+
+add_executable(snake.elf
+ Charliplexing.c
+ kbd.c
+ snake.c
+)
+set_target_properties(snake.elf PROPERTIES
+ COMPILE_FLAGS "-Wall -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Os -mmcu=${BOARD}"
+ LINK_FLAGS "-Wall -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -Os -mmcu=${BOARD}"
+ COMPILE_DEFINITIONS "F_CPU=${CLOCK}"
+)
+
+add_custom_command(OUTPUT snake.hex COMMAND ${CMAKE_OBJCOPY} -O ihex -R .eeprom snake.elf snake.hex DEPENDS snake.elf)
+add_custom_target(snake ALL DEPENDS snake.hex)
+
+add_custom_target(flash COMMAND ${AVRDUDE} ${FLASH_FLAGS} -D -Uflash:w:snake.hex:i DEPENDS snake)