[Bf-blender-cvs] [6cd82db] master: CMake: Enable strict flags for C++

Sergey Sharybin noreply at git.blender.org
Fri Mar 27 14:24:12 CET 2015


Commit: 6cd82dbf57244a754c30039192d5dceaeead0bd7
Author: Sergey Sharybin
Date:   Fri Mar 27 15:55:58 2015 +0500
Branches: master
https://developer.blender.org/rB6cd82dbf57244a754c30039192d5dceaeead0bd7

CMake: Enable strict flags for C++

===================================================================

M	CMakeLists.txt
M	build_files/cmake/macros.cmake
M	intern/audaspace/CMakeLists.txt
M	intern/cycles/kernel/CMakeLists.txt
M	source/blender/ikplugin/CMakeLists.txt
M	source/gameengine/CMakeLists.txt

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2ce183e..68f248a 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 b266602..e23d2c6 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 21a4255..5b81049 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 1e3eb6b..fd69023 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 139dbd3..8991e11 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 cf7895e..6252317 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}")




More information about the Bf-blender-cvs mailing list