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.
This commit is contained in:
Léo Lam 2020-11-21 00:59:17 +01:00
parent fa73b1a23f
commit ade9f92a63
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
2 changed files with 19 additions and 18 deletions

View File

@ -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)

View File

@ -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