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 )
77 #| Directories to include by default
78 include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
83 # Module Compatibility Check
86 #| Check for whether the set modules are compatible with the specified compiler family
87 ModuleCompatibility( ${ScanModulePath} ${ScanModuleCompatibility} )
88 ModuleCompatibility( ${MacroModulePath} ${MacroModuleCompatibility} )
89 ModuleCompatibility( ${OutputModulePath} ${OutputModuleCompatibility} )
90 ModuleCompatibility( ${DebugModulePath} ${DebugModuleCompatibility} )
98 #| Create the .ELF file
99 set( TARGET_ELF ${TARGET}.elf )
100 add_executable( ${TARGET_ELF} ${SRCS} )
104 set_target_properties( ${TARGET_ELF} PROPERTIES
105 LINK_FLAGS ${LINKER_FLAGS}
106 SUFFIX "" # XXX Force Windows to keep the .exe off
110 #| Convert the .ELF into a .HEX to load onto the Teensy
111 set( TARGET_HEX ${TARGET}.hex )
112 add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
113 COMMAND ${OBJCOPY} ${HEX_FLAGS} ${TARGET_ELF} ${TARGET_HEX}
114 COMMENT "Creating load file for Flash: ${TARGET_HEX}"
118 #| Generate the Extended .LSS
119 set( TARGET_LSS ${TARGET}.lss )
120 add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
121 COMMAND ${OBJDUMP} ${LSS_FLAGS} ${TARGET_ELF} > ${TARGET_LSS}
122 COMMENT "Creating Extended Listing: ${TARGET_LSS}"
126 #| Generate the Symbol Table .SYM
127 set( TARGET_SYM ${TARGET}.sym )
128 add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
129 COMMAND ${NM} -n ${TARGET_ELF} > ${TARGET_SYM}
130 COMMENT "Creating Symbol Table: ${TARGET_SYM}"
139 #| After Changes Size Information
140 add_custom_target( SizeAfter ALL ${SIZE} --target=${FORMAT} ${TARGET_HEX} ${TARGET_ELF}
141 DEPENDS ${TARGET_ELF}
142 COMMENT "Size after generation:"
148 # Setup Loader Script
151 #| Provides the user with the correct teensy-loader-cli command for the built .HEX file
152 #| teensy-loader-cli must be in the user's path
153 if( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
154 configure_file( LoadFile/bash load )
158 if( ${CMAKE_SYSTEM_NAME} MATCHES "Windows" )
159 configure_file( LoadFile/bash load )