Kiibohd Controller
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

CMakeLists.txt 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. #| Windows / Cygwin Compatibility options
  10. set( CMAKE_LEGACY_CYGWIN_WIN32 0 )
  11. set( CMAKE_USE_RELATIVE_PATHS 1 )
  12. #| Add Dependency Macro
  13. include( AddFileDependencies )
  14. ###
  15. # Compiler Family
  16. #
  17. #| Specify the compiler family to use
  18. #| Currently only supports AVR and ARM
  19. #| "avr" # Teensy 1.0
  20. #| "avr" # Teensy 2.0
  21. #| "avr" # Teensy++ 1.0
  22. #| "avr" # Teensy++ 2.0
  23. #| "arm" # Teensy 3.0
  24. #set( COMPILER_FAMILY "arm" )
  25. set( COMPILER_FAMILY "avr" )
  26. #| Load the compiler family specific configurations
  27. include( ${COMPILER_FAMILY}.cmake )
  28. ###
  29. # Project Description
  30. #
  31. #| Project
  32. project( kiibohd_controller )
  33. #| Target Name (output name)
  34. set( TARGET kiibohd )
  35. #| General Settings
  36. cmake_minimum_required( VERSION 2.8 )
  37. ###
  38. # Source Defines
  39. #
  40. #| Sources (see setup.h for configuring in/away code blocks or other complete modules)
  41. #| XXX Not set here in this project, see setup.cmake
  42. #set( SRCS ./main.c )
  43. #| Instead, include the module source selector
  44. include( setup.cmake )
  45. set( SRCS
  46. main.c
  47. ${COMPILER_SRCS}
  48. ${SCAN_SRCS}
  49. ${MACRO_SRCS}
  50. ${USB_SRCS}
  51. ${DEBUG_SRCS}
  52. )
  53. ###
  54. # Build Targets
  55. #
  56. #| Create the .ELF file
  57. set( TARGET_ELF ${TARGET}.elf )
  58. add_executable( ${TARGET_ELF} ${SRCS} )
  59. #| .ELF Properties
  60. set_target_properties( ${TARGET_ELF} PROPERTIES
  61. LINK_FLAGS ${LINKER_FLAGS}
  62. SUFFIX "" # XXX Force Windows to keep the .exe off
  63. )
  64. #| Convert the .ELF into a .HEX to load onto the Teensy
  65. set( TARGET_HEX ${TARGET}.hex )
  66. add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
  67. COMMAND ${OBJCOPY} ${HEX_FLAGS} ${TARGET_ELF} ${TARGET_HEX}
  68. COMMENT "Creating load file for Flash: ${TARGET_HEX}"
  69. )
  70. #| Generate the Extended .LSS
  71. set( TARGET_LSS ${TARGET}.lss )
  72. add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
  73. COMMAND ${OBJDUMP} ${LSS_FLAGS} ${TARGET_ELF} > ${TARGET_LSS}
  74. COMMENT "Creating Extended Listing: ${TARGET_LSS}"
  75. )
  76. #| Generate the Symbol Table .SYM
  77. set( TARGET_SYM ${TARGET}.sym )
  78. add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
  79. COMMAND ${NM} -n ${TARGET_ELF} > ${TARGET_SYM}
  80. COMMENT "Creating Symbol Table: ${TARGET_SYM}"
  81. )
  82. ###
  83. # Size Information
  84. #
  85. #| After Changes Size Information
  86. add_custom_target( SizeAfter ALL ${SIZE} --target=${FORMAT} ${TARGET_HEX} ${TARGET_ELF}
  87. DEPENDS ${TARGET_ELF}
  88. COMMENT "Size after generation:"
  89. )
  90. ###
  91. # Setup Loader Script
  92. #
  93. #| Provides the user with the correct teensy-loader-cli command for the built .HEX file
  94. #| teensy-loader-cli must be in the user's path
  95. if( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
  96. configure_file( LoadFile/bash load )
  97. endif( ${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
  98. #| TODO Windows
  99. if( ${CMAKE_SYSTEM_NAME} MATCHES "Windows" )
  100. configure_file( LoadFile/bash load )
  101. endif( ${CMAKE_SYSTEM_NAME} MATCHES "Windows" )