1 ###| CMAKE Kiibohd Controller |###
3 # Jacob Alexander 2011-2014
4 # Due to this file's usefulness:
6 # Released into the Public Domain
8 # Freescale ARM CMake Build Configuration
14 #| Set the Compilers (must be set first)
15 include( CMakeForceCompiler )
16 cmake_force_c_compiler ( arm-none-eabi-gcc ARMCCompiler )
17 cmake_force_cxx_compiler( arm-none-eabi-g++ ARMCxxCompiler )
18 set( _CMAKE_TOOLCHAIN_PREFIX arm-none-eabi- )
23 # ARM Defines and Linker Options
28 #| "mk20dx128" # Teensy 3.0
29 #| "mk20dx256" # Teensy 3.1
31 message( STATUS "Chip Selected:" )
33 set( MCU "${CHIP}" ) # For loading script compatibility
37 #| Automatically chosed based on the chip name.
38 if ( "${CHIP}" MATCHES "^mk20dx.*$" )
39 set( CHIP_FAMILY "mk20dx" )
40 message( STATUS "Chip Family:" )
41 message( "${CHIP_FAMILY}" )
43 message( FATAL_ERROR "Unknown chip family: ${CHIP}" )
48 #| You _MUST_ set this to match the board you are using
49 #| type "make clean" after changing this, so all files will be rebuilt
51 #| "cortex-m4" # Teensy 3.0, 3.1
52 set( CPU "cortex-m4" )
54 message( STATUS "CPU Selected:" )
58 #| Extra Compiler Sources
59 #| Mostly for convenience functions like interrupt handlers
65 message( STATUS "Compiler Source Files:" )
66 message( "${COMPILER_SRCS}" )
70 set( VENDOR_ID "0x16C0" )
71 set( PRODUCT_ID "0x0487" )
74 #| Compiler flag to set the C Standard level.
76 #| gnu89 = c89 plus GCC extensions
77 #| c99 = ISO C99 standard (not yet fully implemented)
78 #| gnu99 = c99 plus GCC extensions
79 set( CSTANDARD "-std=gnu99" )
83 #| -Wall...: warning level
84 set( WARN "-Wall -g" )
88 #| -f...: tuning, see GCC manual
89 #| NOTE: -fshort-wchar is specified to allow USB strings be passed conveniently
90 set( TUNING "-mthumb -nostdlib -fdata-sections -ffunction-sections -fshort-wchar" )
93 #| Optimization level, can be [0, 1, 2, 3, s].
94 #| 0 = turn off optimization. s = optimize for size.
95 #| (Note: 3 is not always the best optimization level.)
100 #| srec, ihex, binary
104 #| Processor frequency.
105 #| Normally the first thing your program should do is set the clock prescaler,
106 #| so your program will run at the correct speed. You should also set this
107 #| variable to same clock speed. The _delay_ms() macro uses this, and many
108 #| examples use this variable to calculate timings. Do not add a "UL" here.
109 set( F_CPU "48000000" )
113 #| Compiler flags to generate dependency files.
114 set( GENDEPFLAGS "-MMD" )
118 add_definitions( "-mcpu=${CPU} -DF_CPU=${F_CPU} -D_${CHIP}_=1 -O${OPT} ${TUNING} ${WARN} ${CSTANDARD} ${GENDEPFLAGS}" )
122 set( LINKER_FLAGS "-mcpu=${CPU} -Wl,-Map=${TARGET}.map,--cref -Wl,--gc-sections -mthumb -Wl,--no-wchar-size-warning -T${CMAKE_CURRENT_SOURCE_DIR}/Lib/${CHIP}.ld" )
125 #| Hex Flags (XXX, CMake seems to have issues if you quote the arguments for the custom commands...)
126 set( HEX_FLAGS -O ${FORMAT} -R .eeprom )
130 set( LSS_FLAGS -h -S -z )