diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -132,8 +132,10 @@ # Enable stack protection add_cxx_compiler_flags(-fstack-protector-all -Wstack-protector) - # Enable some buffer overflow checking - add_compiler_flags(-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2) + # Enable some buffer overflow checking, except in -O0 builds which + # do not support them + add_compiler_flags(-U_FORTIFY_SOURCE) + add_compile_options($<$>:-D_FORTIFY_SOURCE=2>) # Enable ASLR (these flags are primarily targeting MinGw) add_linker_flags(-Wl,--dynamicbase -Wl,--nxcompat -Wl,--high-entropy-va) @@ -203,10 +205,15 @@ if(ENABLE_WERROR) add_compiler_flags( - -Werror=return-type - -Werror=switch - -Werror=thread-safety-analysis - -Werror=vla + # turns warnings into errors + -Werror + # except for the following + -Wno-error=cast-align + -Wno-error=deprecated-copy + -Wno-error=deprecated-declarations + -Wno-error=implicit-int-float-conversion + -Wno-error=maybe-uninitialized + -Wno-error=stringop-truncation ) endif()