From 6cd82dbf57244a754c30039192d5dceaeead0bd7 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 27 Mar 2015 15:55:58 +0500 Subject: CMake: Enable strict flags for C++ --- CMakeLists.txt | 9 +++++++++ build_files/cmake/macros.cmake | 14 ++++++++++++++ intern/audaspace/CMakeLists.txt | 2 ++ intern/cycles/kernel/CMakeLists.txt | 2 ++ source/blender/ikplugin/CMakeLists.txt | 2 ++ source/gameengine/CMakeLists.txt | 2 ++ 6 files changed, 31 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ce183e220f..68f248ab818 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake index b266602fa63..e23d2c6a07c 100644 --- a/build_files/cmake/macros.cmake +++ b/build_files/cmake/macros.cmake @@ -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. diff --git a/intern/audaspace/CMakeLists.txt b/intern/audaspace/CMakeLists.txt index 21a42553935..5b810493663 100644 --- a/intern/audaspace/CMakeLists.txt +++ b/intern/audaspace/CMakeLists.txt @@ -19,6 +19,8 @@ # # ***** END LGPL LICENSE BLOCK ***** +remove_extra_strict_flags() + set(INC . FX diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt index 1e3eb6bca54..fd690234bc1 100644 --- a/intern/cycles/kernel/CMakeLists.txt +++ b/intern/cycles/kernel/CMakeLists.txt @@ -1,3 +1,5 @@ +remove_extra_strict_flags() + set(INC . ../util diff --git a/source/blender/ikplugin/CMakeLists.txt b/source/blender/ikplugin/CMakeLists.txt index 139dbd32349..8991e113410 100644 --- a/source/blender/ikplugin/CMakeLists.txt +++ b/source/blender/ikplugin/CMakeLists.txt @@ -23,6 +23,8 @@ # # ***** END GPL LICENSE BLOCK ***** +remove_extra_strict_flags() + set(INC . ../blenkernel diff --git a/source/gameengine/CMakeLists.txt b/source/gameengine/CMakeLists.txt index cf7895e98ea..62523175f46 100644 --- a/source/gameengine/CMakeLists.txt +++ b/source/gameengine/CMakeLists.txt @@ -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}") -- cgit v1.2.3