]> git.donarmstrong.com Git - kiibohd-controller.git/blob - CMakeLists.txt
Updating CMake build system to prepare for Teensy 3 integration.
[kiibohd-controller.git] / CMakeLists.txt
1 ###| CMAKE Kiibohd Controller |###
2 #
3 # Jacob Alexander 2011-2013
4 # Due to this file's usefulness:
5 #
6 # Released into the Public Domain
7 #
8 ###
9
10 #| Windows / Cygwin Compatibility options
11 set( CMAKE_LEGACY_CYGWIN_WIN32 0 )
12 set( CMAKE_USE_RELATIVE_PATHS  1 )
13
14 #| Add Dependency Macro
15 include( AddFileDependencies )
16
17
18
19 ###
20 # Compiler Family
21 #
22
23 #| Specify the compiler family to use
24 #| Currently only supports AVR and ARM
25 #| "avr"       # Teensy   1.0
26 #| "avr"       # Teensy   2.0
27 #| "avr"       # Teensy++ 1.0
28 #| "avr"       # Teensy++ 2.0
29 #| "arm"       # Teensy   3.0
30 #set( COMPILER_FAMILY "arm" )
31 set( COMPILER_FAMILY "avr" )
32
33
34
35 #| Load the compiler family specific configurations
36 include( ${COMPILER_FAMILY}.cmake )
37
38
39
40 ###
41 # Project Description
42 #
43
44 #| Project
45 project( kiibohd_controller )
46
47 #| Target Name (output name)
48 set( TARGET kiibohd )
49
50 #| General Settings
51 cmake_minimum_required( VERSION 2.8 )
52
53
54
55 ###
56 # Source Defines
57 #
58
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
61 #set( SRCS ./main.c )
62
63 #| Instead, include the module source selector
64 include( setup.cmake )
65 set( SRCS
66         main.c
67         ${COMPILER_SRCS}
68         ${SCAN_SRCS}
69         ${MACRO_SRCS}
70         ${USB_SRCS}
71         ${DEBUG_SRCS}
72 )
73
74
75
76 ###
77 # Build Targets
78 #
79
80 #| Create the .ELF file
81 set( TARGET_ELF ${TARGET}.elf )
82 add_executable( ${TARGET_ELF} ${SRCS} )
83
84
85 #| .ELF Properties
86 set_target_properties( ${TARGET_ELF} PROPERTIES
87         LINK_FLAGS ${LINKER_FLAGS}
88         SUFFIX ""                               # XXX Force Windows to keep the .exe off
89 )
90
91
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}"
97 )
98
99
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}"
105 )
106
107
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}"
113 )
114
115
116
117 ###
118 # Size Information
119 #
120
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:"
125 )
126
127
128
129 ###
130 # Setup Loader Script
131 #
132
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" )
138
139 #| TODO Windows
140 if( ${CMAKE_SYSTEM_NAME} MATCHES "Windows" )
141         configure_file( LoadFile/bash load )
142 endif( ${CMAKE_SYSTEM_NAME} MATCHES "Windows" )
143