cmake: enable extra compiler checks
authorPetr Štetiar <ynezz@true.cz>
Tue, 8 Dec 2020 16:23:36 +0000 (17:23 +0100)
committerPetr Štetiar <ynezz@true.cz>
Fri, 11 Dec 2020 10:17:22 +0000 (11:17 +0100)
Let's enforce additional automatic checks enforced by the compiler in
order to catch possible errors during compilation.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
CMakeLists.txt

index f0388ab..07796a6 100644 (file)
@@ -3,7 +3,12 @@ cmake_minimum_required(VERSION 2.6)
 INCLUDE(CheckIncludeFiles)
 
 PROJECT(uclient C)
 INCLUDE(CheckIncludeFiles)
 
 PROJECT(uclient C)
-ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations)
+ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3)
+IF(CMAKE_C_COMPILER_VERSION VERSION_GREATER 6)
+        ADD_DEFINITIONS(-Wextra -Werror=implicit-function-declaration)
+        ADD_DEFINITIONS(-Wformat -Werror=format-security -Werror=format-nonliteral)
+ENDIF()
+ADD_DEFINITIONS(-Wno-unused-parameter -Wmissing-declarations)
 
 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
 
 
 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")