[Bf-blender-cvs] [4fe413a] master: CMake: use -Wshadow warning for C source

Campbell Barton noreply at git.blender.org
Mon Nov 23 07:52:00 CET 2015


Commit: 4fe413a419e2baf23b835bbf1b9739de40c624de
Author: Campbell Barton
Date:   Mon Nov 23 15:45:52 2015 +1100
Branches: master
https://developer.blender.org/rB4fe413a419e2baf23b835bbf1b9739de40c624de

CMake: use -Wshadow warning for C source

C source now builds without shadowing, enable with GCC by default.

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

M	CMakeLists.txt
M	intern/mikktspace/CMakeLists.txt

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

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7319a34..5076766 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2602,6 +2602,11 @@ if(CMAKE_COMPILER_IS_GNUCC)
 		ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_REDUNDANT_DECLS -Wredundant-decls)
 	endif()
 
+	# versions before gcc4.8 include global name-space.
+	if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.8")
+		ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_SHADOW -Wshadow)
+	endif()
+
 	# disable because it gives warnings for printf() & friends.
 	# ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_DOUBLE_PROMOTION -Wdouble-promotion -Wno-error=double-promotion)
 
diff --git a/intern/mikktspace/CMakeLists.txt b/intern/mikktspace/CMakeLists.txt
index e48b024..8abd955 100644
--- a/intern/mikktspace/CMakeLists.txt
+++ b/intern/mikktspace/CMakeLists.txt
@@ -23,6 +23,13 @@
 #
 # ***** END GPL LICENSE BLOCK *****
 
+if(CMAKE_COMPILER_IS_GNUCC)
+	remove_cc_flag(
+		"-Wshadow"
+		"-Werror=shadow"
+	)
+endif()
+
 set(INC
 	.
 )




More information about the Bf-blender-cvs mailing list