mkleemann / cmake-avr

cmake toolchain for AVR
Other
174 stars 61 forks source link

Fix multiple use of add_avr_executable #18

Closed klaussnd closed 5 years ago

klaussnd commented 5 years ago

This PR fixes problems when using add_avr_executable more than once by disambiguating targets with the same name.

Currently, when adding several images, you get:

Make Error at generic-gcc-avr.cmake:224 (add_custom_target):
  add_custom_target cannot create target "upload_eeprom" because another
  target with the same name already exists.  The existing target is a custom
  target created in source directory "...".
  See documentation for policy CMP0002 for more details.

The problem was solved in several steps:

  1. The target upload_eeprom was renamed upload_${EXECUTABLE_NAME}_eeprom
  2. The targets get_status, get_fuses, set_fuses, get_calibration, and set_calibration were moved inside a new function, since they are stand-alone and don't depend on the executable target. The user has to explicitly call avr_generate_fixed_targets().

Please note that this PR changes the usage.