X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=CMakeLists.txt;h=1f14bbdc58c2133fce4766aed058e715facf242b;hb=6dfeffd9cad508817757d1afaba4ab0901cc9786;hp=44b914121d507cfc581458ca7d12e5668f015477;hpb=8f8de985c569a5be44f2996cc4696c511a4a3378;p=kiibohd-controller.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 44b9141..1f14bbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,212 +1,154 @@ ###| CMAKE Kiibohd Controller |### # -# Written by Jacob Alexander in 2011 for the Kiibohd Controller +# Jacob Alexander 2011-2015 # Due to this file's usefulness: # # Released into the Public Domain # ### -#| Set the Compilers (must be set first) -include( CMakeForceCompiler ) -cmake_force_c_compiler ( avr-gcc AVRCCompiler ) -cmake_force_cxx_compiler( avr-g++ AVRCxxCompiler ) - - -#| Add Dependency Macro -include( AddFileDependencies ) ### -# Project Description +# Chip Selection # -#| Project -project( kiibohd_controller ) - -#| Target Name (output name) -set( TARGET kiibohd ) - -#| General Settings -cmake_minimum_required( VERSION 2.8 ) +#| You _MUST_ set this to match the microcontroller you are trying to compile for +#| You _MUST_ clean the build directory if you change this value +#| +set( CHIP +# "at90usb162" # Teensy 1.0 (avr) +# "atmega32u4" # Teensy 2.0 (avr) +# "at90usb646" # Teensy++ 1.0 (avr) +# "at90usb1286" # Teensy++ 2.0 (avr) +# "mk20dx128" # Teensy 3.0 (arm) + "mk20dx128vlf5" # McHCK mk20dx128vlf5 +# "mk20dx256" # Teensy 3.1 (arm) +# "mk20dx256vlh7" # Kiibohd-dfu mk20dx256vlh7 + CACHE STRING "Microcontroller Chip" ) ### -# Source Defines +# Compiler Selection # -#| Sources (see setup.h for configuring in/away code blocks or other complete modules) -#| XXX Not set here in this project, see setup.cmake -#set( SRCS ./main.c ) - -#| Instead, include the module source selector -include( setup.cmake ) -set( SRCS - main.c - ${SCAN_SRCS} - ${MACRO_SRCS} - ${USB_SRCS} - ${DEBUG_SRCS} -) +#| *** EXPERIMENTAL *** +#| Stick with gcc unless you know what you're doing +#| Currently only arm is supported with clang +set( COMPILER + "gcc" # arm-none-eabi-gcc / avr-gcc - Default +# "clang" # arm-none-eabi + CACHE STRING "Compiler Type" ) ### -# Atmel Defines and Linker Options +# Compiler Intialization # - -#| MCU Name -#| You _MUST_ set this to match the board you are using -#| type "make clean" after changing this, so all files will be rebuilt -#| -#| "at90usb162" # Teensy 1.0 -#| "atmega32u4" # Teensy 2.0 -#| "at90usb646" # Teensy++ 1.0 -#| "at90usb1286" # Teensy++ 2.0 -#set( MCU "atmega32u4" ) -set( MCU "at90usb1286" ) - - -#| Compiler flag to set the C Standard level. -#| c89 = "ANSI" C -#| gnu89 = c89 plus GCC extensions -#| c99 = ISO C99 standard (not yet fully implemented) -#| gnu99 = c99 plus GCC extensions -set( CSTANDARD "-std=gnu99" ) - - -#| Warning Options -#| -Wall...: warning level -set( WARN "-Wall -Wstrict-prototypes" ) - - -#| Tuning Options -#| -f...: tuning, see GCC manual and avr-libc documentation -set( TUNING "-funsigned-char -funsigned-bitfields -ffunction-sections -fpack-struct -fshort-enums" ) - - -#| Optimization level, can be [0, 1, 2, 3, s]. -#| 0 = turn off optimization. s = optimize for size. -#| (Note: 3 is not always the best optimization level. See avr-libc FAQ.) -set( OPT "s" ) - - -#| Output Format -#| srec, ihex, binary -set( FORMAT "ihex" ) - - -#| Processor frequency. -#| Normally the first thing your program should do is set the clock prescaler, -#| so your program will run at the correct speed. You should also set this -#| variable to same clock speed. The _delay_ms() macro uses this, and many -#| examples use this variable to calculate timings. Do not add a "UL" here. -set( F_CPU "16000000" ) - - -#| Dependency Files -#| Compiler flags to generate dependency files. -set( GENDEPFLAGS "-MMD -MP" ) +set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/Lib/CMake ) +include( initialize ) -#| Listing file -set( TARGET_LST ${TARGET}.lst ) +### +# Project Modules +# -#| Compiler Flags -add_definitions( "-mmcu=${MCU} -DF_CPU=${F_CPU} -O${OPT} ${TUNING} ${WARN} ${CSTANDARD} ${GENDEPFLAGS}" ) - - -#| Linker Flags -set( LINKER_FLAGS "-mmcu=${MCU} -Wl,-Map=${TARGET}.map,--cref -Wl,--relax -Wl,--gc-sections" ) - +#| Note: This is the only section you probably want to modify +#| Each module is defined by it's own folder (e.g. Scan/Matrix represents the "Matrix" module) +#| All of the modules must be specified, as they generate the sources list of files to compile +#| Any modifications to this file will cause a complete rebuild of the project -#| Hex Flags (XXX, CMake seems to have issues if you quote the arguments for the custom commands...) -set( HEX_FLAGS -O ${FORMAT} -R .eeprom -R .fuse -R .lock -R .signature ) +#| Please look at the {Scan,Macro,Output,Debug} for information on the modules and how to create new ones +##| Deals with acquiring the keypress information and turning it into a key index +set( ScanModule "MD1" + CACHE STRING "Scan Module" ) -#| Eep Flags -set( EEP_FLAGS -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ${FORMAT} ) +##| Provides the mapping functions for DefaultMap and handles any macro processing before sending to the OutputModule +set( MacroModule "PartialMap" + CACHE STRING "Macro Module" ) +##| Sends the current list of usb key codes through USB HID +set( OutputModule "pjrcUSB" + CACHE STRING "Output Module" ) -#| Lss Flags -set( LSS_FLAGS -h -S -z ) +##| Debugging source to use, each module has it's own set of defines that it sets +set( DebugModule "full" + CACHE STRING "Debug Module" ) ### -# Build Targets +# Keymap Configuration (do not include the .kll extension) # -#| Create the .ELF file -set( TARGET_ELF ${TARGET}.elf ) -add_executable( ${TARGET_ELF} ${SRCS} ) - - -#| .ELF Properties -set_target_properties( ${TARGET_ELF} PROPERTIES - LINK_FLAGS ${LINKER_FLAGS} -) - - -#| Convert the .ELF into a .HEX to load onto the Teensy -set( TARGET_HEX ${TARGET}.hex ) -add_custom_command( TARGET ${TARGET_ELF} POST_BUILD - COMMAND avr-objcopy ${HEX_FLAGS} ${TARGET_ELF} ${TARGET_HEX} - COMMENT "Creating load file for Flash: ${TARGET_HEX}" -) +#| Do not include the .kll extension +#| * BaseMap maps the native keyboard scan codes to USB Codes so the layout is compatible with all other layouts +#| * DefaultMap allows the default keymap to be modified from the BaseMap +#| * PartialMaps is a set of dynamically set layers (there is no limit, but too many may use up too much RAM...) +#| BaseMap generally does not need to be changed from "defaultMap" +#| +#| Syntax: +#| myMap +#| * defines a single .kll layout file, double-quotes are needed to distinguish between layers +#| "myMap specialLayer" +#| * defines myMap to be the main layout, then replace specialLayers on top of it +#| +#| - Only for PartialMaps - +#| "myMap specialLayer" "myMap colemak" dvorak +#| * As before, but also generates a second layer at index 2 and third at index 3 +#| +#| NOTE: Remember to add key(s) to enable each Partial Layer +#| NOTE2: Layers are always based up the BaseMap (which should be an ANSI-like mapping) +#| NOTE3: Compiler looks in kll/layouts and the build directory for layout files (precedence on build directory) +##| Set the base keyboard .kll map, defaults to "defaultMap" if not found +##| Looks in Scan/ for the available BaseMaps +set( BaseMap "defaultMap" + CACHE STRING "KLL BaseMap/Scancode Keymapping" ) -#| Convert the .ELF into a .EEP -set( TARGET_EEP ${TARGET}.eep ) -add_custom_command( TARGET ${TARGET_ELF} POST_BUILD - COMMAND avr-objcopy ${EEP_FLAGS} ${TARGET_ELF} ${TARGET_EEP} - COMMENT "Creating load file for EEPROM: ${TARGET_EEP}" -) +##| Layer additonal .kll maps on the BaseMap, layers are in order from 1st to nth +##| Can be set to "" +set( DefaultMap "md1Overlay stdFuncMap" + CACHE STRING "KLL DefaultMap" ) +##| ParitalMaps available on top of the BaseMap. See above for syntax on specifying multiple layers vs. layering +##| Can be set to "" +set( PartialMaps "hhkbpro2" + CACHE STRING "KLL PartialMaps/Layer Definitions" ) -#| Generate the Extended .LSS -set( TARGET_LSS ${TARGET}.lss ) -add_custom_command( TARGET ${TARGET_ELF} POST_BUILD - COMMAND avr-objdump ${LSS_FLAGS} ${TARGET_ELF} > ${TARGET_LSS} - COMMENT "Creating Extended Listing: ${TARGET_LSS}" -) -#| Generate the Symbol Table .SYM -set( TARGET_SYM ${TARGET}.sym ) -add_custom_command( TARGET ${TARGET_ELF} POST_BUILD - COMMAND avr-nm -n ${TARGET_ELF} > ${TARGET_SYM} - COMMENT "Creating Symbol Table: ${TARGET_SYM}" +### +# Source Defines (in addition to the selected Modules) +# +set( MAIN_SRCS + main.c ) ### -# Size Information +# Project Description # -#| After Changes Size Information -add_custom_target( SizeAfter ALL avr-size --target=${FORMAT} ${TARGET_HEX} ${TARGET_ELF} - DEPENDS ${TARGET_ELF} - COMMENT "Size after generation:" -) +#| Project +project( kiibohd_controller ) +#| Target Name (output name) +set( TARGET kiibohd ) +#| General Settings +cmake_minimum_required( VERSION 2.8 ) -### -# Setup Loader Script -# -#| Provides the user with the correct teensy-loader-cli command for the built .HEX file -#| teensy-loader-cli must be in the user's path -if( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" ) - configure_file( LoadFile/bash load ) -endif( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" ) -#| TODO Windows -if( ${CMAKE_SYSTEM_NAME} MATCHES "Windows" ) - message( STATUS "Load Script is on my TODO List for Windows..." ) -endif( ${CMAKE_SYSTEM_NAME} MATCHES "Windows" ) +### +# Module Initialization / Compilation / Targets +# +include( modules ) +include( kll ) # Generate kll layouts if necessary +include( build )