CMake: refactor flag checking function to take multiple argument pairs
Many calls to add_check_c_compiler_flag add_check_cxx_compiler_flag resulted in over long lines & visual noise. Replace with a function that takes multiple (cache_var flag) pairs to reduce duplication.
This commit is contained in:
379
CMakeLists.txt
379
CMakeLists.txt
@@ -1648,82 +1648,108 @@ endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_ALL -Wall)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_ERROR_RETURN_TYPE -Werror=return-type)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_ERROR_VLA -Werror=vla)
|
||||
# system headers sometimes do this, disable for now, was: -Werror=strict-prototypes
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_WRITE_STRINGS -Wwrite-strings)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_LOGICAL_OP -Wlogical-op)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_UNDEF -Wundef)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_INIT_SELF -Winit-self) # needs -Wuninitialized
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_TYPE_LIMITS -Wtype-limits)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_FORMAT_SIGN -Wformat-signedness)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_RESTRICT -Wrestrict)
|
||||
# Useful but too many false positives and inconvenient to suppress each occurrence.
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_STRINGOP_OVERREAD -Wno-stringop-overread)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_STRINGOP_OVERFLOW -Wno-stringop-overflow)
|
||||
add_check_c_compiler_flags(
|
||||
C_WARNINGS
|
||||
|
||||
# C-only.
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_NULL -Wnonnull)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_ABSOLUTE_VALUE -Wabsolute-value)
|
||||
C_WARN_ALL -Wall
|
||||
C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration
|
||||
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_UNINITIALIZED -Wuninitialized)
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized)
|
||||
# System headers sometimes do this, disable for now, was: `-Werror=strict-prototypes`.
|
||||
C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes
|
||||
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_REDUNDANT_DECLS -Wredundant-decls)
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_REDUNDANT_DECLS -Wredundant-decls)
|
||||
C_WARN_ERROR_RETURN_TYPE -Werror=return-type
|
||||
C_WARN_ERROR_VLA -Werror=vla
|
||||
C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes
|
||||
C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts
|
||||
C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas
|
||||
C_WARN_POINTER_ARITH -Wpointer-arith
|
||||
C_WARN_UNUSED_PARAMETER -Wunused-parameter
|
||||
C_WARN_WRITE_STRINGS -Wwrite-strings
|
||||
C_WARN_LOGICAL_OP -Wlogical-op
|
||||
C_WARN_UNDEF -Wundef
|
||||
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_SHADOW -Wshadow)
|
||||
# Needs: `-Wuninitialized`.
|
||||
C_WARN_INIT_SELF -Winit-self
|
||||
|
||||
# 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)
|
||||
C_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs
|
||||
C_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero
|
||||
C_WARN_TYPE_LIMITS -Wtype-limits
|
||||
C_WARN_FORMAT_SIGN -Wformat-signedness
|
||||
C_WARN_RESTRICT -Wrestrict
|
||||
|
||||
# Useful but too many false positives and inconvenient to suppress each occurrence.
|
||||
C_WARN_NO_STRINGOP_OVERREAD -Wno-stringop-overread
|
||||
C_WARN_NO_STRINGOP_OVERFLOW -Wno-stringop-overflow
|
||||
|
||||
# C-only.
|
||||
C_WARN_NO_NULL -Wnonnull
|
||||
C_WARN_ABSOLUTE_VALUE -Wabsolute-value
|
||||
|
||||
C_WARN_UNINITIALIZED -Wuninitialized
|
||||
C_WARN_REDUNDANT_DECLS -Wredundant-decls
|
||||
C_WARN_SHADOW -Wshadow
|
||||
|
||||
# Disable because it gives warnings for printf() & friends.
|
||||
# C_WARN_DOUBLE_PROMOTION "-Wdouble-promotion -Wno-error=double-promotion"
|
||||
|
||||
# Use `ATTR_FALLTHROUGH` macro to suppress.
|
||||
C_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5
|
||||
)
|
||||
|
||||
if(NOT APPLE)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
|
||||
add_check_c_compiler_flags(
|
||||
C_WARNINGS
|
||||
C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable
|
||||
)
|
||||
endif()
|
||||
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_ALL -Wall)
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_LOGICAL_OP -Wlogical-op)
|
||||
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_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_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)
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_FORMAT_SIGN -Wformat-signedness)
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_RESTRICT -Wrestrict)
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_SUGGEST_OVERRIDE -Wno-suggest-override)
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNINITIALIZED -Wuninitialized)
|
||||
# Useful but too many false positives and inconvenient to suppress each occurrence.
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_STRINGOP_OVERREAD -Wno-stringop-overread)
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_STRINGOP_OVERFLOW -Wno-stringop-overflow)
|
||||
add_check_cxx_compiler_flags(
|
||||
CXX_WARNINGS
|
||||
|
||||
CXX_WARN_UNINITIALIZED -Wuninitialized
|
||||
CXX_WARN_REDUNDANT_DECLS -Wredundant-decls
|
||||
|
||||
CXX_WARN_ALL -Wall
|
||||
CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof
|
||||
CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare
|
||||
CXX_WARN_LOGICAL_OP -Wlogical-op
|
||||
|
||||
# Needs: `-Wuninitialized`.
|
||||
CXX_WARN_INIT_SELF -Winit-self
|
||||
|
||||
CXX_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs
|
||||
CXX_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero
|
||||
CXX_WARN_TYPE_LIMITS -Wtype-limits
|
||||
CXX_WARN_ERROR_RETURN_TYPE -Werror=return-type
|
||||
CXX_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts
|
||||
CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas
|
||||
CXX_WARN_POINTER_ARITH -Wpointer-arith
|
||||
CXX_WARN_UNUSED_PARAMETER -Wunused-parameter
|
||||
CXX_WARN_WRITE_STRINGS -Wwrite-strings
|
||||
CXX_WARN_UNDEF -Wundef
|
||||
CXX_WARN_FORMAT_SIGN -Wformat-signedness
|
||||
CXX_WARN_RESTRICT -Wrestrict
|
||||
CXX_WARN_NO_SUGGEST_OVERRIDE -Wno-suggest-override
|
||||
CXX_WARN_UNINITIALIZED -Wuninitialized
|
||||
|
||||
# Useful but too many false positives and inconvenient to suppress each occurrence.
|
||||
CXX_WARN_NO_STRINGOP_OVERREAD -Wno-stringop-overread
|
||||
CXX_WARN_NO_STRINGOP_OVERFLOW -Wno-stringop-overflow
|
||||
|
||||
# Use `[[fallthrough]]` or `ATTR_FALLTHROUGH` macro to suppress.
|
||||
CXX_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5
|
||||
|
||||
)
|
||||
|
||||
# causes too many warnings
|
||||
if(NOT APPLE)
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNDEF -Wundef)
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_MISSING_DECLARATIONS -Wmissing-declarations)
|
||||
add_check_cxx_compiler_flags(
|
||||
CXX_WARNINGS
|
||||
CXX_WARN_UNDEF -Wundef
|
||||
CXX_WARN_MISSING_DECLARATIONS -Wmissing-declarations
|
||||
)
|
||||
endif()
|
||||
|
||||
# Use 'ATTR_FALLTHROUGH' macro to suppress.
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5)
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_IMPLICIT_FALLTHROUGH -Wimplicit-fallthrough=5)
|
||||
|
||||
# ---------------------
|
||||
# Suppress Strict Flags
|
||||
#
|
||||
@@ -1736,118 +1762,163 @@ if(CMAKE_COMPILER_IS_GNUCC)
|
||||
# If code in `./extern/` needs to suppress these flags that can be done on a case-by-case basis.
|
||||
|
||||
# flags to undo strict flags
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_TYPE_LIMITS -Wno-type-limits)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_INT_IN_BOOL_CONTEXT -Wno-int-in-bool-context)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_FORMAT -Wno-format)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_SWITCH -Wno-switch)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_VARIABLE -Wno-uninitialized)
|
||||
add_check_c_compiler_flags(
|
||||
C_REMOVE_STRICT_FLAGS
|
||||
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_CLASS_MEMACCESS -Wno-class-memaccess)
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_COMMENT -Wno-comment)
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_TYPEDEFS -Wno-unused-local-typedefs)
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable)
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_VARIABLE -Wno-uninitialized)
|
||||
C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations
|
||||
C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter
|
||||
C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function
|
||||
C_WARN_NO_TYPE_LIMITS -Wno-type-limits
|
||||
C_WARN_NO_INT_IN_BOOL_CONTEXT -Wno-int-in-bool-context
|
||||
C_WARN_NO_FORMAT -Wno-format
|
||||
C_WARN_NO_SWITCH -Wno-switch
|
||||
C_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable
|
||||
C_WARN_NO_UNUSED_VARIABLE -Wno-uninitialized
|
||||
C_WARN_NO_IMPLICIT_FALLTHROUGH -Wno-implicit-fallthrough
|
||||
)
|
||||
|
||||
|
||||
add_check_cxx_compiler_flags(
|
||||
CXX_REMOVE_STRICT_FLAGS
|
||||
|
||||
CXX_WARN_NO_CLASS_MEMACCESS -Wno-class-memaccess
|
||||
CXX_WARN_NO_COMMENT -Wno-comment
|
||||
CXX_WARN_NO_UNUSED_TYPEDEFS -Wno-unused-local-typedefs
|
||||
CXX_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable
|
||||
CXX_WARN_NO_UNUSED_VARIABLE -Wno-uninitialized
|
||||
)
|
||||
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_IMPLICIT_FALLTHROUGH -Wno-implicit-fallthrough)
|
||||
|
||||
if(NOT APPLE)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable)
|
||||
add_check_c_compiler_flags(
|
||||
C_REMOVE_STRICT_FLAGS
|
||||
C_WARN_NO_ERROR_UNUSED_BUT_SET_VARIABLE -Wno-error=unused-but-set-variable
|
||||
)
|
||||
endif()
|
||||
|
||||
elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
|
||||
# strange, clang complains these are not supported, but then uses them.
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_ALL -Wall)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_ERROR_RETURN_TYPE -Werror=return-type)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_UNUSED_PARAMETER -Wunused-parameter)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_UNDEF -Wundef)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_UNDEF_PREFIX -Wundef-prefix)
|
||||
add_check_c_compiler_flags(
|
||||
C_WARNINGS
|
||||
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_ALL -Wall)
|
||||
# Using C++20 features while having C++17 as the project language isn't allowed by MSVC.
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_CXX20_DESIGNATOR -Wc++20-designator)
|
||||
# Strange, clang complains these are not supported, but then uses them.
|
||||
C_WARN_ALL -Wall
|
||||
C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration
|
||||
C_WARN_ERROR_RETURN_TYPE -Werror=return-type
|
||||
C_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare
|
||||
C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas
|
||||
C_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts
|
||||
C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes
|
||||
C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes
|
||||
C_WARN_UNUSED_PARAMETER -Wunused-parameter
|
||||
C_WARN_UNDEF -Wundef
|
||||
C_WARN_UNDEF_PREFIX -Wundef-prefix
|
||||
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare)
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
|
||||
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_OVERLOADED_VIRTUAL -Wno-overloaded-virtual) # we get a lot of these, if its a problem a dev needs to look into it.
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
|
||||
# Apple Clang (tested on version 12) doesn't support this flag while LLVM Clang 11 does.
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_SUGGEST_OVERRIDE -Wno-suggest-override)
|
||||
C_WARN_ERROR_UNGUARDED_AVAILABILITY_NEW -Werror=unguarded-availability-new
|
||||
)
|
||||
|
||||
add_check_cxx_compiler_flags(
|
||||
CXX_WARNINGS
|
||||
|
||||
CXX_WARN_ALL -Wall
|
||||
# Using C++20 features while having C++17 as the project language isn't allowed by MSVC.
|
||||
CXX_CXX20_DESIGNATOR -Wc++20-designator
|
||||
|
||||
CXX_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare
|
||||
CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas
|
||||
CXX_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts
|
||||
|
||||
# We get a lot of these, if its a problem a dev needs to look into it.
|
||||
CXX_WARN_NO_OVERLOADED_VIRTUAL -Wno-overloaded-virtual
|
||||
|
||||
CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare
|
||||
CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof
|
||||
|
||||
# Apple Clang (tested on version 12) doesn't support this flag while LLVM Clang 11 does.
|
||||
CXX_WARN_NO_SUGGEST_OVERRIDE -Wno-suggest-override
|
||||
|
||||
CXX_WARN_UNDEF -Wundef
|
||||
CXX_WARN_UNDEF_PREFIX -Wundef-prefix
|
||||
CXX_WARN_UNUSED_PARAMETER -Wunused-parameter
|
||||
|
||||
# Gives too many unfixable warnings.
|
||||
# `C_WARN_UNUSED_MACROS -Wunused-macros`
|
||||
# `CXX_WARN_UNUSED_MACROS -Wunused-macros`
|
||||
|
||||
CXX_WARN_ERROR_UNGUARDED_AVAILABILITY_NEW -Werror=unguarded-availability-new
|
||||
)
|
||||
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNDEF -Wundef)
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNDEF_PREFIX -Wundef-prefix)
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_UNUSED_PARAMETER -Wunused-parameter)
|
||||
|
||||
# gives too many unfixable warnings
|
||||
# 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)
|
||||
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_ERROR_UNGUARDED_AVAILABILITY_NEW -Werror=unguarded-availability-new)
|
||||
add_check_c_compiler_flag(CXX_WARNINGS CXX_WARN_ERROR_UNGUARDED_AVAILABILITY_NEW -Werror=unguarded-availability-new)
|
||||
|
||||
# ---------------------
|
||||
# Suppress Strict Flags
|
||||
|
||||
# flags to undo strict flags
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_MACROS -Wno-unused-macros)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_MISLEADING_INDENTATION -Wno-misleading-indentation)
|
||||
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_VARIABLE_DECLARATIONS -Wno-missing-variable-declarations)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_INCOMPAT_PTR_DISCARD_QUAL -Wno-incompatible-pointer-types-discards-qualifiers)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_INT_TO_VOID_POINTER_CAST -Wno-int-to-void-pointer-cast)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_PROTOTYPES -Wno-missing-prototypes)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_DUPLICATE_ENUM -Wno-duplicate-enum)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNDEF -Wno-undef)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_MISSING_NORETURN -Wno-missing-noreturn)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_UNUSED_BUT_SET_VARIABLE -Wno-unused-but-set-variable)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_STRICT_PROTOTYPES -Wno-strict-prototypes)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_BITWISE_INSTEAD_OF_LOGICAL -Wno-bitwise-instead-of-logical)
|
||||
add_check_c_compiler_flag(C_REMOVE_STRICT_FLAGS C_WARN_NO_IMPLICIT_CONST_INT_FLOAT_CONVERSION -Wno-implicit-const-int-float-conversion)
|
||||
add_check_c_compiler_flags(
|
||||
C_REMOVE_STRICT_FLAGS
|
||||
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter)
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_PRIVATE_FIELD -Wno-unused-private-field)
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_CXX11_NARROWING -Wno-c++11-narrowing)
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_NON_VIRTUAL_DTOR -Wno-non-virtual-dtor)
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_MACROS -Wno-unused-macros)
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable)
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_REORDER -Wno-reorder)
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_COMMENT -Wno-comment)
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNUSED_TYPEDEFS -Wno-unused-local-typedefs)
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNDEFINED_VAR_TEMPLATE -Wno-undefined-var-template)
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_INSTANTIATION_AFTER_SPECIALIZATION -Wno-instantiation-after-specialization)
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_MISLEADING_INDENTATION -Wno-misleading-indentation)
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_BITWISE_INSTEAD_OF_LOGICAL -Wno-bitwise-instead-of-logical)
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_IMPLICIT_CONST_INT_FLOAT_CONVERSION -Wno-implicit-const-int-float-conversion)
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNDEF -Wno-undef)
|
||||
add_check_cxx_compiler_flag(CXX_REMOVE_STRICT_FLAGS CXX_WARN_NO_UNDEF_PREFIX -Wno-undef-prefix)
|
||||
C_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter
|
||||
C_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable
|
||||
C_WARN_NO_UNUSED_MACROS -Wno-unused-macros
|
||||
C_WARN_NO_MISLEADING_INDENTATION -Wno-misleading-indentation
|
||||
|
||||
C_WARN_NO_MISSING_VARIABLE_DECLARATIONS -Wno-missing-variable-declarations
|
||||
C_WARN_NO_INCOMPAT_PTR_DISCARD_QUAL -Wno-incompatible-pointer-types-discards-qualifiers
|
||||
C_WARN_NO_UNUSED_FUNCTION -Wno-unused-function
|
||||
C_WARN_NO_INT_TO_VOID_POINTER_CAST -Wno-int-to-void-pointer-cast
|
||||
C_WARN_NO_MISSING_PROTOTYPES -Wno-missing-prototypes
|
||||
C_WARN_NO_DUPLICATE_ENUM -Wno-duplicate-enum
|
||||
C_WARN_NO_UNDEF -Wno-undef
|
||||
C_WARN_NO_MISSING_NORETURN -Wno-missing-noreturn
|
||||
C_WARN_NO_UNUSED_BUT_SET_VARIABLE -Wno-unused-but-set-variable
|
||||
C_WARN_NO_DEPRECATED_DECLARATIONS -Wno-deprecated-declarations
|
||||
C_WARN_NO_STRICT_PROTOTYPES -Wno-strict-prototypes
|
||||
C_WARN_NO_BITWISE_INSTEAD_OF_LOGICAL -Wno-bitwise-instead-of-logical
|
||||
C_WARN_NO_IMPLICIT_CONST_INT_FLOAT_CONVERSION -Wno-implicit-const-int-float-conversion
|
||||
)
|
||||
|
||||
add_check_cxx_compiler_flags(
|
||||
CXX_REMOVE_STRICT_FLAGS
|
||||
|
||||
CXX_WARN_NO_UNUSED_PARAMETER -Wno-unused-parameter
|
||||
CXX_WARN_NO_UNUSED_PRIVATE_FIELD -Wno-unused-private-field
|
||||
CXX_WARN_NO_CXX11_NARROWING -Wno-c++11-narrowing
|
||||
CXX_WARN_NO_NON_VIRTUAL_DTOR -Wno-non-virtual-dtor
|
||||
CXX_WARN_NO_UNUSED_MACROS -Wno-unused-macros
|
||||
CXX_WARN_NO_UNUSED_VARIABLE -Wno-unused-variable
|
||||
CXX_WARN_NO_REORDER -Wno-reorder
|
||||
CXX_WARN_NO_COMMENT -Wno-comment
|
||||
CXX_WARN_NO_UNUSED_TYPEDEFS -Wno-unused-local-typedefs
|
||||
CXX_WARN_NO_UNDEFINED_VAR_TEMPLATE -Wno-undefined-var-template
|
||||
CXX_WARN_NO_INSTANTIATION_AFTER_SPECIALIZATION -Wno-instantiation-after-specialization
|
||||
CXX_WARN_NO_MISLEADING_INDENTATION -Wno-misleading-indentation
|
||||
CXX_WARN_NO_BITWISE_INSTEAD_OF_LOGICAL -Wno-bitwise-instead-of-logical
|
||||
CXX_WARN_NO_IMPLICIT_CONST_INT_FLOAT_CONVERSION -Wno-implicit-const-int-float-conversion
|
||||
CXX_WARN_NO_UNDEF -Wno-undef
|
||||
CXX_WARN_NO_UNDEF_PREFIX -Wno-undef-prefix
|
||||
)
|
||||
|
||||
elseif(CMAKE_C_COMPILER_ID MATCHES "Intel")
|
||||
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_ALL -Wall)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_POINTER_ARITH -Wpointer-arith)
|
||||
add_check_c_compiler_flag(C_WARNINGS C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
|
||||
add_check_c_compiler_flags(
|
||||
C_WARNINGS
|
||||
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_ALL -Wall)
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof)
|
||||
add_check_cxx_compiler_flag(CXX_WARNINGS CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare)
|
||||
C_WARN_ALL -Wall
|
||||
C_WARN_POINTER_ARITH -Wpointer-arith
|
||||
C_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas
|
||||
)
|
||||
|
||||
# disable numbered, false positives
|
||||
add_check_cxx_compiler_flags(
|
||||
CXX_WARNINGS
|
||||
|
||||
CXX_WARN_ALL -Wall
|
||||
CXX_WARN_NO_INVALID_OFFSETOF -Wno-invalid-offsetof
|
||||
CXX_WARN_NO_SIGN_COMPARE -Wno-sign-compare
|
||||
)
|
||||
|
||||
# Disable numbered, false positives.
|
||||
string(APPEND C_WARNINGS " -wd188,186,144,913,556,858,597,177,1292,167,279,592,94,2722,3199")
|
||||
string(APPEND CXX_WARNINGS " -wd188,186,144,913,556,858,597,177,1292,167,279,592,94,2722,3199")
|
||||
elseif(CMAKE_C_COMPILER_ID MATCHES "MSVC")
|
||||
@@ -1953,8 +2024,14 @@ if(WITH_COMPILER_SHORT_FILE_MACRO)
|
||||
# Use '-fmacro-prefix-map' for Clang and GCC (MSVC doesn't support this).
|
||||
set(C_PREFIX_MAP_FLAGS "")
|
||||
set(CXX_PREFIX_MAP_FLAGS "")
|
||||
add_check_c_compiler_flag(C_PREFIX_MAP_FLAGS C_MACRO_PREFIX_MAP -fmacro-prefix-map=foo=bar)
|
||||
add_check_cxx_compiler_flag(CXX_PREFIX_MAP_FLAGS CXX_MACRO_PREFIX_MAP -fmacro-prefix-map=foo=bar)
|
||||
add_check_c_compiler_flags(
|
||||
C_PREFIX_MAP_FLAGS
|
||||
C_MACRO_PREFIX_MAP -fmacro-prefix-map=foo=bar
|
||||
)
|
||||
add_check_cxx_compiler_flags(
|
||||
CXX_PREFIX_MAP_FLAGS
|
||||
CXX_MACRO_PREFIX_MAP -fmacro-prefix-map=foo=bar
|
||||
)
|
||||
if(C_MACRO_PREFIX_MAP AND CXX_MACRO_PREFIX_MAP)
|
||||
if(APPLE)
|
||||
if(XCODE AND ${XCODE_VERSION} VERSION_LESS 12.0)
|
||||
|
||||
Reference in New Issue
Block a user