Merge lp:~hjd/widelands/compilation-warnings into lp:widelands

Proposed by Hans Joachim Desserud
Status: Merged
Merged at revision: 6480
Proposed branch: lp:~hjd/widelands/compilation-warnings
Merge into: lp:widelands
Diff against target: 52 lines (+19/-9)
1 file modified
CMakeLists.txt (+19/-9)
To merge this branch: bzr merge lp:~hjd/widelands/compilation-warnings
Reviewer Review Type Date Requested Status
Widelands Developers Pending
Review via email: mp+141946@code.launchpad.net

Description of the change

Related to the intial investigation of additional warnings in bug 1033615.

* WL_EXTRAWARNINGS doesn't exist anymore. If it is specified, cmake will warn it is an unused parameter. I have the impression very few people are using this, so I would rather move the warnings to the default configuration. I guess it was split out like this because -Wextra used to be extremely noise (several thousand extra lines).

* Warnings are grouped in three categories; generic, extra and gcc. Generic are the base warnings (-Wall -Wextra), extra adds additional warnings and gcc attempts to add warnings only availble in gcc.
Extra doesn't add a lot at the moment, but we might expand this in the future depending on the feedback on the bug report. Gcc has so far only added -Wlogical-op, mainly because it has already found a bug.

It is split this way because if an unknown warning is encountered, none of them is applied. This way, -Wall -Wextra should always be applied, if extra applies we get those warnings too and if it doesn't it will inform the user, and if the gcc warnings applies they are added too. In other words, if some of the extra warnings are not availble due to older compiler version or similar, we will always get a good base set of warnings. One thing I would like to see in the future is some way to check and add warnings individually so we get as many as possible. Maybe we could loop through the parameters sent to the compiler and only keep the ones supported.

This will be a gradual process though, as we figure out which warnings we want to add and which we want to silence. I think this is a good starting point though, and give us something we can build further upon.

I've rebuilt Widelands with both GCC and Clang with this revision, they both behave as expected and I got the same list of warnings as the previous run I uploaded to the warning bug reports.

PS. -Wno-attributes was removed because it didn't have any impact on the outcome. Were these warnings ignored due to false positives in the past?

To post a comment you must log in.
Revision history for this message
SirVer (sirver) wrote :

A good idea i think. I merged this and have not seen any problems with building widelands so far. Testing for individual warnings will likely need a script to probe the compiler for what it supports.

