CMake: use -Wshadow warning for C source
authorCampbell Barton <ideasman42@gmail.com>
Mon, 23 Nov 2015 04:45:52 +0000 (15:45 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Mon, 23 Nov 2015 06:43:55 +0000 (17:43 +1100)
C source now builds without shadowing, enable with GCC by default.

CMakeLists.txt
intern/mikktspace/CMakeLists.txt

index 7319a34d11b3bef4a8637710bf7546d09425b748..507676667c98c78d612c694b8b4730de87e79338 100644 (file)
@@ -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)
 
index e48b0240f98cf0334f73255cada11969e023a55a..8abd9559358c0b294cab8cc33b3fffe2697db9d7 100644 (file)
 #
 # ***** END GPL LICENSE BLOCK *****
 
+if(CMAKE_COMPILER_IS_GNUCC)
+       remove_cc_flag(
+               "-Wshadow"
+               "-Werror=shadow"
+       )
+endif()
+
 set(INC
        .
 )