CMake: Enable strict flags for C++
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 27 Mar 2015 10:55:58 +0000 (15:55 +0500)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 27 Mar 2015 13:23:31 +0000 (18:23 +0500)
CMakeLists.txt
build_files/cmake/macros.cmake
intern/audaspace/CMakeLists.txt
intern/cycles/kernel/CMakeLists.txt
source/blender/ikplugin/CMakeLists.txt
source/gameengine/CMakeLists.txt

index 2ce183e220fe890e47ace12df8a2ce6e4933acdb..68f248ab818768d8d3cd6f483850a66bf01810a9 100644 (file)
@@ -2550,6 +2550,15 @@ if(CMAKE_COMPILER_IS_GNUCC)
        ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs)
        ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero)
        ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_TYPE_LIMITS -Wtype-limits)
+       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ERROR_RETURN_TYPE  -Werror=return-type)
+       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ERROR_DECLARATION_AFTER_STATEMENT -Werror=declaration-after-statement)
+       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
+       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
+       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
+       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_POINTER_ARITH -Wpointer-arith)
+       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNUSED_PARAMETER -Wunused-parameter)
+       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_WRITE_STRINGS -Wwrite-strings)
+       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNDEF -Wundef)
 
        # gcc 4.2 gives annoying warnings on every file with this
        if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
index b266602fa63503167155280acf58f67cd87619de..e23d2c6a07c264712eda2dafb3c465efe6a16040 100644 (file)
@@ -961,6 +961,20 @@ macro(remove_strict_flags)
 
 endmacro()
 
+macro(remove_extra_strict_flags)
+       if(CMAKE_COMPILER_IS_GNUCC)
+               remove_cc_flag("-Wunused-parameter")
+       endif()
+
+       if(CMAKE_C_COMPILER_ID MATCHES "Clang")
+               remove_cc_flag("-Wunused-parameter")
+       endif()
+
+       if(MSVC)
+               # TODO
+       endif()
+endmacro()
+
 # note, we can only append flags on a single file so we need to negate the options.
 # at the moment we cant shut up ffmpeg deprecations, so use this, but will
 # probably add more removals here.
index 21a42553935985cba14e0632fafb73b421f2390f..5b81049366345f50903ee1607bbd26b6404c69f4 100644 (file)
@@ -19,6 +19,8 @@
 #
 # ***** END LGPL LICENSE BLOCK *****
 
+remove_extra_strict_flags()
+
 set(INC
        .
        FX
index 1e3eb6bca5489b1a15f6c38beedec4224c5c0d1b..fd690234bc1230e2ba226d6c6b7406dc40186f15 100644 (file)
@@ -1,3 +1,5 @@
+remove_extra_strict_flags()
+
 set(INC
        .
        ../util
index 139dbd32349a38a30c4d8c0527eb80f24302ef8b..8991e113410d364bda8547b067f464577dea0144 100644 (file)
@@ -23,6 +23,8 @@
 #
 # ***** END GPL LICENSE BLOCK *****
 
+remove_extra_strict_flags()
+
 set(INC 
        .
        ../blenkernel
index cf7895e98ea5056685f89ee25c57c1bff20f6b52..62523175f46ead0655267964b30d046550916269 100644 (file)
@@ -23,6 +23,8 @@
 #
 # ***** END GPL LICENSE BLOCK *****
 
+remove_extra_strict_flags()
+
 # there are too many inter-includes so best define here
 if(WITH_PYTHON)
        blender_include_dirs_sys("${PYTHON_INCLUDE_DIRS}")