cmake: use extra compiler warnings only on gcc6+
authorPetr Štetiar <ynezz@true.cz>
Tue, 26 Nov 2019 07:32:57 +0000 (08:32 +0100)
committerPetr Štetiar <ynezz@true.cz>
Sun, 1 Dec 2019 11:26:41 +0000 (12:26 +0100)
gcc version 4.8.4 (Ubuntu 14.04) and -Wextra produces following:

 json_script.c:124:3: error: missing initializer for field 'name' of 'struct blobmsg_policy' [-Werror=missing-field-initializers]

Reported-by: Jonas Gorski <jonas.gorski@gmail.com>
Signed-off-by: Petr Štetiar <ynezz@true.cz>
CMakeLists.txt

index b80d551c112ff7f24e87bc5df86b9aaeec40615e..da7d03c7fc213ea38fed65cd1d1217c948550320 100644 (file)
@@ -3,7 +3,12 @@ INCLUDE(CheckLibraryExists)
 INCLUDE(CheckFunctionExists)
 
 PROJECT(ubox C)
-ADD_DEFINITIONS(-Os -Wextra -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations -Wno-unused-parameter)
+
+ADD_DEFINITIONS(-Wall -Werror)
+IF(CMAKE_C_COMPILER_VERSION VERSION_GREATER 6)
+       ADD_DEFINITIONS(-Wextra)
+ENDIF()
+ADD_DEFINITIONS(-Os -std=gnu99 -g3 -Wmissing-declarations -Wno-unused-parameter)
 
 OPTION(BUILD_LUA "build Lua plugin" ON)
 OPTION(BUILD_EXAMPLES "build examples" ON)