1 ###| CMAKE Kiibohd Controller |###
3 # Jacob Alexander 2011-2014
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 )
20 #| Specify the compiler family to use
21 #| Currently only supports AVR and ARM
24 #| "avr" # Teensy++ 1.0
25 #| "avr" # Teensy++ 2.0
28 set( COMPILER_FAMILY "arm" )
29 #set( COMPILER_FAMILY "avr" )
31 message( STATUS "Compiler Family:" )
32 message( "${COMPILER_FAMILY}" )
36 #| Load the compiler family specific configurations
37 include( ${COMPILER_FAMILY}.cmake )
46 project( kiibohd_controller )
48 #| Target Name (output name)
52 cmake_minimum_required( VERSION 2.8 )
60 #| Sources (see setup.h for configuring in/away code blocks or other complete modules)
61 #| XXX Not set here in this project, see setup.cmake
64 #| Instead, include the module source selector
65 include( setup.cmake )
75 #| Directories to include by default
76 include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
81 # Module Compatibility Check
84 #| Check for whether the set modules are compatible with the specified compiler family
85 ModuleCompatibility( ${ScanModulePath} ${ScanModuleCompatibility} )
86 ModuleCompatibility( ${MacroModulePath} ${MacroModuleCompatibility} )
87 ModuleCompatibility( ${OutputModulePath} ${OutputModuleCompatibility} )
88 ModuleCompatibility( ${DebugModulePath} ${DebugModuleCompatibility} )
93 # CMake Module Checking
95 find_package( Git REQUIRED )
102 #| Create the .ELF file
103 set( TARGET_ELF ${TARGET}.elf )
104 add_executable( ${TARGET_ELF} ${SRCS} )
108 set_target_properties( ${TARGET_ELF} PROPERTIES
109 LINK_FLAGS ${LINKER_FLAGS}
110 SUFFIX "" # XXX Force Windows to keep the .exe off
114 #| Convert the .ELF into a .HEX to load onto the Teensy
115 set( TARGET_HEX ${TARGET}.hex )
116 add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
117 COMMAND ${OBJCOPY} ${HEX_FLAGS} ${TARGET_ELF} ${TARGET_HEX}
118 COMMENT "Creating load file for Flash: ${TARGET_HEX}"
122 #| Generate the Extended .LSS
123 set( TARGET_LSS ${TARGET}.lss )
124 add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
125 COMMAND ${OBJDUMP} ${LSS_FLAGS} ${TARGET_ELF} > ${TARGET_LSS}
126 COMMENT "Creating Extended Listing: ${TARGET_LSS}"
130 #| Generate the Symbol Table .SYM
131 set( TARGET_SYM ${TARGET}.sym )
132 add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
133 COMMAND ${NM} -n ${TARGET_ELF} > ${TARGET_SYM}
134 COMMENT "Creating Symbol Table: ${TARGET_SYM}"
143 #| After Changes Size Information
144 #| TODO Do lookup on Flash and RAM sizes and do % used
145 add_custom_target( SizeAfter ALL
146 COMMAND ${SIZE} --target=${FORMAT} ${TARGET_HEX} ${TARGET_ELF}
147 DEPENDS ${TARGET_ELF}
148 COMMENT "Size after generation\n\tFlash Usage: data (hex)\n\t RAM Usage: data (elf)"
154 # Setup Loader Script and Program
157 #| Provides the user with the correct teensy-loader-cli command for the built .HEX file
158 configure_file( LoadFile/load load )