DEV Community

Discussion on: CMake on STM32 | Episode 3: handle warnings in 3rd party files

Collapse
 
dancollins_171 profile image
Dan Collins

I figure you can probably add these files to a variable, allowing you to pass it to both the list of sources and this warning suppression? That way you only update your list of ST sources in one place :)

Collapse
 
pgradot profile image
Pierre Gradot • Edited

Hi!

I guess you can.

In this particular case, I was trying to be as simple as possible ;)

In general, I am not super fond of variables for list of files. Indeed, when a file is not found, CMake will raise the error where the variable is used, not where it is set. When you have multiple files in your build, it is sometimes painful to find the root of the issue. Hence, I use them when they really improve the code.

Also note that here I am selectively applying the options to some of ST's files, not all of them. If you use one variable with all ST's files, you will probably use more aggressive options, such as -w to silent all warnings.

Collapse
 
dancollins_171 profile image
Dan Collins

That's a good point, yeah. Explicit error suppression is nice in that way :)

Thanks again for a great series - I'm planning on having a play this evening.

Thread Thread
 
pgradot profile image
Pierre Gradot

And eventually, did you play? :)

Thread Thread
 
dancollins_171 profile image
Dan Collins

I did! I've got a blinky light running on the F7 discovery board. I'll be figuring out how to add features like generating a 'version.h' with git info, and perhaps having a per-file logging level. I used to use SCons for this, but I like how well supported / deployed CMake is.

Thread Thread
 
pgradot profile image
Pierre Gradot

I have generated such version.hpp files, but for SVN. I used stackoverflow.com/questions/378066...

For Git, there is cmake.org/cmake/help/latest/module... but there are less commands than with SVN. You will probably find tips on Stackoverflow ;)