-
Notifications
You must be signed in to change notification settings - Fork 212
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the avif_enable_warnings INTERFACE library #2327
Add the avif_enable_warnings INTERFACE library #2327
Conversation
8678b63
to
cab64fd
Compare
It collects all warning-related compiler options and macro definitions. Re-enable warnings on the apps (avifdec, avifenc, and avifgainmaputil). Warnings on the tests will be re-enabled separately. Note: We cannot use add_compile_options() to enable warnings, because add_compile_options() affects not only our own targets but also the external dependencies we bring in by FetchContent.
cab64fd
to
1c800d8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks to encapsulate the warnings in one target rather than relying on the generators in individual ones. I don't know if this matches the behavior entirely given the earlier comments about exporting the warnings to users of the targets (via add_subdirectory
?)
This pull request is modeled after the |
The goal is to not repeat the warning we set through the generator expression and |
Vincent: I can change As for using a macro or an interface library, it doesn't really matter. Are you suggesting a macro because it is a more elementary feature than an interface library? The tutorial you mentioned in #2323 (comment) also uses an interface library (named So far all the compile options and macro definitions in |
I think this may have been a regression introduced by #1819. I'm having a hard time finding documentation to confirm this, but it seems as though object libraries don't transitively propagate compiler flags to targets. When the target for the warning flags was changed from target_compile_options(avif_obj PUBLIC $<BUILD_INTERFACE:-Wall -Wextra -Wshorten-64-to-32>) would become target_compile_options(avif PUBLIC $<BUILD_INTERFACE:-Wall -Wextra -Wshorten-64-to-32>) One virtue of this approach, if it does in fact work, is that the warning flags are automatically applied to all targets, including tests, without any additional work. |
@fdintino Frankie: Thank you for the suggestion. The only compiler option that the avif library should propagate is
Note that foo.c is compiled with the Since multiple sources (including official CMake documentation) recommend that an interface library be used to enable warning options, I am going to switch to this approach. |
Also, object libraries do transitively propagate compiler flags to targets. That's why the source files in the avif_apps library, which is based on the avif_apps_obj object library, are also compiled with warnings enabled.
|
It collects all warning-related compiler options and macro definitions. Re-enable warnings on the apps (avifdec, avifenc, and avifgainmaputil).
Warnings on the tests will be re-enabled separately.
A partial fix for #2340.
Note: We cannot use add_compile_options() to enable warnings, because add_compile_options() affects not only our own targets but also the external dependencies we bring in by FetchContent.