-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Remove -Werror from default flags or give cmake option to avoid it #3447
Labels
Comments
Thanks for pointing this out. I completely agree and will get it removed. |
dinord
pushed a commit
that referenced
this issue
Jun 21, 2021
Remove -Werror from the CMake compiler flags We should not force warnings as errors on users. Sometimes compilers introduce new warnings which will break builds. Instead, we manually turn this flag on in our continuous integration scripts so we can catch these errors, but not force them on our users. Fixes #3447 PiperOrigin-RevId: 380241852
dinord
pushed a commit
that referenced
this issue
Jun 22, 2021
Remove -Werror from the CMake compiler flags We should not force warnings as errors on users. Sometimes compilers introduce new warnings which will break builds. Instead, we manually turn this flag on in our continuous integration scripts so we can catch these errors, but not force them on our users. Fixes #3447 PiperOrigin-RevId: 380241852
kmikolaj
pushed a commit
to kmikolaj/googletest
that referenced
this issue
Jun 28, 2022
Remove -Werror from the CMake compiler flags We should not force warnings as errors on users. Sometimes compilers introduce new warnings which will break builds. Instead, we manually turn this flag on in our continuous integration scripts so we can catch these errors, but not force them on our users. Fixes google#3447 PiperOrigin-RevId: 380241852
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Does the feature exist in the most recent commit?
No, the
-Werror
flag is included by default on master as of now:googletest/googletest/cmake/internal_utils.cmake
Lines 86 to 93 in 7153098
Why do we need this feature?
When building googletest/googlemock as part of another project (recommended best practice AFAIK), if that project is built with extremely pedantic warning flags, e.g. clang's
-Weverything
, then googletest will fail with errors rather than warnings. It is desirable for the project to finish building so all warning can be collected. googletest failing part way through due to-Werror
prevents this.Describe the proposal
In my opinion, googletest should not set -Werror in its cmake logic. The user (developer on local machine, CI infrastructure, CD infrastructure) can enable this with
export CXXFLAGS=-Werror
(andexport CFLAGS=-Werror
if needed) or with an argument to cmake-DCMAKE_CXX_FLAGS=-Werror
. The opposite is not true, however (AFAIK), because though you can disable individual warnings as errors with-Wno-error=...
, there is no-werror
or-Wno-error=all
or something like that. If there is, then that would probably be a sufficient workaround, and I'd appreciate anyone who could point out how to do that to me.However, if there is no desire to change existing infrastructure, then I'd request a way to influence googletest to not include this flag, likely by having a cmake build option like
GOOGLE_TEST_INCLUDE_W_ERROR
and have it default to true. This would allow a project to prevent google test from adding that flag when usingExternalProject_Add
, for example.Without either removing the flag altogether, or a build option to prevent it, the only alternative I can think of is patching googletest before compiling, again you could do this with
ExternalProject_Add
, but that is fragile when upgrading to newer versions of googletest, and therefore a burden to maintain.Is the feature specific to an operating system, compiler, or build system version?
It was added in 1ded831.
It is specific to CMake, and it appears to be specific to clang and gcc:
googletest/googletest/cmake/internal_utils.cmake
Lines 86 to 87 in 7153098
googletest/googletest/cmake/internal_utils.cmake
Lines 92 to 93 in 7153098
The text was updated successfully, but these errors were encountered: