comparison Lib/CMake/build.cmake @ 298:39f84a603350

Adding dfu-suffix signing support to build system - If dfu-suffix is not found, a warning is given and the binary is not signed - Unsigned binaries are still ok with the latest version of dfu-util
author Jacob Alexander <haata@kiibohd.com>
date Mon, 02 Mar 2015 01:58:53 -0800
parents 945ce4472602
children b5746c43904e
comparison
equal deleted inserted replaced
297:c86eb7d0a693 298:39f84a603350
1 ###| CMAKE Kiibohd Controller Source Configurator |### 1 ###| CMAKE Kiibohd Controller Source Configurator |###
2 # 2 #
3 # Written by Jacob Alexander in 2011-2014 for the Kiibohd Controller 3 # Written by Jacob Alexander in 2011-2015 for the Kiibohd Controller
4 # 4 #
5 # Released into the Public Domain 5 # Released into the Public Domain
6 # 6 #
7 ### 7 ###
8 8
44 set ( OBJ_COPY ${CMAKE_OBJCOPY} ) 44 set ( OBJ_COPY ${CMAKE_OBJCOPY} )
45 endif () 45 endif ()
46 46
47 47
48 #| Convert the .ELF into a .bin to load onto the McHCK 48 #| Convert the .ELF into a .bin to load onto the McHCK
49 #| Then sign using dfu-suffix (requries dfu-util)
49 if ( DEFINED DFU ) 50 if ( DEFINED DFU )
51 # dfu-suffix is required to sign the dfu binary
52 find_package ( DFUSuffix )
53
50 set( TARGET_BIN ${TARGET}.dfu.bin ) 54 set( TARGET_BIN ${TARGET}.dfu.bin )
51 add_custom_command( TARGET ${TARGET_ELF} POST_BUILD 55 if ( DFU_SUFFIX_FOUND )
52 COMMAND ${OBJ_COPY} ${BIN_FLAGS} ${TARGET_ELF} ${TARGET_BIN} 56 add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
53 COMMENT "Creating dfu binary file: ${TARGET_BIN}" 57 COMMAND ${OBJ_COPY} ${BIN_FLAGS} ${TARGET_ELF} ${TARGET_BIN}
54 ) 58 COMMAND ${DFU_SUFFIX_EXECUTABLE} --add ${TARGET_BIN} --vid ${BOOT_VENDOR_ID} --pid ${BOOT_PRODUCT_ID} 1> /dev/null
59 COMMENT "Create and sign dfu bin file: ${TARGET_BIN}"
60 )
61 else ()
62 message ( WARNING "DFU Binary has not been signed, requires dfu-suffix..." )
63 add_custom_command( TARGET ${TARGET_ELF} POST_BUILD
64 COMMAND ${OBJ_COPY} ${BIN_FLAGS} ${TARGET_ELF} ${TARGET_BIN}
65 COMMENT "Creating dfu binary file: ${TARGET_BIN}"
66 )
67 endif ()
55 endif () 68 endif ()
56 69
57 70
58 #| Convert the .ELF into a .HEX to load onto the Teensy 71 #| Convert the .ELF into a .HEX to load onto the Teensy
59 if ( DEFINED TEENSY ) 72 if ( DEFINED TEENSY )