Kiibohd Controller
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

CMakeLists.txt 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. ###| CMAKE Kiibohd Controller |###
  2. #
  3. # Written by Jacob Alexander in 2011 for the Kiibohd Controller
  4. # Due to this file's usefulness:
  5. #
  6. # Released into the Public Domain
  7. #
  8. ###
  9. #| Set the Compilers (must be set first)
  10. include( CMakeForceCompiler )
  11. set( CMAKE_SYSTEM_NAME Generic )
  12. cmake_force_c_compiler ( avr-gcc AVRCCompiler )
  13. cmake_force_cxx_compiler( avr-g++ AVRCxxCompiler )
  14. ###
  15. # Project Description
  16. #
  17. #| Project
  18. project( kiibohd_controller )
  19. #| Target Name (output name)
  20. set( TARGET kiibohd )
  21. #| General Settings
  22. cmake_minimum_required( VERSION 2.8 )
  23. ###
  24. # Source Defines
  25. #
  26. #| Sources
  27. set( SRCS
  28. ./main.c
  29. ./print.c
  30. ./usb_keyboard_debug.c
  31. ./scan_loop.c
  32. )
  33. ###
  34. # Atmel Defines and Linker Options
  35. #
  36. #| MCU Name
  37. #| You _MUST_ set this to match the board you are using
  38. #| type "make clean" after changing this, so all files will be rebuilt
  39. #|
  40. #| "at90usb162" # Teensy 1.0
  41. #| "atmega32u4" # Teensy 2.0
  42. #| "at90usb646" # Teensy++ 1.0
  43. #| "at90usb1286" # Teensy++ 2.0
  44. set( MCU "at90usb1286" )
  45. #| Compiler flag to set the C Standard level.
  46. #| c89 = "ANSI" C
  47. #| gnu89 = c89 plus GCC extensions
  48. #| c99 = ISO C99 standard (not yet fully implemented)
  49. #| gnu99 = c99 plus GCC extensions
  50. set( CSTANDARD "-std=gnu99" )
  51. #| Warning Options
  52. #| -Wall...: warning level
  53. set( WARN "-Wall -Wstrict-prototypes" )
  54. #| Tuning Options
  55. #| -f...: tuning, see GCC manual and avr-libc documentation
  56. set( TUNING "-funsigned-char -funsigned-bitfields -ffunction-sections -fpack-struct -fshort-enums" )
  57. #| Optimization level, can be [0, 1, 2, 3, s].
  58. #| 0 = turn off optimization. s = optimize for size.
  59. #| (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
  60. set( OPT "s" )
  61. #| Output Format
  62. #| srec, ihex, binary
  63. set( FORMAT "ihex" )
  64. #| Processor frequency.
  65. #| Normally the first thing your program should do is set the clock prescaler,
  66. #| so your program will run at the correct speed. You should also set this
  67. #| variable to same clock speed. The _delay_ms() macro uses this, and many
  68. #| examples use this variable to calculate timings. Do not add a "UL" here.
  69. set( F_CPU "16000000" )
  70. #| Dependency Files
  71. #| Compiler flags to generate dependency files.
  72. set( GENDEPFLAGS "-MMD -MP" )
  73. #| Listing file
  74. set( TARGET_LST ${TARGET}.lst )
  75. #| Compiler Flags
  76. add_definitions( "-mmcu=${MCU} -DF_CPU=${F_CPU} -O${OPT} ${TUNING} ${WARN} ${CSTANDARD} ${GENDEPFLAGS}" )
  77. #| Linker Flags
  78. set( LINKER_FLAGS "-mmcu=${MCU} -Wl,-Map=${TARGET}.map,--cref -Wl,--relax -Wl,--gc-sections" )
  79. #| Hex Flags (XXX, CMake seems to have issues if you quote the arguments for the custom commands...)
  80. set( HEX_FLAGS -O ${FORMAT} -R .eeprom -R .fuse -R .lock -R .signature )
  81. #| Eep Flags
  82. set( EEP_FLAGS -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O ${FORMAT} )
  83. #| Lss Flags
  84. set( LSS_FLAGS -h -S -z )
  85. ###
  86. # Build Targets
  87. #
  88. #| Create the .ELF file
  89. set( TARGET_ELF ${TARGET}.elf )
  90. add_executable( ${TARGET_ELF} ${SRCS} )
  91. #| .ELF Properties
  92. set_target_properties( ${TARGET_ELF} PROPERTIES
  93. LINK_FLAGS ${LINKER_FLAGS}
  94. )
  95. #| Convert the .ELF into a .HEX to load onto the Teensy
  96. set( TARGET_HEX ${TARGET}.hex )
  97. add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
  98. COMMAND avr-objcopy ${HEX_FLAGS} ${TARGET_ELF} ${TARGET_HEX}
  99. COMMENT "Creating load file for Flash: ${TARGET_HEX}"
  100. )
  101. #| Convert the .ELF into a .EEP
  102. set( TARGET_EEP ${TARGET}.eep )
  103. add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
  104. COMMAND avr-objcopy ${EEP_FLAGS} ${TARGET_ELF} ${TARGET_EEP}
  105. COMMENT "Creating load file for EEPROM: ${TARGET_EEP}"
  106. )
  107. #| Generate the Extended .LSS
  108. set( TARGET_LSS ${TARGET}.lss )
  109. add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
  110. COMMAND avr-objdump ${LSS_FLAGS} ${TARGET_ELF} > ${TARGET_LSS}
  111. COMMENT "Creating Extended Listing: ${TARGET_LSS}"
  112. )
  113. #| Generate the Symbol Table .SYM
  114. set( TARGET_SYM ${TARGET}.sym )
  115. add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
  116. COMMAND avr-nm -n ${TARGET_ELF} > ${TARGET_SYM}
  117. COMMENT "Creating Symbol Table: ${TARGET_SYM}"
  118. )
  119. ###
  120. # Size Information
  121. #
  122. #| After Changes Size Information
  123. add_custom_target( SizeAfter ALL avr-size --target=${FORMAT} ${TARGET_HEX} ${TARGET_ELF}
  124. DEPENDS ${TARGET_ELF}
  125. COMMENT "Size after generation:"
  126. )