From bd09b51379ee1281cf94f94d2ca58b9658bb49e3 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 22 May 2017 11:08:10 +0200 Subject: [PATCH] Fix/workaround GCC bug about -Wno-implicit-fallthrough For some reason GCC-6 successfully compiles test program with -Wno-implicit-fallthrough passed via command line. It just silently ignores the unknown arguments which are starting with -Wno-. The issue is, if some other waning happens in the code, then GCC will complain about unknown -Wno- argument which is not supported by current GCC version. This makes some misleading warning prints about unknown command line argument when any other warning happens in code from extern/. --- CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2284146b3ab..5efe96df9e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1389,7 +1389,10 @@ if(CMAKE_COMPILER_IS_GNUCC) # flags to undo strict flags ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations) ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter) - ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_IMPLICIT_FALLTHROUGH -Wno-implicit-fallthrough) + + if(CMAKE_COMPILER_IS_GNUCC AND (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "7.0")) + ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_IMPLICIT_FALLTHROUGH -Wno-implicit-fallthrough) + endif() if(NOT APPLE) ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)