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" )
33 message( STATUS "Compiler Family:" )
34 message( "${COMPILER_FAMILY}" )
38 #| Load the compiler family specific configurations
39 include( ${COMPILER_FAMILY}.cmake )
48 project( kiibohd_controller )
50 #| Target Name (output name)
54 cmake_minimum_required( VERSION 2.8 )
62 #| Sources (see setup.h for configuring in/away code blocks or other complete modules)
63 #| XXX Not set here in this project, see setup.cmake
66 #| Instead, include the module source selector
67 include( setup.cmake )
83 #| Create the .ELF file
84 set( TARGET_ELF ${TARGET}.elf )
85 add_executable( ${TARGET_ELF} ${SRCS} )
89 set_target_properties( ${TARGET_ELF} PROPERTIES
90 LINK_FLAGS ${LINKER_FLAGS}
91 SUFFIX "" # XXX Force Windows to keep the .exe off
95 #| Convert the .ELF into a .HEX to load onto the Teensy
96 set( TARGET_HEX ${TARGET}.hex )
97 add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
98 COMMAND ${OBJCOPY} ${HEX_FLAGS} ${TARGET_ELF} ${TARGET_HEX}
99 COMMENT "Creating load file for Flash: ${TARGET_HEX}"
103 #| Generate the Extended .LSS
104 set( TARGET_LSS ${TARGET}.lss )
105 add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
106 COMMAND ${OBJDUMP} ${LSS_FLAGS} ${TARGET_ELF} > ${TARGET_LSS}
107 COMMENT "Creating Extended Listing: ${TARGET_LSS}"
111 #| Generate the Symbol Table .SYM
112 set( TARGET_SYM ${TARGET}.sym )
113 add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
114 COMMAND ${NM} -n ${TARGET_ELF} > ${TARGET_SYM}
115 COMMENT "Creating Symbol Table: ${TARGET_SYM}"
124 #| After Changes Size Information
125 add_custom_target( SizeAfter ALL ${SIZE} --target=${FORMAT} ${TARGET_HEX} ${TARGET_ELF}
126 DEPENDS ${TARGET_ELF}
127 COMMENT "Size after generation:"
133 # Setup Loader Script
136 #| Provides the user with the correct teensy-loader-cli command for the built .HEX file
137 #| teensy-loader-cli must be in the user's path
138 if( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
139 configure_file( LoadFile/bash load )
140 endif( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
143 if( ${CMAKE_SYSTEM_NAME} MATCHES "Windows" )
144 configure_file( LoadFile/bash load )
145 endif( ${CMAKE_SYSTEM_NAME} MATCHES "Windows" )