Add more warnings to compiler flags.

This commit is contained in:
tastytea 2019-10-25 05:59:13 +02:00
parent d19dc71e3a
commit 7c2e33949b
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 50 additions and 17 deletions

View File

@ -29,23 +29,56 @@ set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
set(DEBUG_CXXFLAGS set(DEBUG_CXXFLAGS "")
"-Wall" # GCC >= 5.0 or Clang >= 5.0 is assumed.
"-Wextra" if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
"-Wpedantic" list(APPEND DEBUG_CXXFLAGS
"-ftrapv" "-Wall"
"-fsanitize=undefined" "-Wextra"
"-g" "-Wpedantic"
"-Og" "-Wuninitialized"
"-fno-omit-frame-pointer") "-Wshadow"
set(DEBUG_LDFLAGS "-Wnon-virtual-dtor"
"-fsanitize=undefined") "-Wconversion"
add_compile_options("$<$<CONFIG:Debug>:${DEBUG_CXXFLAGS}>") "-Wsign-conversion"
# add_link_options was introduced in version 3.13. "-Wold-style-cast"
if(${CMAKE_VERSION} VERSION_LESS 3.13) "-Wzero-as-null-pointer-constant"
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${DEBUG_LDFLAGS}") # "-Wmissing-declarations"
else() "-Wcast-align"
add_link_options("$<$<CONFIG:Debug>:${DEBUG_LDFLAGS}>") "-Wunused"
"-Woverloaded-virtual"
"-Wdouble-promotion"
"-Wformat=2"
"-ftrapv"
"-fsanitize=undefined"
"-g"
"-Og"
"-fno-omit-frame-pointer")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
list(APPEND DEBUG_CXXFLAGS
"-Wlogical-op"
"-Wuseless-cast")
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6")
list(APPEND DEBUG_CXXFLAGS
"-Wmisleading-indentation"
"-Wduplicated-cond"
"-Wnull-dereference")
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "7")
list(APPEND DEBUG_CXXFLAGS
"-Wduplicated-branches")
endif()
endif()
endif()
set(DEBUG_LDFLAGS
"-fsanitize=undefined")
add_compile_options("$<$<CONFIG:Debug>:${DEBUG_CXXFLAGS}>")
# add_link_options was introduced in version 3.13.
if(${CMAKE_VERSION} VERSION_LESS 3.13)
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${DEBUG_LDFLAGS}")
else()
add_link_options("$<$<CONFIG:Debug>:${DEBUG_LDFLAGS}>")
endif()
endif() endif()
add_subdirectory(src) add_subdirectory(src)