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 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. ###| CMAKE Kiibohd Controller |###
  2. #
  3. # Jacob Alexander 2011-2014
  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. ###
  13. # Compiler Family
  14. #
  15. #| Specify the compiler family to use
  16. #| Currently only supports AVR and ARM
  17. #| "avr" # Teensy 1.0
  18. #| "avr" # Teensy 2.0
  19. #| "avr" # Teensy++ 1.0
  20. #| "avr" # Teensy++ 2.0
  21. #| "arm" # Teensy 3.0
  22. #| "arm" # Teensy 3.1
  23. #set( COMPILER_FAMILY "arm" )
  24. set( COMPILER_FAMILY "avr" )
  25. message( STATUS "Compiler Family:" )
  26. message( "${COMPILER_FAMILY}" )
  27. #| Load the compiler family specific configurations
  28. include( ${COMPILER_FAMILY}.cmake )
  29. #| Binutils not set by CMake
  30. set( CMAKE_SIZE "${_CMAKE_TOOLCHAIN_PREFIX}size" )
  31. ###
  32. # Project Description
  33. #
  34. #| Project
  35. project( kiibohd_controller )
  36. #| Target Name (output name)
  37. set( TARGET kiibohd )
  38. #| General Settings
  39. cmake_minimum_required( VERSION 2.8 )
  40. ###
  41. # Source Defines
  42. #
  43. #| Sources (see setup.h for configuring in/away code blocks or other complete modules)
  44. #| XXX Not set here in this project, see setup.cmake
  45. #set( SRCS ./main.c )
  46. #| Instead, include the module source selector
  47. include( setup.cmake )
  48. set( SRCS
  49. main.c
  50. ${COMPILER_SRCS}
  51. ${SCAN_SRCS}
  52. ${MACRO_SRCS}
  53. ${OUTPUT_SRCS}
  54. ${DEBUG_SRCS}
  55. )
  56. #| Directories to include by default
  57. include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} )
  58. ###
  59. # Module Compatibility Check
  60. #
  61. #| Check for whether the set modules are compatible with the specified compiler family
  62. ModuleCompatibility( ${ScanModulePath} ${ScanModuleCompatibility} )
  63. ModuleCompatibility( ${MacroModulePath} ${MacroModuleCompatibility} )
  64. ModuleCompatibility( ${OutputModulePath} ${OutputModuleCompatibility} )
  65. ModuleCompatibility( ${DebugModulePath} ${DebugModuleCompatibility} )
  66. ###
  67. # CMake Module Checking
  68. #
  69. find_package( Git REQUIRED )
  70. ###
  71. # Build Targets
  72. #
  73. #| Create the .ELF file
  74. set( TARGET_ELF ${TARGET}.elf )
  75. add_executable( ${TARGET_ELF} ${SRCS} )
  76. #| .ELF Properties
  77. set_target_properties( ${TARGET_ELF} PROPERTIES
  78. LINK_FLAGS ${LINKER_FLAGS}
  79. SUFFIX "" # XXX Force Windows to keep the .exe off
  80. )
  81. #| Convert the .ELF into a .HEX to load onto the Teensy
  82. set( TARGET_HEX ${TARGET}.hex )
  83. add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
  84. COMMAND ${CMAKE_OBJCOPY} ${HEX_FLAGS} ${TARGET_ELF} ${TARGET_HEX}
  85. COMMENT "Creating load file for Flash: ${TARGET_HEX}"
  86. )
  87. #| Generate the Extended .LSS
  88. set( TARGET_LSS ${TARGET}.lss )
  89. add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
  90. COMMAND ${CMAKE_OBJDUMP} ${LSS_FLAGS} ${TARGET_ELF} > ${TARGET_LSS}
  91. COMMENT "Creating Extended Listing: ${TARGET_LSS}"
  92. )
  93. #| Generate the Symbol Table .SYM
  94. set( TARGET_SYM ${TARGET}.sym )
  95. add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
  96. COMMAND ${CMAKE_NM} -n ${TARGET_ELF} > ${TARGET_SYM}
  97. COMMENT "Creating Symbol Table: ${TARGET_SYM}"
  98. )
  99. ###
  100. # Size Information
  101. #
  102. #| After Changes Size Information
  103. #| TODO Do lookup on Flash and RAM sizes and do % used
  104. add_custom_target( SizeAfter ALL
  105. COMMAND ${CMAKE_SIZE} --target=${FORMAT} ${TARGET_HEX} ${TARGET_ELF}
  106. DEPENDS ${TARGET_ELF}
  107. COMMENT "Size after generation\n\tFlash Usage: data (hex)\n\t RAM Usage: data (elf)"
  108. )
  109. ###
  110. # Setup Loader Script and Program
  111. #
  112. #| Provides the user with the correct teensy-loader-cli command for the built .HEX file
  113. #| Windows
  114. if( CMAKE_SYSTEM_NAME MATCHES "Windows" )
  115. configure_file( LoadFile/winload load NEWLINE_STYLE UNIX )
  116. #| Default
  117. else()
  118. configure_file( LoadFile/load load NEWLINE_STYLE UNIX )
  119. endif()