Mercurial > louis > kiibohd-controller
annotate Lib/CMake/arm.cmake @ 428:b5746c43904e
Fixing clang compilation and supporting clang-tidy
- clang.c includes necessary functions to make clang compiler work (tested on teensy 3.1)
- Added support code to generate a compile_commands.json for clang-tidy
* Updates the symlink whenever cmake or make is called (Unix OSs only)
author | Jacob Alexander <haata@kiibohd.com> |
---|---|
date | Fri, 04 Mar 2016 00:23:48 -0800 |
parents | 772f9bea482b |
children |
rev | line source |
---|---|
147
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
1 ###| CMAKE Kiibohd Controller |### |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
2 # |
428
b5746c43904e
Fixing clang compilation and supporting clang-tidy
Jacob Alexander <haata@kiibohd.com>
parents:
333
diff
changeset
|
3 # Jacob Alexander 2011-2016 |
147
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
4 # Due to this file's usefulness: |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
5 # |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
6 # Released into the Public Domain |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
7 # |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
8 # Freescale ARM CMake Build Configuration |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
9 # |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
10 ### |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
11 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
12 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
13 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
14 #| Set the Compilers (must be set first) |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
15 include( CMakeForceCompiler ) |
264
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
16 message( STATUS "Compiler Selected:" ) |
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
17 if ( "${COMPILER}" MATCHES "gcc" ) |
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
18 cmake_force_c_compiler ( arm-none-eabi-gcc ARMCCompiler ) |
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
19 cmake_force_cxx_compiler( arm-none-eabi-g++ ARMCxxCompiler ) |
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
20 set( _CMAKE_TOOLCHAIN_PREFIX arm-none-eabi- ) |
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
21 message( "gcc" ) |
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
22 elseif ( "${COMPILER}" MATCHES "clang" ) |
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
23 cmake_force_c_compiler ( clang ARMCCompiler ) |
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
24 cmake_force_cxx_compiler( clang++ ARMCxxCompiler ) |
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
25 set( _CMAKE_TOOLCHAIN_PREFIX llvm- ) |
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
26 message( "clang" ) |
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
27 else () |
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
28 message( AUTHOR_WARNING "COMPILER: ${COMPILER} - Unknown compiler selection" ) |
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
29 endif () |
147
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
30 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
31 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
32 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
33 ### |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
34 # ARM Defines and Linker Options |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
35 # |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
36 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
37 #| Chip Name (Linker) |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
38 #| |
263
9afed592bcb5
Preparing for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
260
diff
changeset
|
39 #| "mk20dx128vlf5" # McHCK / Kiibohd-dfu |
9afed592bcb5
Preparing for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
260
diff
changeset
|
40 #| "mk20dx256vlh7" # Kiibohd-dfu |
9afed592bcb5
Preparing for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
260
diff
changeset
|
41 #| "mk20dx128" # Teensy 3.0 |
147
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
42 #| "mk20dx256" # Teensy 3.1 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
43 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
44 message( STATUS "Chip Selected:" ) |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
45 message( "${CHIP}" ) |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
46 set( MCU "${CHIP}" ) # For loading script compatibility |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
47 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
48 |
333
772f9bea482b
Adding 72 MHz clock support for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
303
diff
changeset
|
49 #| Chip Size and CPU Frequency Database |
772f9bea482b
Adding 72 MHz clock support for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
303
diff
changeset
|
50 #| Processor frequency. |
772f9bea482b
Adding 72 MHz clock support for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
303
diff
changeset
|
51 #| Normally the first thing your program should do is set the clock prescaler, |
772f9bea482b
Adding 72 MHz clock support for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
303
diff
changeset
|
52 #| so your program will run at the correct speed. You should also set this |
772f9bea482b
Adding 72 MHz clock support for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
303
diff
changeset
|
53 #| variable to same clock speed. The _delay_ms() macro uses this, and many |
772f9bea482b
Adding 72 MHz clock support for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
303
diff
changeset
|
54 #| examples use this variable to calculate timings. Do not add a "UL" here. |
263
9afed592bcb5
Preparing for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
260
diff
changeset
|
55 #| MCHCK Based / Kiibohd-dfu |
192
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
56 if ( "${CHIP}" MATCHES "mk20dx128vlf5" ) |
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
57 set( SIZE_RAM 16384 ) |
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
58 set( SIZE_FLASH 126976 ) |
333
772f9bea482b
Adding 72 MHz clock support for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
303
diff
changeset
|
59 set( F_CPU "48000000" ) |
192
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
60 |
263
9afed592bcb5
Preparing for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
260
diff
changeset
|
61 #| Kiibohd-dfu |
9afed592bcb5
Preparing for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
260
diff
changeset
|
62 elseif ( "${CHIP}" MATCHES "mk20dx256vlh7" ) |
9afed592bcb5
Preparing for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
260
diff
changeset
|
63 set( SIZE_RAM 65536 ) |
9afed592bcb5
Preparing for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
260
diff
changeset
|
64 set( SIZE_FLASH 253952 ) |
333
772f9bea482b
Adding 72 MHz clock support for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
303
diff
changeset
|
65 set( F_CPU "72000000" ) |
263
9afed592bcb5
Preparing for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
260
diff
changeset
|
66 |
148
15814bf7b0cc
Adding chip usage display after build completion.
Jacob Alexander <haata@kiibohd.com>
parents:
147
diff
changeset
|
67 #| Teensy 3.0 |
192
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
68 elseif ( "${CHIP}" MATCHES "mk20dx128" ) |
148
15814bf7b0cc
Adding chip usage display after build completion.
Jacob Alexander <haata@kiibohd.com>
parents:
147
diff
changeset
|
69 set( SIZE_RAM 16384 ) |
15814bf7b0cc
Adding chip usage display after build completion.
Jacob Alexander <haata@kiibohd.com>
parents:
147
diff
changeset
|
70 set( SIZE_FLASH 131072 ) |
333
772f9bea482b
Adding 72 MHz clock support for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
303
diff
changeset
|
71 set( F_CPU "48000000" ) |
148
15814bf7b0cc
Adding chip usage display after build completion.
Jacob Alexander <haata@kiibohd.com>
parents:
147
diff
changeset
|
72 |
15814bf7b0cc
Adding chip usage display after build completion.
Jacob Alexander <haata@kiibohd.com>
parents:
147
diff
changeset
|
73 #| Teensy 3.1 |
15814bf7b0cc
Adding chip usage display after build completion.
Jacob Alexander <haata@kiibohd.com>
parents:
147
diff
changeset
|
74 elseif ( "${CHIP}" MATCHES "mk20dx256" ) |
15814bf7b0cc
Adding chip usage display after build completion.
Jacob Alexander <haata@kiibohd.com>
parents:
147
diff
changeset
|
75 set( SIZE_RAM 65536 ) |
15814bf7b0cc
Adding chip usage display after build completion.
Jacob Alexander <haata@kiibohd.com>
parents:
147
diff
changeset
|
76 set( SIZE_FLASH 262144 ) |
333
772f9bea482b
Adding 72 MHz clock support for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
303
diff
changeset
|
77 set( F_CPU "48000000" ) # XXX Also supports 72 MHz, but may requires code changes |
148
15814bf7b0cc
Adding chip usage display after build completion.
Jacob Alexander <haata@kiibohd.com>
parents:
147
diff
changeset
|
78 |
15814bf7b0cc
Adding chip usage display after build completion.
Jacob Alexander <haata@kiibohd.com>
parents:
147
diff
changeset
|
79 #| Unknown ARM |
15814bf7b0cc
Adding chip usage display after build completion.
Jacob Alexander <haata@kiibohd.com>
parents:
147
diff
changeset
|
80 else () |
15814bf7b0cc
Adding chip usage display after build completion.
Jacob Alexander <haata@kiibohd.com>
parents:
147
diff
changeset
|
81 message( AUTHOR_WARNING "CHIP: ${CHIP} - Unknown ARM microcontroller" ) |
15814bf7b0cc
Adding chip usage display after build completion.
Jacob Alexander <haata@kiibohd.com>
parents:
147
diff
changeset
|
82 endif () |
15814bf7b0cc
Adding chip usage display after build completion.
Jacob Alexander <haata@kiibohd.com>
parents:
147
diff
changeset
|
83 |
15814bf7b0cc
Adding chip usage display after build completion.
Jacob Alexander <haata@kiibohd.com>
parents:
147
diff
changeset
|
84 |
147
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
85 #| Chip Base Type |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
86 #| Automatically chosed based on the chip name. |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
87 if ( "${CHIP}" MATCHES "^mk20dx.*$" ) |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
88 set( CHIP_FAMILY "mk20dx" ) |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
89 message( STATUS "Chip Family:" ) |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
90 message( "${CHIP_FAMILY}" ) |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
91 else () |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
92 message( FATAL_ERROR "Unknown chip family: ${CHIP}" ) |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
93 endif () |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
94 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
95 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
96 #| CPU Type |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
97 #| You _MUST_ set this to match the board you are using |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
98 #| type "make clean" after changing this, so all files will be rebuilt |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
99 #| |
169
7962a42dbda0
Initial work for McHCK mk20dx128vlf5 port.
Jacob Alexander <haata@kiibohd.com>
parents:
148
diff
changeset
|
100 #| "cortex-m4" # Teensy 3.0, 3.1, McHCK |
147
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
101 set( CPU "cortex-m4" ) |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
102 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
103 message( STATUS "CPU Selected:" ) |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
104 message( "${CPU}" ) |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
105 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
106 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
107 #| Extra Compiler Sources |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
108 #| Mostly for convenience functions like interrupt handlers |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
109 set( COMPILER_SRCS |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
110 Lib/${CHIP_FAMILY}.c |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
111 Lib/delay.c |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
112 ) |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
113 |
428
b5746c43904e
Fixing clang compilation and supporting clang-tidy
Jacob Alexander <haata@kiibohd.com>
parents:
333
diff
changeset
|
114 #| Clang needs a few more functions for linking |
b5746c43904e
Fixing clang compilation and supporting clang-tidy
Jacob Alexander <haata@kiibohd.com>
parents:
333
diff
changeset
|
115 if ( "${COMPILER}" MATCHES "clang" ) |
b5746c43904e
Fixing clang compilation and supporting clang-tidy
Jacob Alexander <haata@kiibohd.com>
parents:
333
diff
changeset
|
116 set( COMPILER_SRCS ${COMPILER_SRCS} |
b5746c43904e
Fixing clang compilation and supporting clang-tidy
Jacob Alexander <haata@kiibohd.com>
parents:
333
diff
changeset
|
117 Lib/clang.c |
b5746c43904e
Fixing clang compilation and supporting clang-tidy
Jacob Alexander <haata@kiibohd.com>
parents:
333
diff
changeset
|
118 ) |
b5746c43904e
Fixing clang compilation and supporting clang-tidy
Jacob Alexander <haata@kiibohd.com>
parents:
333
diff
changeset
|
119 endif () |
b5746c43904e
Fixing clang compilation and supporting clang-tidy
Jacob Alexander <haata@kiibohd.com>
parents:
333
diff
changeset
|
120 |
147
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
121 message( STATUS "Compiler Source Files:" ) |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
122 message( "${COMPILER_SRCS}" ) |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
123 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
124 |
169
7962a42dbda0
Initial work for McHCK mk20dx128vlf5 port.
Jacob Alexander <haata@kiibohd.com>
parents:
148
diff
changeset
|
125 #| USB Defines, this is how the loader programs detect which type of chip base is used |
260
5dbe3bf2dc42
Adding more CMake log information.
Jacob Alexander <haata@kiibohd.com>
parents:
209
diff
changeset
|
126 message( STATUS "Bootloader Type:" ) |
263
9afed592bcb5
Preparing for mk20dx256vlh7
Jacob Alexander <haata@kiibohd.com>
parents:
260
diff
changeset
|
127 if ( "${CHIP}" MATCHES "mk20dx128vlf5" OR "${CHIP}" MATCHES "mk20dx256vlh7" ) |
192
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
128 set( VENDOR_ID "0x1C11" ) |
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
129 set( PRODUCT_ID "0xB04D" ) |
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
130 set( BOOT_VENDOR_ID "0x1C11" ) |
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
131 set( BOOT_PRODUCT_ID "0xB007" ) |
303
f9c406854bc2
Set DFU bootloader name
Rowan Decker <Smasher816@gmail.com>
parents:
264
diff
changeset
|
132 set( BOOT_DFU_ALTNAME "Kiibohd DFU" ) |
192
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
133 set( DFU 1 ) |
260
5dbe3bf2dc42
Adding more CMake log information.
Jacob Alexander <haata@kiibohd.com>
parents:
209
diff
changeset
|
134 message( "dfu" ) |
192
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
135 elseif ( "${CHIP}" MATCHES "mk20dx128" OR "${CHIP}" MATCHES "mk20dx256" ) |
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
136 set( VENDOR_ID "0x1C11" ) |
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
137 set( PRODUCT_ID "0xB04D" ) |
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
138 set( BOOT_VENDOR_ID "0x16c0" ) # TODO Double check, this is likely incorrect |
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
139 set( BOOT_PRODUCT_ID "0x0487" ) |
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
140 set( TEENSY 1 ) |
260
5dbe3bf2dc42
Adding more CMake log information.
Jacob Alexander <haata@kiibohd.com>
parents:
209
diff
changeset
|
141 message( "Teensy" ) |
169
7962a42dbda0
Initial work for McHCK mk20dx128vlf5 port.
Jacob Alexander <haata@kiibohd.com>
parents:
148
diff
changeset
|
142 endif () |
147
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
143 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
144 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
145 #| Compiler flag to set the C Standard level. |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
146 #| c89 = "ANSI" C |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
147 #| gnu89 = c89 plus GCC extensions |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
148 #| c99 = ISO C99 standard (not yet fully implemented) |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
149 #| gnu99 = c99 plus GCC extensions |
192
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
150 #| gnu11 = c11 plus GCC extensions |
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
151 set( CSTANDARD "-std=gnu11" ) |
147
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
152 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
153 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
154 #| Warning Options |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
155 #| -Wall...: warning level |
192
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
156 set( WARN "-Wall -ggdb3" ) |
147
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
157 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
158 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
159 #| Tuning Options |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
160 #| -f...: tuning, see GCC manual |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
161 #| NOTE: -fshort-wchar is specified to allow USB strings be passed conveniently |
192
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
162 if( BOOTLOADER ) |
209
e9fdef19a059
Fixing Mac OSX arm build options.
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
163 set( TUNING "-D_bootloader_ -Wno-main -msoft-float -mthumb -fplan9-extensions -ffunction-sections -fdata-sections -fno-builtin -fstrict-volatile-bitfields -flto -fno-use-linker-plugin -nostdlib" ) |
192
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
164 #set( TUNING "-mthumb -fdata-sections -ffunction-sections -fno-builtin -msoft-float -fstrict-volatile-bitfields -flto -fno-use-linker-plugin -fwhole-program -Wno-main -nostartfiles -fplan9-extensions -D_bootloader_" ) |
264
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
165 elseif ( "${COMPILER}" MATCHES "clang" ) |
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
166 set( TUNING "-target arm-none-eabi -mthumb -nostdlib -fdata-sections -ffunction-sections -fshort-wchar -fno-builtin" ) |
192
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
167 else() |
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
168 set( TUNING "-mthumb -nostdlib -fdata-sections -ffunction-sections -fshort-wchar -fno-builtin -nostartfiles" ) |
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
169 endif() |
147
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
170 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
171 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
172 #| Optimization level, can be [0, 1, 2, 3, s]. |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
173 #| 0 = turn off optimization. s = optimize for size. |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
174 #| (Note: 3 is not always the best optimization level.) |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
175 set( OPT "s" ) |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
176 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
177 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
178 #| Dependency Files |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
179 #| Compiler flags to generate dependency files. |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
180 set( GENDEPFLAGS "-MMD" ) |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
181 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
182 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
183 #| Compiler Flags |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
184 add_definitions( "-mcpu=${CPU} -DF_CPU=${F_CPU} -D_${CHIP}_=1 -O${OPT} ${TUNING} ${WARN} ${CSTANDARD} ${GENDEPFLAGS}" ) |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
185 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
186 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
187 #| Linker Flags |
192
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
188 if( BOOTLOADER ) |
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
189 # Bootloader linker flags |
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
190 set( LINKER_FLAGS "${TUNING} -Wl,--gc-sections -fwhole-program -T${CMAKE_CURRENT_SOURCE_DIR}/../Lib/${CHIP}.bootloader.ld -nostartfiles -Wl,-Map=link.map" ) |
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
191 else() |
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
192 # Normal linker flags |
209
e9fdef19a059
Fixing Mac OSX arm build options.
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
193 set( LINKER_FLAGS "${TUNING} -Wl,-Map=link.map,--cref -Wl,--gc-sections -Wl,--no-wchar-size-warning -T${CMAKE_CURRENT_SOURCE_DIR}/Lib/${CHIP}.ld" ) |
192
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
175
diff
changeset
|
194 endif() |
147
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
195 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
196 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
197 #| Hex Flags (XXX, CMake seems to have issues if you quote the arguments for the custom commands...) |
169
7962a42dbda0
Initial work for McHCK mk20dx128vlf5 port.
Jacob Alexander <haata@kiibohd.com>
parents:
148
diff
changeset
|
198 set( HEX_FLAGS -O ihex -R .eeprom ) |
7962a42dbda0
Initial work for McHCK mk20dx128vlf5 port.
Jacob Alexander <haata@kiibohd.com>
parents:
148
diff
changeset
|
199 |
7962a42dbda0
Initial work for McHCK mk20dx128vlf5 port.
Jacob Alexander <haata@kiibohd.com>
parents:
148
diff
changeset
|
200 |
7962a42dbda0
Initial work for McHCK mk20dx128vlf5 port.
Jacob Alexander <haata@kiibohd.com>
parents:
148
diff
changeset
|
201 #| Binary Flags |
7962a42dbda0
Initial work for McHCK mk20dx128vlf5 port.
Jacob Alexander <haata@kiibohd.com>
parents:
148
diff
changeset
|
202 set( BIN_FLAGS -O binary ) |
147
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
203 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
204 |
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
205 #| Lss Flags |
264
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
206 if ( "${COMPILER}" MATCHES "clang" ) |
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
207 set( LSS_FLAGS -section-headers -triple=arm-none-eabi ) |
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
208 else () |
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
209 set( LSS_FLAGS -h -S -z ) |
945ce4472602
Adding experimental clang compiler support for arm-none-eabi
Jacob Alexander <haata@kiibohd.com>
parents:
263
diff
changeset
|
210 endif () |
147
95da03b43860
Reorganizing CMake build system.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
211 |