Build flags for my code only

GreenGiant
Posts: 28
Joined: Tue Sep 10, 2019 7:22 am

Build flags for my code only

Postby GreenGiant » Fri Oct 01, 2021 9:27 am

Using:

Code: Select all

target_compile_options(${COMPONENT_LIB} PRIVATE -Wall -Wpedantic)
This is very handy however it flags issues with the IDF, which I don't really care about.

Is there an elegant way to confine the extra build flags to my project code/components ONLY and not IDF components, without needing to list all the source files as in:

Code: Select all

set_source_files_properties(<lots and lots of source files>.cpp
    PROPERTIES COMPILE_FLAGS
    -Wall -Wpedantic
)

GreenGiant
Posts: 28
Joined: Tue Sep 10, 2019 7:22 am

Re: Build flags for my code only

Postby GreenGiant » Wed Oct 06, 2021 9:05 am

Just to add the why...

With these two flags there are a LOT of warnings, particularly in the use of anonymous structs, e.g.:

Code: Select all

/home/simon/_esp4v3/esp-idf/components/soc/esp32/include/soc/gpio_struct.h:187:9: warning: ISO C++ prohibits anonymous structs [-Wpedantic]
         };
         ^
/home/simon/_esp4v3/esp-idf/components/soc/esp32/include/soc/gpio_struct.h:196:9: warning: ISO C++ prohibits anonymous structs [-Wpedantic]
         };
         ^
/home/simon/_esp4v3/esp-idf/components/soc/esp32/include/soc/gpio_struct.h:206:9: warning: ISO C++ prohibits anonymous structs [-Wpedantic]
         };
...you get the point.

I don't mind if the IDF is non compliant, but I want my code to be.

ESP_Sprite
Posts: 9723
Joined: Thu Nov 26, 2015 4:08 am

Re: Build flags for my code only

Postby ESP_Sprite » Thu Oct 07, 2021 2:56 am

AFAIK, the private option thing should work. Are you sure that your issue isn't that your component includes those headers you mention (indirectly)? In that case, they'll still be compiled with the options you set for your component; you'd possibly be able to work around that with some #pragma commands, though.

GreenGiant
Posts: 28
Joined: Tue Sep 10, 2019 7:22 am

Re: Build flags for my code only

Postby GreenGiant » Tue Oct 19, 2021 7:18 pm

Yep, that was exactly the issue, thanks. Pragmas have come to the rescue for now. Cheers

Who is online

Users browsing this forum: No registered users and 229 guests