From 69a01b650ac6c48b46d72838188ec1a5ffc40765 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 11 Sep 2018 18:28:22 -0700 Subject: With llvm-gcc, just don't do -Wshorten-64-to-32. If you specify -Werror and -Wshorten-64-to-32, there does not appear to be any way to get llvm-gcc *NOT* to treat those warnings as errors - not with pragmas, and not even with -Wno-error=shorten-64-to-32. Change-Id: Ia82df3f548085cca8d187c4b43c02060b87f0542 Reviewed-on: https://code.wireshark.org/review/29620 Reviewed-by: Guy Harris --- CMakeLists.txt | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dab3f828e4..de23e91c22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -491,9 +491,24 @@ else() # ! MSVC -Wno-long-long -Wheader-guard -Wcomma - -Wshorten-64-to-32 ) + # + # For -Wshorten-64-to-32, Apple's llvm-gcc doesn't seem to support + # specifying -Werror and then specifying that -Wshorten-64-to-32 + # warnings should *not* be treated as errors - not with pragmas + # and not even with -Werror ... -Wshorten-64-to-32 ... + # -Wno-error=shorten-64-to-32. + # + # So we only add -Wshorten-64-to-32 if either 1) we're not building + # on/for Apple or 2) we're using Clang. + # + if ((NOT APPLE) OR CMAKE_C_COMPILER_ID MATCHES "Clang") + list(APPEND WIRESHARK_COMMON_FLAGS + -Wshorten-64-to-32 + ) + endif() + # # Code that may be worth looking into (coding practices) # @@ -736,24 +751,6 @@ if(NOT DISABLE_WERROR AND NOT ENABLE_EXTRA_COMPILER_WARNINGS) if (WERROR) set(WERROR_COMMON_FLAGS "-Werror") endif() - - # - # Apple's llvm-gcc appears not to support suppressing - # warnings with pragmas, so, if we're building on a Mac - # (we check for APPLE), and we're not using Clang, we - # suppress errors for some warnings that we can only - # remove by suppressing them, as they're in generated - # code. - # - # We have to do this *after* -Werror, otherwise the - # compiler decides -Werror means "never mind, make 'em - # all errors. - # - if (APPLE AND NOT CMAKE_C_COMPILER_ID MATCHES "Clang") - set(WERROR_COMMON_FLAGS - "${WERROR_COMMON_FLAGS} -Wno-error=shorten-64-to-32 -Wno-error=unused-function" - ) - endif() endif() endif() -- cgit v1.2.3