]> git.donarmstrong.com Git - kiibohd-controller.git/blob - CMakeLists.txt
Adding initial Teensy 3 support, compiles, but not fully functional yet.
[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 message( STATUS "Compiler Family:" )
34 message( "${COMPILER_FAMILY}" )
35
36
37
38 #| Load the compiler family specific configurations
39 include( ${COMPILER_FAMILY}.cmake )
40
41
42
43 ###
44 # Project Description
45 #
46
47 #| Project
48 project( kiibohd_controller )
49
50 #| Target Name (output name)
51 set( TARGET kiibohd )
52
53 #| General Settings
54 cmake_minimum_required( VERSION 2.8 )
55
56
57
58 ###
59 # Source Defines
60 #
61
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
64 #set( SRCS ./main.c )
65
66 #| Instead, include the module source selector
67 include( setup.cmake )
68 set( SRCS
69         main.c
70         ${COMPILER_SRCS}
71         ${SCAN_SRCS}
72         ${MACRO_SRCS}
73         ${USB_SRCS}
74         ${DEBUG_SRCS}
75 )
76
77
78
79 ###
80 # Build Targets
81 #
82
83 #| Create the .ELF file
84 set( TARGET_ELF ${TARGET}.elf )
85 add_executable( ${TARGET_ELF} ${SRCS} )
86
87
88 #| .ELF Properties
89 set_target_properties( ${TARGET_ELF} PROPERTIES
90         LINK_FLAGS ${LINKER_FLAGS}
91         SUFFIX ""                               # XXX Force Windows to keep the .exe off
92 )
93
94
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}"
100 )
101
102
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}"
108 )
109
110
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}"
116 )
117
118
119
120 ###
121 # Size Information
122 #
123
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:"
128 )
129
130
131
132 ###
133 # Setup Loader Script
134 #
135
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" )
141
142 #| TODO Windows
143 if( ${CMAKE_SYSTEM_NAME} MATCHES "Windows" )
144         configure_file( LoadFile/bash load )
145 endif( ${CMAKE_SYSTEM_NAME} MATCHES "Windows" )
146