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 )
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
31 set( COMPILER_FAMILY "arm" )
32 #set( COMPILER_FAMILY "avr" )
34 message( STATUS "Compiler Family:" )
35 message( "${COMPILER_FAMILY}" )
39 #| Load the compiler family specific configurations
40 include( ${COMPILER_FAMILY}.cmake )
49 project( kiibohd_controller )
51 #| Target Name (output name)
55 cmake_minimum_required( VERSION 2.8 )
63 #| Sources (see setup.h for configuring in/away code blocks or other complete modules)
64 #| XXX Not set here in this project, see setup.cmake
67 #| Instead, include the module source selector
68 include( setup.cmake )
78 #| Directories to include by default
79 include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
84 # Module Compatibility Check
87 #| Check for whether the set modules are compatible with the specified compiler family
88 ModuleCompatibility( ${ScanModulePath} ${ScanModuleCompatibility} )
89 ModuleCompatibility( ${MacroModulePath} ${MacroModuleCompatibility} )
90 ModuleCompatibility( ${OutputModulePath} ${OutputModuleCompatibility} )
91 ModuleCompatibility( ${DebugModulePath} ${DebugModuleCompatibility} )
99 #| Create the .ELF file
100 set( TARGET_ELF ${TARGET}.elf )
101 add_executable( ${TARGET_ELF} ${SRCS} )
105 set_target_properties( ${TARGET_ELF} PROPERTIES
106 LINK_FLAGS ${LINKER_FLAGS}
107 SUFFIX "" # XXX Force Windows to keep the .exe off
111 #| Convert the .ELF into a .HEX to load onto the Teensy
112 set( TARGET_HEX ${TARGET}.hex )
113 add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
114 COMMAND ${OBJCOPY} ${HEX_FLAGS} ${TARGET_ELF} ${TARGET_HEX}
115 COMMENT "Creating load file for Flash: ${TARGET_HEX}"
119 #| Generate the Extended .LSS
120 set( TARGET_LSS ${TARGET}.lss )
121 add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
122 COMMAND ${OBJDUMP} ${LSS_FLAGS} ${TARGET_ELF} > ${TARGET_LSS}
123 COMMENT "Creating Extended Listing: ${TARGET_LSS}"
127 #| Generate the Symbol Table .SYM
128 set( TARGET_SYM ${TARGET}.sym )
129 add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
130 COMMAND ${NM} -n ${TARGET_ELF} > ${TARGET_SYM}
131 COMMENT "Creating Symbol Table: ${TARGET_SYM}"
140 #| After Changes Size Information
141 add_custom_target( SizeAfter ALL ${SIZE} --target=${FORMAT} ${TARGET_HEX} ${TARGET_ELF}
142 DEPENDS ${TARGET_ELF}
143 COMMENT "Size after generation:"
149 # Setup Loader Script
152 #| Provides the user with the correct teensy-loader-cli command for the built .HEX file
153 #| teensy-loader-cli must be in the user's path
154 if( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
155 configure_file( LoadFile/bash load )
159 if( ${CMAKE_SYSTEM_NAME} MATCHES "Windows" )
160 configure_file( LoadFile/bash load )