-set_target_properties(carl9170.elf PROPERTIES COMPILE_FLAGS
- "${CARLFW_CFLAGS_EXTRA} ${CARLFW_CFLAGS_AGGRESSIVE} ${CARLFW_CFLAGS_WARNING}")
-set_target_properties(carl9170.elf PROPERTIES LINK_FLAGS "-Tcarl9170.lds")
-
-add_custom_target(
- carl9170.fw ALL
- ${OBJCOPY} --strip-unneeded -O binary -R .sram -R .eeprom -R .fwdsc carl9170.elf carl9170.fw
- DEPENDS carl9170.elf)
-
-
-add_custom_target(
- carl9170.dsc ALL
- ${OBJCOPY} --strip-unneeded -O binary -j .fwdsc carl9170.elf carl9170.dsc
- DEPENDS carl9170.elf)
-
+set_target_properties(carl9170.elf PROPERTIES COMPILE_FLAGS "${CARLFW_CFLAGS}")
+set_target_properties(carl9170.elf PROPERTIES LINK_FLAGS "${CARLFW_CFLAGS} -Wl,-Tcarl9170.lds")
+
+add_custom_target(firmware ALL)
+
+add_custom_command(
+ SOURCE carl9170.elf
+ COMMAND ${OBJCOPY}
+ ARGS --strip-unneeded -O binary -R .sram -R .eeprom -R .fwdsc carl9170.elf carl9170.bin
+ TARGET firmware
+ OUTPUTS carl9170.bin)
+
+add_custom_command(
+ SOURCE carl9170.elf
+ COMMAND ${OBJCOPY}
+ ARGS --strip-unneeded -O binary -j .fwdsc carl9170.elf carl9170.dsc
+ TARGET firmware
+ OUTPUTS carl9170.dsc)
+
+add_custom_command(
+ SOURCE firmware
+ TARGET firmware
+ COMMAND cat
+ ARGS "carl9170.bin" "carl9170.dsc" > "carl9170.fw"
+ DEPENDS carl9170.elf carl9170.bin carl9170.dsc
+ OUTPUTS carl9170.fw)
+
+SET_DIRECTORY_PROPERTIES(
+ PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "carl9170.fw")