From ade9f92a63ca3c2f4146018ce0baacdd36328f77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sat, 21 Nov 2020 00:59:17 +0100 Subject: [PATCH] Enable extra warnings in Source CMakeLists, not in root CMakeLists Having extra warnings enabled for everything including external libraries produces an overwhelming amount of warnings in code that isn't even part of our codebase. Move the various warning flags to Source/CMakeLists.txt to get rid of those useless warnings. Note that the Source CMakeLists.txt is already where the MSVC warnings are defined, so this commit improves consistency as well. --- CMakeLists.txt | 17 ----------------- Source/CMakeLists.txt | 20 +++++++++++++++++++- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1748ed9347..e67f469c94 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -248,23 +248,6 @@ if(CMAKE_C_COMPILER_ID MATCHES "MSVC") string(APPEND CMAKE_EXE_LINKER_FLAGS " /NXCOMPAT") else() add_definitions(-D_DEFAULT_SOURCE) - check_and_add_flag(HAVE_WALL -Wall) - # TODO: would like these but they produce overwhelming amounts of warnings - #check_and_add_flag(EXTRA -Wextra) - #check_and_add_flag(MISSING_FIELD_INITIALIZERS -Wmissing-field-initializers) - #check_and_add_flag(SWITCH_DEFAULT -Wswitch-default) - #check_and_add_flag(FLOAT_EQUAL -Wfloat-equal) - #check_and_add_flag(CONVERSION -Wconversion) - #check_and_add_flag(ZERO_AS_NULL_POINTER_CONSTANT -Wzero-as-null-pointer-constant) - check_and_add_flag(TYPE_LIMITS -Wtype-limits) - check_and_add_flag(SIGN_COMPARE -Wsign-compare) - check_and_add_flag(IGNORED_QUALIFIERS -Wignored-qualifiers) - check_and_add_flag(UNINITIALIZED -Wuninitialized) - check_and_add_flag(LOGICAL_OP -Wlogical-op) - check_and_add_flag(SHADOW -Wshadow) - check_and_add_flag(INIT_SELF -Winit-self) - check_and_add_flag(MISSING_DECLARATIONS -Wmissing-declarations) - check_and_add_flag(MISSING_VARIABLE_DECLARATIONS -Wmissing-variable-declarations) # gcc uses some optimizations which might break stuff without this flag check_and_add_flag(NO_STRICT_ALIASING -fno-strict-aliasing) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 015b03f882..df91f4b668 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -62,10 +62,28 @@ if (MSVC) # Use PCH add_subdirectory(PCH) add_definitions(/I${PCH_DIRECTORY}) - add_definitions(/Yu${PCH_PATH}) + add_definitions(/Yu${PCH_PATH}) # Don't include timestamps in binaries add_link_options(/Brepro) +else() + check_and_add_flag(HAVE_WALL -Wall) + # TODO: would like these but they produce overwhelming amounts of warnings + #check_and_add_flag(EXTRA -Wextra) + #check_and_add_flag(MISSING_FIELD_INITIALIZERS -Wmissing-field-initializers) + #check_and_add_flag(SWITCH_DEFAULT -Wswitch-default) + #check_and_add_flag(FLOAT_EQUAL -Wfloat-equal) + #check_and_add_flag(CONVERSION -Wconversion) + #check_and_add_flag(ZERO_AS_NULL_POINTER_CONSTANT -Wzero-as-null-pointer-constant) + check_and_add_flag(TYPE_LIMITS -Wtype-limits) + check_and_add_flag(SIGN_COMPARE -Wsign-compare) + check_and_add_flag(IGNORED_QUALIFIERS -Wignored-qualifiers) + check_and_add_flag(UNINITIALIZED -Wuninitialized) + check_and_add_flag(LOGICAL_OP -Wlogical-op) + check_and_add_flag(SHADOW -Wshadow) + check_and_add_flag(INIT_SELF -Winit-self) + check_and_add_flag(MISSING_DECLARATIONS -Wmissing-declarations) + check_and_add_flag(MISSING_VARIABLE_DECLARATIONS -Wmissing-variable-declarations) endif() # These aren't actually needed for C11/C++11