Merged changes in the trunk up to revision 55357.
[blender.git] / CMakeLists.txt
index abfdcd3..579f474 100644 (file)
@@ -281,6 +281,10 @@ mark_as_advanced(WITH_ASSERT_ABORT)
 
 option(WITH_BOOST                                      "Enable features depending no boost" ON)
 
+if(CMAKE_COMPILER_IS_GNUCC)
+       option(WITH_GCC_MUDFLAP                 "Enable mudflap" OFF)
+       mark_as_advanced(WITH_GCC_MUDFLAP)
+endif()
 
 if(APPLE)
        cmake_minimum_required(VERSION 2.8.8)
@@ -1933,6 +1937,11 @@ if(CMAKE_COMPILER_IS_GNUCC)
                ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNINITIALIZED -Wuninitialized)
        endif()
 
+       # versions before gcc4.6 give many BLI_math warnings
+       if (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.6")
+               ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_REDUNDANT_DECLS -Wredundant-decls)
+       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)
 
@@ -1947,6 +1956,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
        ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_INIT_SELF -Winit-self)  # needs -Wuninitialized
        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_REDUNDANT_DECLS -Wredundant-decls)
 
        # gcc 4.2 gives annoying warnings on every file with this
        if (NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
@@ -1993,6 +2003,10 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
        # ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_UNUSED_MACROS      -Wunused-macros)
        # ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_UNUSED_MACROS          -Wunused-macros)
 
+       # flags to undo strict flags
+       ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
+       ADD_CHECK_C_COMPILER_FLAG(CC_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_MACROS    -Wno-unused-macros)
+
 elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
 
        ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
@@ -2029,7 +2043,7 @@ if(WITH_PYTHON)
 
        if(WITH_PYTHON_INSTALL AND WITH_PYTHON_INSTALL_NUMPY)
                # set but invalid
-        # -- disabled until we make numpy bundled with blender - campbell
+               # -- disabled until we make numpy bundled with blender - campbell
                if((NOT ${PYTHON_NUMPY_PATH} STREQUAL "") AND (NOT ${PYTHON_NUMPY_PATH} MATCHES NOTFOUND))
 #                      if(NOT EXISTS "${PYTHON_NUMPY_PATH}/numpy")
 #                              message(WARNING "PYTHON_NUMPY_PATH is invalid, numpy not found in '${PYTHON_NUMPY_PATH}' "
@@ -2073,6 +2087,13 @@ if(WITH_PYTHON)
        endif()
 endif()
 
+if(WITH_GCC_MUDFLAP)
+       set(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -fmudflapth -funwind-tables")
+       set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lpthread -lmudflapth -rdynamic")
+       ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS     C_WARN_NO_ERROR_MUDFLAP   -Wno-error=mudflap)
+       ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_ERROR_MUDFLAP -Wno-error=mudflap)
+endif()
+
 # Include warnings first, so its possible to disable them with user defined flags
 # eg: -Wno-uninitialized
 set(CMAKE_C_FLAGS "${C_WARNINGS} ${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS}")