aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/CompilerWarnings.cmake
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-11-18 13:01:36 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-11-18 13:01:36 +0000
commit7f482c08cef8b8e7817d2154ee46aa2569f28e30 (patch)
treeba913fe7cf6cf4abe36b681364d0ea4eb676749d /cmake/CompilerWarnings.cmake
parent617c1bd77dfb532fe47bd27e58a1202d744b0af1 (diff)
downloadrspamd-7f482c08cef8b8e7817d2154ee46aa2569f28e30.tar.gz
rspamd-7f482c08cef8b8e7817d2154ee46aa2569f28e30.zip
[Rework] Make cmake structure more modular
Diffstat (limited to 'cmake/CompilerWarnings.cmake')
-rw-r--r--cmake/CompilerWarnings.cmake72
1 files changed, 72 insertions, 0 deletions
diff --git a/cmake/CompilerWarnings.cmake b/cmake/CompilerWarnings.cmake
new file mode 100644
index 000000000..a9797f539
--- /dev/null
+++ b/cmake/CompilerWarnings.cmake
@@ -0,0 +1,72 @@
+CHECK_C_COMPILER_FLAG(-Wall SUPPORT_WALL)
+CHECK_C_COMPILER_FLAG(-W SUPPORT_W)
+CHECK_C_COMPILER_FLAG(-Wpointer-arith SUPPORT_WPOINTER)
+CHECK_C_COMPILER_FLAG(-Wno-unused-parameter SUPPORT_WPARAM)
+CHECK_C_COMPILER_FLAG(-Wno-unused-function SUPPORT_WFUNCTION)
+CHECK_C_COMPILER_FLAG(-Wno-strict-aliasing SUPPORT_WSTRICT_ALIASING)
+CHECK_C_COMPILER_FLAG(-Wunused-variable SUPPORT_WUNUSED_VAR)
+CHECK_C_COMPILER_FLAG(-Wno-pointer-sign SUPPORT_WPOINTER_SIGN)
+CHECK_C_COMPILER_FLAG(-Wno-sign-compare SUPPORT_WSIGN_COMPARE)
+CHECK_C_COMPILER_FLAG(-Wstrict-prototypes SUPPORT_WSTRICT_PROTOTYPES)
+CHECK_C_COMPILER_FLAG(-pedantic SUPPORT_PEDANTIC_FLAG)
+CHECK_C_COMPILER_FLAG(-Wno-unused-const-variable SUPPORT_WNO_UNUSED_CONST)
+# GCC 6 specific
+CHECK_C_COMPILER_FLAG(-Wnull-dereference SUPPORT_WNULL_DEREFERENCE)
+CHECK_C_COMPILER_FLAG(-Wduplicated-cond SUPPORT_WDUPLICATED_COND)
+# GCC 7 specific
+CHECK_C_COMPILER_FLAG(-Wimplicit-fallthrough SUPPORT_WIMPLICIT_FALLTHROUGH)
+
+IF(SUPPORT_W)
+ ADD_COMPILE_OPTIONS("-W")
+ENDIF(SUPPORT_W)
+IF(SUPPORT_WALL)
+ ADD_COMPILE_OPTIONS("-Wall")
+ENDIF(SUPPORT_WALL)
+IF(SUPPORT_WPOINTER)
+ ADD_COMPILE_OPTIONS("-Wpointer-arith")
+ENDIF(SUPPORT_WPOINTER)
+IF(SUPPORT_WPARAM)
+ ADD_COMPILE_OPTIONS("-Wno-unused-parameter")
+ENDIF(SUPPORT_WPARAM)
+IF(SUPPORT_WFUNCTION)
+ ADD_COMPILE_OPTIONS("-Wno-unused-function")
+ENDIF(SUPPORT_WFUNCTION)
+IF(SUPPORT_WUNUSED_VAR)
+ ADD_COMPILE_OPTIONS("-Wunused-variable")
+ENDIF(SUPPORT_WUNUSED_VAR)
+IF(SUPPORT_WPOINTER_SIGN)
+ ADD_COMPILE_OPTIONS("-Wno-pointer-sign")
+ENDIF(SUPPORT_WPOINTER_SIGN)
+IF(SUPPORT_WSTRICT_PROTOTYPES)
+ ADD_COMPILE_OPTIONS("-Wstrict-prototypes")
+ENDIF(SUPPORT_WSTRICT_PROTOTYPES)
+IF(SUPPORT_WSTRICT_ALIASING)
+ ADD_COMPILE_OPTIONS("-Wno-strict-aliasing")
+ ADD_COMPILE_OPTIONS("-fno-strict-aliasing")
+ENDIF(SUPPORT_WSTRICT_ALIASING)
+#IF(SUPPORT_PEDANTIC_FLAG)
+# SET(CMAKE_C_WARN_FLAGS "${CMAKE_C_WARN_FLAGS} -pedantic")
+#ENDIF(SUPPORT_PEDANTIC_FLAG)
+IF(SUPPORT_WNULL_DEREFERENCE)
+ ADD_COMPILE_OPTIONS("-Wnull-dereference")
+ENDIF()
+IF(SUPPORT_WDUPLICATED_COND)
+ ADD_COMPILE_OPTIONS("-Wduplicated-cond")
+ENDIF()
+IF(SUPPORT_WLOGICAL_OP)
+ ADD_COMPILE_OPTIONS("-Wlogical-op")
+ENDIF()
+IF(SUPPORT_WNO_UNUSED_CONST)
+ ADD_COMPILE_OPTIONS("-Wno-unused-const-variable")
+ENDIF()
+IF(SUPPORT_WSIGN_COMPARE)
+ ADD_COMPILE_OPTIONS("-Wno-sign-compare")
+ENDIF()
+IF(SUPPORT_WIMPLICIT_FALLTHROUGH)
+ ADD_COMPILE_OPTIONS("-Wno-implicit-fallthrough")
+ENDIF(SUPPORT_WIMPLICIT_FALLTHROUGH)
+
+CHECK_C_COMPILER_FLAG(-fPIC SUPPORT_FPIC)
+IF(SUPPORT_FPIC)
+ ADD_COMPILE_OPTIONS("-fPIC")
+ENDIF(SUPPORT_FPIC) \ No newline at end of file