On 11/09/17 20:30, Albert Astals Cid wrote:
> El diumenge, 10 de setembre de 2017, a les 20:39:18 CEST, Adrian Johnson va
> escriure:
>> Also in PopplerMacros.cmake there are three levels of warning options:
>> "no", "yes", and "kde". Is there any reason we can't have one standard
>> set of warning options? I can't think of any reason for wanting to turn
>> off warnings. If anyone needs some extra warnings they can be added with
>> CXXFLAGS.
>
> We have the same in configure.ac:1154
>
> I'm more than happy to have a single good set of warnings we agree on.
I've had a go at coming up with a list of warnings. I have made the
following warnings default as the compile is reasonably clean.
-Wall -Wextra -Wpedantic
-Wno-unused-parameter -Wno-missing-field-initializers
-Wcast-align
-Wformat-security
-Wframe-larger-than=65536
-Wlogical-op
-Wmissing-format-attribute
-Wnon-virtual-dtor
-Woverloaded-virtual
-Wsuggest-override
-Wextra and -Wpedantic produced a fairly clean compile after I disabled
-Wunused-parameter and -Wmissing-field-initializers. Most of the other
warnings are existing warnings (either "yes" or "kde" options). I added
-Wlogical-op as it helps avoid mixing logical and bitwise ops. I added
-Wframe-larger-than=65536 because if the stack frame is larger than this
you are doing something wrong (largest currently is 52K in splash).
I've replaced the COMPILE_WARNINGS option with an EXTRA_WARN boolean
option default to off. When on it enables:
-Wconversion
-Wmissing-declarations
-Wshadow
-Wundef
-Wuseless-cast
-Wzero-as-null-pointer-constant
These produce a lot of warnings. Most of them probably should be fixed.
All of the "kde" warnings except -Wlong-long are included in the above
two sets of warnings. Some of them are part of "-Wall -Wextra
-Wpedantic" so I have removed them from the list. The
"-D_XOPEN_SOURCE=600 -D_BSD_SOURCE" is deprecated by "-D_DEFAULT_SOURCE".
If we can either fix the extra warnings or decide not to care about some
of them, they can be moved to default or removed and the EXTRA_WARN
option can be removed.
>
> Cheers,
> Albert
> _______________________________________________
> poppler mailing list
> [email protected]
> https://lists.freedesktop.org/mailman/listinfo/poppler
>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c094d5ec..4288be38 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -56,6 +56,7 @@ if(WIN32)
else()
set(ENABLE_RELOCATABLE OFF)
endif()
+option(EXTRA_WARN "Enable extra compile warnings" OFF)
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)")
set(SHARE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share" CACHE STRING "Share directory name")
@@ -335,21 +336,12 @@ if(NOT DEFINED POPPLER_DATADIR)
set(POPPLER_DATADIR "${CMAKE_INSTALL_PREFIX}/share/poppler")
endif()
-if(DEFINED COMPILE_WARNINGS)
-else()
- set(COMPILE_WARNINGS "yes")
-endif()
-string(TOLOWER "${COMPILE_WARNINGS}" _comp_warnings)
-if(_comp_warnings STREQUAL "no")
- set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS_NO} ${CMAKE_CXX_FLAGS}")
-endif()
-if(_comp_warnings STREQUAL "yes")
+if(EXTRA_WARN)
set(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}")
- set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS_YES} ${CMAKE_CXX_FLAGS}")
-endif()
-if(_comp_warnings STREQUAL "kde")
+ set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS_EXTRA} ${CMAKE_CXX_FLAGS}")
+else()
set(CMAKE_C_FLAGS "-Wall ${CMAKE_C_FLAGS}")
- set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS_KDE} ${CMAKE_CXX_FLAGS}")
+ set(CMAKE_CXX_FLAGS "${DEFAULT_COMPILE_WARNINGS} ${CMAKE_CXX_FLAGS}")
endif()
diff --git a/cmake/modules/PopplerMacros.cmake b/cmake/modules/PopplerMacros.cmake
index 442e7ee5..2f06caf1 100644
--- a/cmake/modules/PopplerMacros.cmake
+++ b/cmake/modules/PopplerMacros.cmake
@@ -99,17 +99,31 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
if(CMAKE_COMPILER_IS_GNUCXX)
- if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0.0")
- set(CMAKE_CXX_FLAGS "-Wsuggest-override ${CMAKE_CXX_FLAGS}" )
- endif()
-
# set the default compile warnings
- set(DEFAULT_COMPILE_WARNINGS_NO)
- set(DEFAULT_COMPILE_WARNINGS_YES "-Wall -Wcast-align -fno-exceptions -fno-check-new -fno-common")
- set(DEFAULT_COMPILE_WARNINGS_KDE "-Wno-long-long -Wundef -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -Wcast-align -Wconversion -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-exceptions -fno-check-new -fno-common")
+ set(_warn "-Wall -Wextra -Wpedantic")
+ set(_warn "${_warn} -Wno-unused-parameter -Wno-missing-field-initializers")
+ set(_warn "${_warn} -Wcast-align")
+ set(_warn "${_warn} -Wformat-security")
+ set(_warn "${_warn} -Wframe-larger-than=65536")
+ set(_warn "${_warn} -Wlogical-op")
+ set(_warn "${_warn} -Wmissing-format-attribute")
+ set(_warn "${_warn} -Wnon-virtual-dtor")
+ set(_warn "${_warn} -Woverloaded-virtual")
+ set(_warn "${_warn} -Wsuggest-override")
+
+ # set extra warnings
+ set(_warnx "${_warnx} -Wconversion")
+ set(_warnx "${_warnx} -Wmissing-declarations")
+ set(_warnx "${_warnx} -Wshadow")
+ set(_warnx "${_warnx} -Wundef")
+ set(_warnx "${_warnx} -Wuseless-cast")
+ set(_warnx "${_warnx} -Wzero-as-null-pointer-constant")
+
+ set(DEFAULT_COMPILE_WARNINGS "${_warn}")
+ set(DEFAULT_COMPILE_WARNINGS_EXTRA "${_warn} ${_warnx}")
set(_save_cxxflags "${CMAKE_CXX_FLAGS}")
- set(CMAKE_CXX_FLAGS "-Wnon-virtual-dtor -Woverloaded-virtual -D_DEFAULT_SOURCE")
+ set(CMAKE_CXX_FLAGS "-fno-exceptions -fno-check-new -fno-common -D_DEFAULT_SOURCE")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g ${_save_cxxflags}")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG ${_save_cxxflags}")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline ${_save_cxxflags}")
_______________________________________________
poppler mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/poppler