Move most strict warning flags to the default build flags.
This moves all the warnings flags from the strict build to the regular build, except for -Werror. This means that the only difference between strict builds and non-strict builds will be if warnings are turned into errors.
This commit is contained in:
parent
c3e9e816e9
commit
49b6ede463
4 changed files with 22 additions and 37 deletions
|
@ -199,19 +199,16 @@ if(NOT DEFINED CXX_FLAGS_USER)
|
|||
|
||||
endif(NOT DEFINED CXX_FLAGS_USER)
|
||||
|
||||
set(COMPILER_FLAGS "-std=c++11 -Wall -Wextra -Werror=non-virtual-dtor")
|
||||
set(COMPILER_FLAGS "-std=c++11 -Wall -Wextra -Werror=non-virtual-dtor -Wno-unused-local-typedefs -Wno-maybe-uninitialized -Wold-style-cast")
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Qunused-arguments -Wno-unknown-warning-option -Wmismatched-tags -Wno-conditional-uninitialized")
|
||||
endif()
|
||||
|
||||
### Set strict compiler flags.
|
||||
|
||||
if(ENABLE_STRICT_COMPILATION)
|
||||
set(CXX_FLAGS_STRICT_COMPILATION "-Werror -Wno-unused-local-typedefs -Wno-maybe-uninitialized -Wold-style-cast")
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(CXX_FLAGS_STRICT_COMPILATION "${CXX_FLAGS_STRICT_COMPILATION} -Wmismatched-tags -Wno-conditional-uninitialized")
|
||||
endif()
|
||||
|
||||
set(COMPILER_FLAGS "${COMPILER_FLAGS} ${CXX_FLAGS_STRICT_COMPILATION}")
|
||||
|
||||
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Werror")
|
||||
endif(ENABLE_STRICT_COMPILATION)
|
||||
|
||||
### Set pedantic compiler flags.
|
||||
|
@ -230,10 +227,6 @@ endif(ENABLE_PEDANTIC_COMPILATION)
|
|||
|
||||
### Set the final compiler flags.
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
set(COMPILER_FLAGS "${COMPILER_FLAGS} -Qunused-arguments -Wno-unknown-warning-option")
|
||||
endif()
|
||||
|
||||
set(COMPILER_FLAGS "${COMPILER_FLAGS} ${CXX_FLAGS_USER}")
|
||||
|
||||
if(NOT "${CMAKE_CXX_FLAGS}" STREQUAL "${COMPILER_FLAGS}")
|
||||
|
|
13
SConstruct
13
SConstruct
|
@ -322,7 +322,7 @@ env.PrependENVPath('LD_LIBRARY_PATH', env["boostlibdir"])
|
|||
|
||||
# Some tests require at least C++11
|
||||
if "gcc" in env["TOOLS"]:
|
||||
env.AppendUnique(CCFLAGS = Split("-Wall -Wextra -Werror=non-virtual-dtor"), CFLAGS = ["-std=c99"])
|
||||
env.AppendUnique(CCFLAGS = Split("-Wall -Wextra -Werror=non-virtual-dtor"))
|
||||
env.AppendUnique(CXXFLAGS = "-std=c++" + env["cxx_std"])
|
||||
|
||||
if env["prereqs"]:
|
||||
|
@ -472,17 +472,16 @@ for env in [test_env, client_env, env]:
|
|||
|
||||
if "clang" in env["CXX"]:
|
||||
# Silence warnings about unused -I options and unknown warning switches.
|
||||
env.AppendUnique(CCFLAGS = Split("-Qunused-arguments -Wno-unknown-warning-option"))
|
||||
if env['strict']:
|
||||
env.AppendUnique(CCFLAGS = Split("-Wmismatched-tags -Wno-conditional-uninitialized"))
|
||||
env.AppendUnique(CCFLAGS = Split("-Qunused-arguments -Wno-unknown-warning-option -Wmismatched-tags -Wno-conditional-uninitialized"))
|
||||
|
||||
if "gcc" in env["TOOLS"]:
|
||||
if env['openmp']:
|
||||
env.AppendUnique(CXXFLAGS = ["-fopenmp"], LIBS = ["gomp"])
|
||||
|
||||
|
||||
env.AppendUnique(CCFLAGS = Split("-Wno-unused-local-typedefs -Wno-maybe-uninitialized -Wold-style-cast"))
|
||||
|
||||
if env['strict']:
|
||||
env.AppendUnique(CCFLAGS = Split("-Werror -Wno-unused-local-typedefs -Wno-maybe-uninitialized"))
|
||||
env.AppendUnique(CXXFLAGS = Split("-Wold-style-cast"))
|
||||
env.AppendUnique(CCFLAGS = Split("-Werror"))
|
||||
if env['sanitize']:
|
||||
env.AppendUnique(CCFLAGS = ["-fsanitize=" + env["sanitize"]], LINKFLAGS = ["-fsanitize=" + env["sanitize"]])
|
||||
|
||||
|
|
|
@ -206,22 +206,12 @@ add_library(lua ${LIBRARY_TYPE} EXCLUDE_FROM_ALL ${lua_STAT_SRC})
|
|||
# Disable the setting of -Wold-style-cast on some targets.
|
||||
# old style casts are not wanted by our coding style but some C based code
|
||||
# uses it. Force the flag off for these files.
|
||||
if(ENABLE_STRICT_COMPILATION)
|
||||
set(CXX_FLAG_NO_OLD_STYLE_CAST "-Wno-old-style-cast")
|
||||
endif()
|
||||
set_target_properties(lua
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS
|
||||
"-Wno-old-style-cast -Wno-useless-cast"
|
||||
)
|
||||
|
||||
if(ENABLE_PEDANTIC_COMPILATION)
|
||||
set(CXX_FLAG_NO_USELESS_CAST "-Wno-useless-cast")
|
||||
endif()
|
||||
|
||||
if(ENABLE_STRICT_COMPILATION OR ENABLE_PEDANTIC_COMPILATION)
|
||||
MESSAGE("Adding flags to lua target: ${CXX_FLAG_NO_OLD_STYLE_CAST} ${CXX_FLAG_NO_USELESS_CAST}")
|
||||
set_target_properties(lua
|
||||
PROPERTIES
|
||||
COMPILE_FLAGS
|
||||
"${CXX_FLAG_NO_OLD_STYLE_CAST} ${CXX_FLAG_NO_USELESS_CAST}"
|
||||
)
|
||||
endif()
|
||||
|
||||
########### Helper libraries ###############
|
||||
|
||||
|
|
|
@ -99,12 +99,15 @@ libwesnoth_client = client_env.Library("wesnoth-client", wesnoth_client_sources)
|
|||
lua_sources = GetSources("lua")
|
||||
|
||||
env_lua = env.Clone(
|
||||
# Silence some Clang-specific warnings due to extra parentheses in if statements when comparing.
|
||||
CCFLAGS = ["$CCFLAGS", "clang" in env["CXX"] and Split("-Wno-parentheses-equality -Wno-pointer-bool-conversion") or [], "strict" in env and Split("-Wno-old-style-cast -Wno-useless-cast") or []],
|
||||
CCCOM = env["CXXCOM"],
|
||||
CPPPATH = ["$CPPPATH", Dir(".").srcnode()],
|
||||
CPPDEFINES = ["$CPPDEFINES", env["PLATFORM"] != "win32" and "LUA_USE_POSIX" or []])
|
||||
|
||||
env_lua.AppendUnique(CCFLAGS = Split("-Wno-old-style-cast -Wno-useless-cast"))
|
||||
# Silence some Clang-specific warnings due to extra parentheses in if statements when comparing.
|
||||
if "clang" in env["CXX"]:
|
||||
env_lua.AppendUnique(CCFLAGS = Split("-Wno-parentheses-equality"))
|
||||
|
||||
if env_lua["enable_lto"] == True:
|
||||
env_lua["AR"] = 'gcc-ar'
|
||||
env_lua["RANLIB"] = 'gcc-ranlib'
|
||||
|
|
Loading…
Add table
Reference in a new issue