cmake: enable extra compiler checks
authorHans Dedecker <dedeckeh@gmail.com>
Sat, 3 Apr 2021 18:28:11 +0000 (20:28 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Sat, 3 Apr 2021 18:50:12 +0000 (20:50 +0200)
Let's catch enforced compiler errors during compilation

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
CMakeLists.txt

index a5b0cb397e0965550fb5710b62165e06c3a598db..94f279cc589caf1acbc96285fcc5ace4adb7730d 100644 (file)
@@ -4,8 +4,13 @@ cmake_policy(SET CMP0015 NEW)
 # Project Definition
 project(odhcp6c C)
 set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -std=c99")
-add_definitions(-D_GNU_SOURCE -Wall -Werror -Wextra -pedantic)
+set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3 -std=c99")
+add_definitions(-D_GNU_SOURCE -Os -Wall -Werror -pedantic)
+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)
 
 if(${EXT_PREFIX_CLASS})
        add_definitions(-DEXT_PREFIX_CLASS=${EXT_PREFIX_CLASS})