diff options
author | Florian Fainelli <f.fainelli@gmail.com> | 2018-09-11 17:14:19 -0700 |
---|---|---|
committer | Florian Fainelli <f.fainelli@gmail.com> | 2018-09-11 17:14:19 -0700 |
commit | 0059335c5b60c5623a894f08a090fdabd618afae (patch) | |
tree | 5f520f968696badaeb94abd537069266a202293c | |
parent | 7454d121090f60428777c01f431031059acc96eb (diff) |
CMakeList: Check that compiler supports -Wimplicit-fallthrough
This is a GCC >= 7 feature, not all compilers support it.
Fixes: 908a9f4f1027 ("CMakeLists.txt: add -Wimplicit-fallthrough to the compiler flags")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
-rw-r--r-- | CMakeLists.txt | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 50f62bd..d6203aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,17 @@ cmake_minimum_required(VERSION 2.6) PROJECT(netifd C) -ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -Wmissing-declarations -Wno-unknown-warning-option -Wno-format-truncation -Wimplicit-fallthrough) + +IF(NOT ${CMAKE_VERSION} LESS 3.0) + include(CheckCCompilerFlag) + check_c_compiler_flag(-Wimplicit-fallthrough HAS_IMPLICIT_FALLTHROUGH) +ENDIF() + +ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -Wmissing-declarations -Wno-unknown-warning-option -Wno-format-truncation) + +IF(HAS_IMPLICIT_FALLTHROUGH) + ADD_DEFINITIONS(-Wimplicit-fallthrough) +ENDIF() SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") |