[poppler] CMakeLists.txt cmake/modules

Adrian Johnson ajohnson at kemper.freedesktop.org
Sat Sep 16 10:56:57 UTC 2017


 CMakeLists.txt                    |   18 +++++-------------
 cmake/modules/PopplerMacros.cmake |   32 ++++++++++++++++++++++++--------
 2 files changed, 29 insertions(+), 21 deletions(-)

New commits:
commit 804a823a67fedc3e633e89f817232d3c15715b56
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sat Sep 16 20:16:58 2017 +0930

    cmake: restructure the warnings into a "default" and "extra" group
    
    Most of the previous warnings are now in default. Extra warnings that
    should be fixed but currently result in a lot of warnings are in the
    extra group.
    
    The old no/yes/kde COMPILE_WARNINGS option has been replaced with the
    boolean option EXTRA_WARN (default off) to enable the extra warnings.

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..bc24ed9f 100644
--- a/cmake/modules/PopplerMacros.cmake
+++ b/cmake/modules/PopplerMacros.cmake
@@ -99,17 +99,33 @@ 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")
+  if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0.0")
+    set(_warn "${_warn} -Wsuggest-override")
+  endif()
+
+  # 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}")


More information about the poppler mailing list