2011-09-28 08:47:50 +00:00
|
|
|
###| CMAKE Kiibohd Controller |###
|
|
|
|
#
|
2013-01-26 09:34:33 +00:00
|
|
|
# Jacob Alexander 2011-2013
|
2011-09-28 08:47:50 +00:00
|
|
|
# Due to this file's usefulness:
|
|
|
|
#
|
|
|
|
# Released into the Public Domain
|
|
|
|
#
|
|
|
|
###
|
|
|
|
|
2012-11-24 19:41:41 +00:00
|
|
|
#| Windows / Cygwin Compatibility options
|
|
|
|
set( CMAKE_LEGACY_CYGWIN_WIN32 0 )
|
|
|
|
set( CMAKE_USE_RELATIVE_PATHS 1 )
|
|
|
|
|
2013-01-26 09:34:33 +00:00
|
|
|
#| Add Dependency Macro
|
|
|
|
include( AddFileDependencies )
|
2012-11-24 19:41:41 +00:00
|
|
|
|
2011-09-28 08:47:50 +00:00
|
|
|
|
|
|
|
|
2013-01-26 09:34:33 +00:00
|
|
|
###
|
|
|
|
# Compiler Family
|
|
|
|
#
|
|
|
|
|
|
|
|
#| Specify the compiler family to use
|
|
|
|
#| Currently only supports AVR and ARM
|
|
|
|
#| "avr" # Teensy 1.0
|
|
|
|
#| "avr" # Teensy 2.0
|
|
|
|
#| "avr" # Teensy++ 1.0
|
|
|
|
#| "avr" # Teensy++ 2.0
|
|
|
|
#| "arm" # Teensy 3.0
|
2014-01-19 23:00:48 +00:00
|
|
|
set( COMPILER_FAMILY "arm" )
|
|
|
|
#set( COMPILER_FAMILY "avr" )
|
2013-01-26 09:34:33 +00:00
|
|
|
|
2013-01-26 20:43:59 +00:00
|
|
|
message( STATUS "Compiler Family:" )
|
|
|
|
message( "${COMPILER_FAMILY}" )
|
|
|
|
|
2013-01-26 09:34:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
#| Load the compiler family specific configurations
|
|
|
|
include( ${COMPILER_FAMILY}.cmake )
|
|
|
|
|
2011-11-13 10:04:44 +00:00
|
|
|
|
|
|
|
|
2011-09-29 03:37:19 +00:00
|
|
|
###
|
|
|
|
# Project Description
|
|
|
|
#
|
|
|
|
|
2011-09-28 08:47:50 +00:00
|
|
|
#| Project
|
|
|
|
project( kiibohd_controller )
|
|
|
|
|
2011-09-29 03:37:19 +00:00
|
|
|
#| Target Name (output name)
|
|
|
|
set( TARGET kiibohd )
|
2011-09-28 08:47:50 +00:00
|
|
|
|
|
|
|
#| General Settings
|
|
|
|
cmake_minimum_required( VERSION 2.8 )
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-29 03:37:19 +00:00
|
|
|
###
|
|
|
|
# Source Defines
|
|
|
|
#
|
2011-09-28 08:47:50 +00:00
|
|
|
|
2011-09-29 06:25:51 +00:00
|
|
|
#| 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 )
|
2011-11-13 10:04:44 +00:00
|
|
|
set( SRCS
|
|
|
|
main.c
|
2013-01-26 09:34:33 +00:00
|
|
|
${COMPILER_SRCS}
|
2011-11-13 10:04:44 +00:00
|
|
|
${SCAN_SRCS}
|
|
|
|
${MACRO_SRCS}
|
|
|
|
${USB_SRCS}
|
|
|
|
${DEBUG_SRCS}
|
|
|
|
)
|
2011-09-28 08:47:50 +00:00
|
|
|
|
2013-02-02 01:02:55 +00:00
|
|
|
#| Directories to include by default
|
|
|
|
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
|
|
|
|
|
2011-09-28 08:47:50 +00:00
|
|
|
|
|
|
|
|
2013-01-30 23:13:49 +00:00
|
|
|
###
|
|
|
|
# Module Compatibility Check
|
|
|
|
#
|
|
|
|
|
|
|
|
#| Check for whether the set modules are compatible with the specified compiler family
|
|
|
|
ModuleCompatibility( ${ScanModulePath} ${ScanModuleCompatibility} )
|
|
|
|
ModuleCompatibility( ${MacroModulePath} ${MacroModuleCompatibility} )
|
|
|
|
ModuleCompatibility( ${USBModulePath} ${USBModuleCompatibility} )
|
|
|
|
ModuleCompatibility( ${DebugModulePath} ${DebugModuleCompatibility} )
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-29 03:37:19 +00:00
|
|
|
###
|
|
|
|
# Build Targets
|
|
|
|
#
|
2011-09-28 08:47:50 +00:00
|
|
|
|
|
|
|
#| 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}
|
2012-11-24 19:41:41 +00:00
|
|
|
SUFFIX "" # XXX Force Windows to keep the .exe off
|
2011-09-28 08:47:50 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
#| Convert the .ELF into a .HEX to load onto the Teensy
|
|
|
|
set( TARGET_HEX ${TARGET}.hex )
|
|
|
|
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
|
2013-01-26 09:34:33 +00:00
|
|
|
COMMAND ${OBJCOPY} ${HEX_FLAGS} ${TARGET_ELF} ${TARGET_HEX}
|
2011-09-28 08:47:50 +00:00
|
|
|
COMMENT "Creating load file for Flash: ${TARGET_HEX}"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2011-09-29 03:37:19 +00:00
|
|
|
#| Generate the Extended .LSS
|
2011-09-28 08:47:50 +00:00
|
|
|
set( TARGET_LSS ${TARGET}.lss )
|
|
|
|
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
|
2013-01-26 09:34:33 +00:00
|
|
|
COMMAND ${OBJDUMP} ${LSS_FLAGS} ${TARGET_ELF} > ${TARGET_LSS}
|
2011-09-28 08:47:50 +00:00
|
|
|
COMMENT "Creating Extended Listing: ${TARGET_LSS}"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
#| Generate the Symbol Table .SYM
|
|
|
|
set( TARGET_SYM ${TARGET}.sym )
|
|
|
|
add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
|
2013-01-26 09:34:33 +00:00
|
|
|
COMMAND ${NM} -n ${TARGET_ELF} > ${TARGET_SYM}
|
2011-09-28 08:47:50 +00:00
|
|
|
COMMENT "Creating Symbol Table: ${TARGET_SYM}"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-09-29 03:37:19 +00:00
|
|
|
###
|
|
|
|
# Size Information
|
|
|
|
#
|
2011-09-28 08:47:50 +00:00
|
|
|
|
|
|
|
#| After Changes Size Information
|
2013-01-26 09:34:33 +00:00
|
|
|
add_custom_target( SizeAfter ALL ${SIZE} --target=${FORMAT} ${TARGET_HEX} ${TARGET_ELF}
|
2011-09-28 08:47:50 +00:00
|
|
|
DEPENDS ${TARGET_ELF}
|
|
|
|
COMMENT "Size after generation:"
|
|
|
|
)
|
|
|
|
|
2011-09-30 05:22:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
###
|
|
|
|
# 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 )
|
2013-02-02 02:19:31 +00:00
|
|
|
endif()
|
2011-09-30 05:22:19 +00:00
|
|
|
|
|
|
|
#| TODO Windows
|
|
|
|
if( ${CMAKE_SYSTEM_NAME} MATCHES "Windows" )
|
2012-11-24 19:41:41 +00:00
|
|
|
configure_file( LoadFile/bash load )
|
2013-02-02 02:19:31 +00:00
|
|
|
endif()
|
2011-09-30 05:22:19 +00:00
|
|
|
|