2020-05-09 22:59:34 +00:00
|
|
|
# Our principle is to enable as many warnings as possible and always do it with "warnings as errors" flag.
|
|
|
|
#
|
|
|
|
# But it comes with some cost:
|
|
|
|
# - we have to disable some warnings in 3rd party libraries (they are located in "contrib" directory)
|
|
|
|
# - we have to include headers of these libraries as -isystem to avoid warnings from headers
|
|
|
|
# (this is the same behaviour as if these libraries were located in /usr/include)
|
|
|
|
# - sometimes warnings from 3rd party libraries may come from macro substitutions in our code
|
|
|
|
# and we have to wrap them with #pragma GCC/clang diagnostic ignored
|
|
|
|
|
2022-05-12 18:07:41 +00:00
|
|
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
|
2020-05-09 22:59:34 +00:00
|
|
|
|
2020-06-08 17:35:45 +00:00
|
|
|
# Control maximum size of stack frames. It can be important if the code is run in fibers with small stack size.
|
2020-08-02 21:10:57 +00:00
|
|
|
# Only in release build because debug has too large stack frames.
|
2020-11-27 16:33:16 +00:00
|
|
|
if ((NOT CMAKE_BUILD_TYPE_UC STREQUAL "DEBUG") AND (NOT SANITIZE) AND (NOT CMAKE_CXX_COMPILER_ID MATCHES "AppleClang"))
|
2020-12-04 02:15:44 +00:00
|
|
|
add_warning(frame-larger-than=65536)
|
2020-08-02 21:10:57 +00:00
|
|
|
endif ()
|
2020-06-08 17:35:45 +00:00
|
|
|
|
2020-05-09 22:59:34 +00:00
|
|
|
if (COMPILER_CLANG)
|
2022-05-20 00:12:44 +00:00
|
|
|
# Add some warnings that are not available even with -Wall -Wextra -Wpedantic.
|
|
|
|
# We want to get everything out of the compiler for code quality.
|
2022-05-16 18:44:24 +00:00
|
|
|
add_warning(everything)
|
2020-05-09 22:59:34 +00:00
|
|
|
add_warning(pedantic)
|
|
|
|
no_warning(zero-length-array)
|
2022-05-16 18:44:24 +00:00
|
|
|
no_warning(c++98-compat-pedantic)
|
|
|
|
no_warning(c++98-compat)
|
2022-08-11 11:27:53 +00:00
|
|
|
no_warning(c++20-compat) # Use constinit in C++20 without warnings
|
2022-09-10 02:34:56 +00:00
|
|
|
no_warning(sign-conversion)
|
|
|
|
no_warning(implicit-int-conversion)
|
|
|
|
no_warning(implicit-int-float-conversion)
|
2022-05-16 18:44:24 +00:00
|
|
|
no_warning(ctad-maybe-unsupported) # clang 9+, linux-only
|
|
|
|
no_warning(disabled-macro-expansion)
|
|
|
|
no_warning(documentation-unknown-command)
|
|
|
|
no_warning(double-promotion)
|
|
|
|
no_warning(exit-time-destructors)
|
|
|
|
no_warning(float-equal)
|
|
|
|
no_warning(global-constructors)
|
|
|
|
no_warning(missing-prototypes)
|
|
|
|
no_warning(missing-variable-declarations)
|
|
|
|
no_warning(padded)
|
|
|
|
no_warning(switch-enum)
|
|
|
|
no_warning(undefined-func-template)
|
|
|
|
no_warning(unused-template)
|
|
|
|
no_warning(vla)
|
|
|
|
no_warning(weak-template-vtables)
|
|
|
|
no_warning(weak-vtables)
|
2022-06-14 22:35:55 +00:00
|
|
|
no_warning(thread-safety-negative) # experimental flag, too many false positives
|
2022-08-13 04:06:01 +00:00
|
|
|
no_warning(enum-constexpr-conversion) # breaks magic-enum library in clang-16
|
2023-02-28 14:45:33 +00:00
|
|
|
no_warning(unsafe-buffer-usage) # too aggressive
|
2022-05-16 18:44:24 +00:00
|
|
|
# TODO Enable conversion, sign-conversion, double-promotion warnings.
|
2020-05-09 22:59:34 +00:00
|
|
|
endif ()
|