-
Notifications
You must be signed in to change notification settings - Fork 2
/
CXXWarnings.cmake
27 lines (22 loc) · 1.01 KB
/
CXXWarnings.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
LIST(APPEND CXXOPTS "-Wall" "-Wextra")
option(WERROR "Enable/disable -Werror compile flags" OFF)
IF(WERROR)
MESSAGE(STATUS "Enabling -Werror compile flag, turning warnings into errors")
LIST(APPEND CXXOPTS "-Werror")
endif()
IF(CMAKE_COMPILER_IS_GNUCC)
LIST(APPEND CXXOPTS "-Wpedantic" "-Wlogical-op" "-Wshadow" "-Wformat=2" "-pedantic-errors")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0")
# regression bug in gcc6.0,... throws warnings on inherited constructors
LIST(APPEND CXXOPTS "-Wuseless-cast")
else()
LIST(APPEND CXXOPTS "-Wduplicated-cond" "-Wmissing-include-dirs" "-Wredundant-decls"
"-Wnull-dereference" "-Wsuggest-override" "-Wuninitialized" "-Winit-self")
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "7.0")
LIST(APPEND CXXOPTS "-Wduplicated-branches" "-Woverloaded-virtual")
endif()
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.3")
LIST(APPEND CXXOPTS "-Wuseless-cast")
endif()
endif()
endif()