mkleemann / cmake-avr

cmake toolchain for AVR
Other
174 stars 61 forks source link

Changing config variables does not affect building #1

Closed nbars closed 9 years ago

nbars commented 9 years ago

Hey,

first of all I want to thank you for the grate project.

But i think there is a bug: The variables (e.g. AVR_MCU) defined at the top of the CmakeLists file inside the root directory are never used.

I think this is because the tool chain file, which is passed with "-DCMAKE_TOOLCHAIN_FILE=../../generic-gcc-avr.cmake is parsed right after the project() call, but at this moment there are´t any variables set. Because of this the generic-gcc-avr.cmake script uses always the default values.

Steps to reproduce

  1. Clean build directory
  2. Run cmake
  3. make (look at the file names)
  4. Clean build directory
  5. Change AVR_MCU to atmega16
  6. Run cmake
  7. make (file name suffix is still atmega8)

Possible solution 1 Move the project() call to a position downwards. (Don´t know which variables will be used by the generic-gcc file... so it could be that we need to move the project() call anywhere else ?!) e.g.

set(AVR_UPLOADTOOL avrdude)
set(AVR_PROGRAMMER avrispmkII)
set(AVR_UPLOADTOOL_PORT usb)

set(AVR_MCU atmega16)
set(AVR_H_FUSE 0xd9)
set(AVR_L_FUSE 0xc3)

project(AVR-EXAMPLE)

2 Introduce a new parameter and manually include the generic-gcc-cmake file.

mkleemann commented 9 years ago

Thanks for finding the issue.

I'll go for the first proposal for now. I'll think about introducing also the second one as a possibility, but need a little more time to check if this is going to work in all environments.

See commit [https://github.com/mkleemann/cmake-avr/commit/08de87004a38170e4b71d4e2c2bc592cd27a8895].

mkleemann commented 9 years ago

Added notes about the avoidances. All possible solutions are now shown in the examples provided.