myxx/MyxxCMake/lib/WarningFlags.cmake

89 lines
3.8 KiB
CMake
Raw Normal View History

2022-10-07 05:03:56 +00:00
include_guard(GLOBAL)
option(MYX_CMAKE_WARNINGS_NORMAL "Normal level" ON)
cmake_dependent_option(MYX_CMAKE_WARNINGS_VERBOSE "Verbose level" OFF "MYX_CMAKE_WARNINGS_NORMAL" OFF)
if(MYX_CMAKE_WARNINGS_NORMAL)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
check_enable_cxx_compiler_flag(-Wshadow)
check_enable_cxx_compiler_flag(-Wtautological-overlap-compare)
check_enable_cxx_compiler_flag(-Wtautological-compare)
check_enable_cxx_compiler_flag(-Wtautological-bitwise-compare)
check_enable_cxx_compiler_flag(-Wbitwise-conditional-parentheses)
check_enable_cxx_compiler_flag(-Wrange-loop-analysis)
check_enable_cxx_compiler_flag(-Wmisleading-indentation)
check_enable_cxx_compiler_flag(-Wc99-designator)
check_enable_cxx_compiler_flag(-Wreorder-init-list)
check_enable_cxx_compiler_flag(-Wsizeof-pointer-div)
check_enable_cxx_compiler_flag(-Wsizeof-array-div)
check_enable_cxx_compiler_flag(-Wxor-used-as-pow)
check_enable_cxx_compiler_flag(-Wfinal-dtor-non-final-class)
endif()
if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR
(CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
check_enable_cxx_compiler_flag(-Wall)
check_enable_cxx_compiler_flag(-Wextra)
check_enable_cxx_compiler_flag(-Wnon-virtual-dtor)
check_enable_cxx_compiler_flag(-Wlogical-op)
check_enable_cxx_compiler_flag(-Wconversion)
check_enable_cxx_compiler_flag(-Wdeprecated)
check_enable_cxx_compiler_flag(-ftemplate-depth=1024)
check_enable_cxx_compiler_flag(-Wold-style-cast)
check_enable_cxx_compiler_flag(-Wdisabled-optimization)
check_enable_cxx_compiler_flag(-ftemplate-backtrace-limit=0)
check_enable_cxx_compiler_flag(-fstack-protector-all)
check_enable_cxx_compiler_flag(-Wodr)
check_enable_cxx_compiler_flag(-Wsuggest-final-types)
check_enable_cxx_compiler_flag(-Wsuggest-final-methods)
check_enable_cxx_compiler_flag(-Wsuggest-override)
check_enable_cxx_compiler_flag(-fdiagnostics-show-template-tree)
if(NOT MYX_CMAKE_WARNINGS_VERBOSE)
2022-10-07 08:22:07 +00:00
check_enable_cxx_compiler_flag(-Wno-float-conversion)
2022-10-07 05:03:56 +00:00
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "5.999")
check_enable_cxx_compiler_flag(-Wno-attributes)
endif()
check_enable_cxx_compiler_flag(-Wno-maybe-uninitialized)
endif()
endif()
endif()
endif()
if(MYX_CMAKE_WARNINGS_VERBOSE)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
check_enable_cxx_compiler_flag(-Wpointer-to-int-cast)
check_enable_cxx_compiler_flag(-Wuninitialized-const-reference)
check_enable_cxx_compiler_flag(-Wunused-but-set-parameter)
check_enable_cxx_compiler_flag(-Wunused-but-set-variable)
check_enable_cxx_compiler_flag(-Wnull-pointer-subtraction)
check_enable_cxx_compiler_flag(-Wno-reserved-identifier)
endif()
if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR
(CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
check_enable_cxx_compiler_flag(-Wshadow)
check_enable_cxx_compiler_flag(-Wpedantic)
check_enable_cxx_compiler_flag(-Wnoexcept)
check_enable_cxx_compiler_flag(-Wzero-as-null-pointer-constant)
# From GCC 6.
check_enable_cxx_compiler_flag(-Wshift-negative-value)
check_enable_cxx_compiler_flag(-Wshift-overflow=2)
check_enable_cxx_compiler_flag(-Wduplicated-cond)
check_enable_cxx_compiler_flag(-Wnull-dereference)
# From GCC 7.
check_enable_cxx_compiler_flag(-Wduplicated-branches)
check_enable_cxx_compiler_flag(-Wrestrict)
check_enable_cxx_compiler_flag(-Waligned-new)
# From GCC 8.
check_enable_cxx_compiler_flag(-Wcast-align=strict)
# From GCC 10.
check_enable_cxx_compiler_flag(-Wmismatched-tags)
check_enable_cxx_compiler_flag(-Wredundant-tags)
# From GCC 12.
check_enable_cxx_compiler_flag(-Warray-compare)
check_enable_cxx_compiler_flag(-Wmissing-requires)
endif()
endif()