-Wno-attributes was added by me IIRC because compilation on old gcc version made some noisy output because we use attribute hot in some places. My memory might fail me though, I am an old man after all.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2012-11-30 18:16:47 +0000
+++ CMakeLists.txt 2013-01-04 15:56:24 +0000
@@ -157,8 +157,9 @@
157157
158set (PARAMETER_COMPILERFLAG_OLDSTYLECAST_EXTENDED "-Wold-style-cast -isystem ${Boost_INCLUDE_DIR}")158set (PARAMETER_COMPILERFLAG_OLDSTYLECAST_EXTENDED "-Wold-style-cast -isystem ${Boost_INCLUDE_DIR}")
159set (PARAMETER_COMPILERFLAG_OLDSTYLECAST "-Wold-style-cast")159set (PARAMETER_COMPILERFLAG_OLDSTYLECAST "-Wold-style-cast")
160set (PARAMETER_COMPILERFLAG_GENERICWARNINGS "-Wno-attributes -Wall")160set (PARAMETER_COMPILERFLAG_GENERICWARNINGS "-Wall -Wextra")
161set (PARAMETER_COMPILERFLAG_EXTRAWARNINGS "-Wextra -Wsign-promo")161set (PARAMETER_COMPILERFLAG_EXTRAWARNINGS "-Wsign-promo")
162set (PARAMETER_COMPILERFLAG_GCCWARNINGS "-Wlogical-op")
162set (PARAMETER_COMPILERFLAG_STRICT "-Werror -Wno-error=old-style-cast -Wno-error=deprecated-declarations -fdiagnostics-show-option")163set (PARAMETER_COMPILERFLAG_STRICT "-Werror -Wno-error=old-style-cast -Wno-error=deprecated-declarations -fdiagnostics-show-option")
163IF (CMAKE_BUILD_TYPE STREQUAL "Debug")164IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
164 include(CheckCXXCompilerFlag) #this include should be safe165 include(CheckCXXCompilerFlag) #this include should be safe
@@ -198,12 +199,21 @@
198 IF (Compiler_generic_warnings_supported)199 IF (Compiler_generic_warnings_supported)
199 set (WL_COMPILERFLAG_GENERICWARNINGS " ${PARAMETER_COMPILERFLAG_GENERICWARNINGS}") #the space is on purpose!200 set (WL_COMPILERFLAG_GENERICWARNINGS " ${PARAMETER_COMPILERFLAG_GENERICWARNINGS}") #the space is on purpose!
200 ENDIF (Compiler_generic_warnings_supported)201 ENDIF (Compiler_generic_warnings_supported)
201 IF (WL_EXTRAWARNINGS)202
202 CHECK_CXX_COMPILER_FLAG(${PARAMETER_COMPILERFLAG_EXTRAWARNINGS} Compiler_extra_warnings_supported)203 CHECK_CXX_COMPILER_FLAG(${PARAMETER_COMPILERFLAG_EXTRAWARNINGS} Compiler_extra_warnings_supported)
203 IF (Compiler_extra_warnings_supported)204 IF (Compiler_extra_warnings_supported)
204 set (WL_COMPILERFLAG_EXTRAWARNINGS " ${PARAMETER_COMPILERFLAG_EXTRAWARNINGS}") #the space is on purpose!205 set (WL_COMPILERFLAG_EXTRAWARNINGS " ${PARAMETER_COMPILERFLAG_EXTRAWARNINGS}") #the space is on purpose!
205 ENDIF (Compiler_extra_warnings_supported)206 ELSE (Compiler_extra_warnings_supported)
206 ENDIF (WL_EXTRAWARNINGS)207 message("Warning: couldn't set the following compiler options: ${PARAMETER_COMPILERFLAG_EXTRAWARNINGS}. Most likely these options are available in a newer release of your compiler.")
208 ENDIF (Compiler_extra_warnings_supported)
209
210 CHECK_CXX_COMPILER_FLAG(${PARAMETER_COMPILERFLAG_GCCWARNINGS} Compiler_gcc_warnings_supported)
211 IF (Compiler_gcc_warnings_supported)
212 set (WL_COMPILERFLAG_GCCWARNINGS " ${PARAMETER_COMPILERFLAG_GCCWARNINGS}") #the space is on purpose!
213 ELSE (Compiler_gcc_warnings_supported)
214 message("Warning: could not add additional GCC-specific warning options: ${PARAMETER_COMPILERFLAG_GCCWARNINGS}. Most likely you are using a different compiler, like Clang/LLVM.")
215 ENDIF (Compiler_gcc_warnings_supported)
216
207217
208 IF (WL_STRICT)218 IF (WL_STRICT)
209 CHECK_CXX_COMPILER_FLAG(${PARAMETER_COMPILERFLAG_STRICT} Compiler_strict_mode_supported)219 CHECK_CXX_COMPILER_FLAG(${PARAMETER_COMPILERFLAG_STRICT} Compiler_strict_mode_supported)
@@ -215,7 +225,7 @@
215ENDIF (CMAKE_BUILD_TYPE STREQUAL "Debug")225ENDIF (CMAKE_BUILD_TYPE STREQUAL "Debug")
216226
217# CMAKE only defines "-g", but we need -DDEBUG also, and we need -DNOPARACHUTE (for SDL) in Debug227# CMAKE only defines "-g", but we need -DDEBUG also, and we need -DNOPARACHUTE (for SDL) in Debug
218set (CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG -DNOPARACHUTE${WL_COMPILERFLAG_OLDSTYLECAST}${WL_COMPILERFLAG_GENERICWARNINGS}${WL_COMPILERFLAG_EXTRAWARNINGS}${WL_COMPILERFLAG_STRICT}" CACHE STRING "Set by widelands CMakeLists.txt" FORCE)228set (CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG -DNOPARACHUTE${WL_COMPILERFLAG_OLDSTYLECAST}${WL_COMPILERFLAG_GENERICWARNINGS}${WL_COMPILERFLAG_EXTRAWARNINGS}${WL_COMPILERFLAG_GCCWARNINGS}${WL_COMPILERFLAG_STRICT}" CACHE STRING "Set by widelands CMakeLists.txt" FORCE)
219229
220#This can be removed if no one uses gcc 4.5.1 or 4.5.2 any more230#This can be removed if no one uses gcc 4.5.1 or 4.5.2 any more
221IF (CMAKE_COMPILER_IS_GNUCXX)231IF (CMAKE_COMPILER_IS_GNUCXX)

Subscribers

People subscribed via source and target branches

to status/vote changes: