CMake: Enable strict flags for C++
This commit is contained in:
@@ -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_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_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_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
|
# gcc 4.2 gives annoying warnings on every file with this
|
||||||
if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
|
if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3")
|
||||||
|
@@ -961,6 +961,20 @@ macro(remove_strict_flags)
|
|||||||
|
|
||||||
endmacro()
|
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.
|
# 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
|
# at the moment we cant shut up ffmpeg deprecations, so use this, but will
|
||||||
# probably add more removals here.
|
# probably add more removals here.
|
||||||
|
@@ -19,6 +19,8 @@
|
|||||||
#
|
#
|
||||||
# ***** END LGPL LICENSE BLOCK *****
|
# ***** END LGPL LICENSE BLOCK *****
|
||||||
|
|
||||||
|
remove_extra_strict_flags()
|
||||||
|
|
||||||
set(INC
|
set(INC
|
||||||
.
|
.
|
||||||
FX
|
FX
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
remove_extra_strict_flags()
|
||||||
|
|
||||||
set(INC
|
set(INC
|
||||||
.
|
.
|
||||||
../util
|
../util
|
||||||
|
@@ -23,6 +23,8 @@
|
|||||||
#
|
#
|
||||||
# ***** END GPL LICENSE BLOCK *****
|
# ***** END GPL LICENSE BLOCK *****
|
||||||
|
|
||||||
|
remove_extra_strict_flags()
|
||||||
|
|
||||||
set(INC
|
set(INC
|
||||||
.
|
.
|
||||||
../blenkernel
|
../blenkernel
|
||||||
|
@@ -23,6 +23,8 @@
|
|||||||
#
|
#
|
||||||
# ***** END GPL LICENSE BLOCK *****
|
# ***** END GPL LICENSE BLOCK *****
|
||||||
|
|
||||||
|
remove_extra_strict_flags()
|
||||||
|
|
||||||
# there are too many inter-includes so best define here
|
# there are too many inter-includes so best define here
|
||||||
if(WITH_PYTHON)
|
if(WITH_PYTHON)
|
||||||
blender_include_dirs_sys("${PYTHON_INCLUDE_DIRS}")
|
blender_include_dirs_sys("${PYTHON_INCLUDE_DIRS}")
|
||||||
|
Reference in New Issue
Block a user