OpenSubdiv: Add CMake option to enable -Werror in subsurf code
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 30 Jul 2015 08:31:22 +0000 (10:31 +0200)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 30 Jul 2015 08:31:22 +0000 (10:31 +0200)
CMakeLists.txt
intern/opensubdiv/CMakeLists.txt
source/blender/blenkernel/CMakeLists.txt

index c2c0e8e1f75b92cf7b5f454a3225440517a28548..198f6a3a6feced5a6214f04c7651712c7c421dd2 100644 (file)
@@ -230,6 +230,8 @@ option(WITH_COMPOSITOR_WERROR  "Treat warnings as errors in compositor code" OFF
 mark_as_advanced(WITH_COMPOSITOR_WERROR)
 
 option(WITH_OPENSUBDIV    "Enable OpenSubdiv for surface subdivision" OFF)
+option(WITH_SUBSURF_WERROR  "Treat warnings as errors in subsurf code" OFF)
+mark_as_advanced(WITH_COMPOSITOR_WERROR)
 
 # GHOST Windowing Library Options
 option(WITH_GHOST_DEBUG   "Enable debugging output for the GHOST library" OFF)
index 3f88ba5d662bf857aa1f88ef2d0e0bf42741a140..fceaeb94af9f4e877b6904bc39ba9a8ba8fd94fe 100644 (file)
@@ -50,6 +50,11 @@ set(SRC
        opensubdiv_partitioned.h
 )
 
+if(WITH_SUBSURF_WERROR)
+       ADD_CHECK_C_COMPILER_FLAG(CMAKE_C_FLAGS C_WERROR -Werror)
+       ADD_CHECK_CXX_COMPILER_FLAG(CMAKE_CXX_FLAGS C_WERROR -Werror)
+endif()
+
 macro(OPENSUBDIV_DEFINE_COMPONENT component)
        if(${${component}})
                add_definitions(-D${component})
index f0d6cfb7e1ca1baa3cc4c994ffc8a1e8eed59bab..5a3fb49276212f3255d0e4207283bfc7ea2c3648 100644 (file)
@@ -505,6 +505,16 @@ if(WITH_OPENSUBDIV)
                ../../../intern/opensubdiv
                ${OPENSUBDIV_INCLUDE_DIRS}
        )
+       if(WITH_SUBSURF_WERROR)
+               if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
+                       set_source_files_properties(intern/CCGSubSurf.c
+                                                   intern/CCGSubSurf_legacy.c
+                                                   intern/CCGSubSurf_opensubdiv.c
+                                                   intern/CCGSubSurf_opensubdiv_converter.c
+                                                   intern/CCGSubSurf_util.c
+                                                   PROPERTIES COMPILE_FLAGS -Werror)
+               endif()
+       endif()
 endif()
 
 ## Warnings as errors, this is too strict!