Can't set compile flags per file or per project?

Are the developers aware of this and doing anything to allow this? Or did I miss how to do it? I saw a suggestion somewhere in the old version of a kludge to create alternate board definitions. Is that the only way?

There is a way to set flags from the command line when using Arduino CLI.

There are some examples of that here in the arduino-cli compile command documentation:

https://arduino.github.io/arduino-cli/latest/commands/arduino-cli_compile/

If you are interested in reading a lot of discussion about the subject in general, you can check this issue thread and all the related discussions linked off it:

you could define a board for the project. only boards.txt is required.
you can the ensure with #ifdef in the sketch that this board is selected in Tools menu.

1 Like

The issue for our team is that we really need to "globally modify X" when you want it "project specific". And with this method, all our mods would be gone with the next IDE upgrade. What would seem to be an important feature is to be able to compile file1.cpp with -03 and file2.cpp with a different setting without having to use pragma defines.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.