1 ###| CMAKE Kiibohd Controller |###
3 # Jacob Alexander 2011-2013
4 # Due to this file's usefulness:
6 # Released into the Public Domain
10 #| Windows / Cygwin Compatibility options
11 set( CMAKE_LEGACY_CYGWIN_WIN32 0 )
12 set( CMAKE_USE_RELATIVE_PATHS 1 )
14 #| Add Dependency Macro
15 include( AddFileDependencies )
23 #| Specify the compiler family to use
24 #| Currently only supports AVR and ARM
27 #| "avr" # Teensy++ 1.0
28 #| "avr" # Teensy++ 2.0
30 #set( COMPILER_FAMILY "arm" )
31 set( COMPILER_FAMILY "avr" )
35 #| Load the compiler family specific configurations
36 include( ${COMPILER_FAMILY}.cmake )
45 project( kiibohd_controller )
47 #| Target Name (output name)
51 cmake_minimum_required( VERSION 2.8 )
59 #| Sources (see setup.h for configuring in/away code blocks or other complete modules)
60 #| XXX Not set here in this project, see setup.cmake
63 #| Instead, include the module source selector
64 include( setup.cmake )
80 #| Create the .ELF file
81 set( TARGET_ELF ${TARGET}.elf )
82 add_executable( ${TARGET_ELF} ${SRCS} )
86 set_target_properties( ${TARGET_ELF} PROPERTIES
87 LINK_FLAGS ${LINKER_FLAGS}
88 SUFFIX "" # XXX Force Windows to keep the .exe off
92 #| Convert the .ELF into a .HEX to load onto the Teensy
93 set( TARGET_HEX ${TARGET}.hex )
94 add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
95 COMMAND ${OBJCOPY} ${HEX_FLAGS} ${TARGET_ELF} ${TARGET_HEX}
96 COMMENT "Creating load file for Flash: ${TARGET_HEX}"
100 #| Generate the Extended .LSS
101 set( TARGET_LSS ${TARGET}.lss )
102 add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
103 COMMAND ${OBJDUMP} ${LSS_FLAGS} ${TARGET_ELF} > ${TARGET_LSS}
104 COMMENT "Creating Extended Listing: ${TARGET_LSS}"
108 #| Generate the Symbol Table .SYM
109 set( TARGET_SYM ${TARGET}.sym )
110 add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
111 COMMAND ${NM} -n ${TARGET_ELF} > ${TARGET_SYM}
112 COMMENT "Creating Symbol Table: ${TARGET_SYM}"
121 #| After Changes Size Information
122 add_custom_target( SizeAfter ALL ${SIZE} --target=${FORMAT} ${TARGET_HEX} ${TARGET_ELF}
123 DEPENDS ${TARGET_ELF}
124 COMMENT "Size after generation:"
130 # Setup Loader Script
133 #| Provides the user with the correct teensy-loader-cli command for the built .HEX file
134 #| teensy-loader-cli must be in the user's path
135 if( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
136 configure_file( LoadFile/bash load )
137 endif( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
140 if( ${CMAKE_SYSTEM_NAME} MATCHES "Windows" )
141 configure_file( LoadFile/bash load )
142 endif( ${CMAKE_SYSTEM_NAME} MATCHES "Windows" )