From 41feaa17f3b1db488027d9754c02eda8a375f980 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 19 May 2022 10:33:02 +1000 Subject: Cleanup: suppress 'address' warnings for ./extern/glew Also add comments noting why some warnings shouldn't be added to strict-flags. --- CMakeLists.txt | 20 +++++++++++++++++++- extern/glew/CMakeLists.txt | 5 +++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 13f4e6b9cc4..c0ff56fb0f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -937,7 +937,10 @@ set(PLATFORM_CFLAGS) set(C_WARNINGS) set(CXX_WARNINGS) -# for gcc -Wno-blah-blah +# NOTE: These flags are intended for situations where where it's impractical to +# suppress warnings by modifying the code or for code which is maintained externally. +# For GCC this typically means adding `-Wno-*` arguments to negate warnings +# that are useful in the general case. set(C_REMOVE_STRICT_FLAGS) set(CXX_REMOVE_STRICT_FLAGS) @@ -1617,6 +1620,18 @@ if(CMAKE_COMPILER_IS_GNUCC) ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5) endif() + + #---------------------- + # Suppress Strict Flags + # + # Exclude the following warnings from this list: + # - `-Wno-address`: + # This can give useful hints that point to bugs/misleading logic. + # - `-Wno-strict-prototypes`: + # No need to support older C-style prototypes. + # + # If code in `./extern/` needs to suppress these flags that can be done on a case-by-case basis. + # flags to undo strict flags ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations) ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter) @@ -1672,6 +1687,9 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Clang") # ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_MACROS -Wunused-macros) # ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNUSED_MACROS -Wunused-macros) + #---------------------- + # Suppress Strict Flags + # flags to undo strict flags ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter) ADD_CHECK_C_COMPILER_FLAG(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable) diff --git a/extern/glew/CMakeLists.txt b/extern/glew/CMakeLists.txt index bd35fa81538..ce51c8b2f7b 100644 --- a/extern/glew/CMakeLists.txt +++ b/extern/glew/CMakeLists.txt @@ -7,6 +7,11 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") "-Wno-strict-prototypes" ) endif() +if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "12.1")) + add_c_flag( + "-Wno-address" + ) +endif() # MSVC's inliner is not having a happy time with glewIsSupported # causing this to be one of the most expensive things to build -- cgit v1.2.3