Kiibohd Controller
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
Это архивный репозиторий. Вы можете его клонировать или просматривать файлы, но не вносить изменения или открывать задачи/запросы на слияние.

CMakeLists.txt 5.2KB

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