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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. ###| CMAKE Kiibohd Controller Bootloader |###
  2. #
  3. # Jacob Alexander 2011-2014
  4. # Due to this file's usefulness:
  5. #
  6. # Released into the Public Domain
  7. #
  8. # This bootloader is based upon the MCHCK dfu-usb bootloader.
  9. # DO NOT USE with Teensy based microcontrollers.
  10. #
  11. ###
  12. ###
  13. # Chip Selection
  14. #
  15. #| You _MUST_ set this to match the microcontroller you are trying to compile for
  16. #| You _MUST_ clean the build directory if you change this value
  17. #|
  18. set( CHIP
  19. "mk20dx128vlf5" # McHCK mk20dx128vlf5
  20. )
  21. ###
  22. # Bootloader Configuration
  23. #
  24. set ( BOOTLOADER 1 )
  25. ###
  26. # Compiler Intialization
  27. #
  28. set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/../Lib/CMake )
  29. include( initialize )
  30. ##
  31. # Source Defines
  32. #
  33. set( SRCS
  34. main.c
  35. dfu.c
  36. dfu.desc.c
  37. flash.c
  38. kinetis.c
  39. usb.c
  40. )
  41. message( STATUS "Bootloader Source Files:" )
  42. message( "${SRCS}" )
  43. #| Add Lib sources to main list
  44. foreach( SRC_FILE ${COMPILER_SRCS} )
  45. set( SRCS ${SRCS} ${CMAKE_SOURCE_DIR}/../${SRC_FILE} )
  46. endforeach()
  47. ###
  48. # Directory Includes
  49. #
  50. include_directories( ${CMAKE_SOURCE_DIR}/../Lib )
  51. ###
  52. # Project Description
  53. #
  54. #| Project
  55. project( kiibohd_bootloader )
  56. #| Target Name (output name)
  57. set( TARGET kiibohd_bootloader )
  58. #| General Settings
  59. cmake_minimum_required( VERSION 2.8 )
  60. ###
  61. # Generate Header Files
  62. #
  63. configure_file( _buildvars.h buildvars.h )
  64. include_directories( ${CMAKE_BINARY_DIR} )
  65. ###
  66. # CMake Module Checking
  67. #
  68. find_package( Git REQUIRED )
  69. find_package( Ctags ) # Optional
  70. ###
  71. # ctag Generation
  72. #
  73. if( CTAGS_EXECUTABLE )
  74. # Generate the ctags
  75. execute_process( COMMAND ctags ${SRCS}
  76. WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  77. )
  78. endif()
  79. ###
  80. # Disable -Wl,-search_paths_first for OSX (not supported by arm-none-eabi-gcc)
  81. #
  82. if ( APPLE )
  83. string ( REPLACE "-Wl,-search_paths_first" "" CMAKE_C_LINK_FLAGS ${CMAKE_C_LINK_FLAGS} )
  84. string ( REPLACE "-Wl,-search_paths_first" "" CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS} )
  85. message ( AUTHOR_WARNING "Bootloader binary may not fit on device (must be less than 4096 bytes). Macports arm-none-eabi-gcc 4.7.3 doesn't seem to work properly with -flto. However, even disabling it doesn't shrink the binary enough... 4.9.1 is known to work on Arch Linux." )
  86. endif ()
  87. ###
  88. # Build Targets
  89. #
  90. #| Create the .ELF file
  91. set( TARGET_ELF ${TARGET}.elf )
  92. add_executable( ${TARGET_ELF} ${SRCS} )
  93. #| .ELF Properties
  94. set_target_properties( ${TARGET_ELF} PROPERTIES
  95. LINK_FLAGS ${LINKER_FLAGS}
  96. SUFFIX "" # XXX Force Windows to keep the .exe off
  97. )
  98. #| Convert the .ELF into a .bin to load onto the McHCK
  99. set( TARGET_BIN ${TARGET}.bin )
  100. add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
  101. COMMAND ${CMAKE_OBJCOPY} ${BIN_FLAGS} ${TARGET_ELF} ${TARGET_BIN}
  102. COMMENT "Creating binary file to load: ${TARGET_BIN}"
  103. )
  104. #| Generate the Extended .LSS
  105. set( TARGET_LSS ${TARGET}.lss )
  106. add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
  107. COMMAND ${CMAKE_OBJDUMP} ${LSS_FLAGS} ${TARGET_ELF} > ${TARGET_LSS}
  108. COMMENT "Creating Extended Listing: ${TARGET_LSS}"
  109. )
  110. #| Generate the Symbol Table .SYM
  111. set( TARGET_SYM ${TARGET}.sym )
  112. add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
  113. COMMAND ${CMAKE_NM} -n ${TARGET_ELF} > ${TARGET_SYM}
  114. COMMENT "Creating Symbol Table: ${TARGET_SYM}"
  115. )
  116. #| Compiler Selection Record
  117. add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
  118. COMMAND ${CMAKE_SOURCE_DIR}/../Lib/CMake/writer compiler ${COMPILER_FAMILY}
  119. )
  120. ###
  121. # Size Information
  122. #
  123. #| After Changes Size Information
  124. add_custom_target( SizeAfter ALL
  125. COMMAND ${CMAKE_SOURCE_DIR}/../Lib/CMake/sizeCalculator ${CMAKE_SIZE} ram ${TARGET_ELF} ${SIZE_RAM} " SRAM"
  126. COMMAND ${CMAKE_SOURCE_DIR}/../Lib/CMake/sizeCalculator ${CMAKE_SIZE} flash ${TARGET_ELF} ${SIZE_FLASH} "Flash"
  127. DEPENDS ${TARGET_ELF}
  128. COMMENT "Chip usage for ${CHIP}"
  129. )