2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-10 23:20:58 +00:00

Handle warning flags better

Make --enable-werror work properly on msvc, handle extra warnings
flags for msvc in configure.ac instead of hardcoding into
make/msvc.mk, separate warnings flags into WFLAGS in autoconf.mk to
avoid duplication and to make it easier to override.
This commit is contained in:
Jay Berkenbilt 2013-01-24 11:18:28 -05:00
parent 32b62035ce
commit a11081085b
7 changed files with 55 additions and 46 deletions

View File

@ -25,6 +25,15 @@
2013-01-24 Jay Berkenbilt <ejb@ql.org> 2013-01-24 Jay Berkenbilt <ejb@ql.org>
* Make --enable-werror work for MSVC, and generally handle warning
options better for that compiler. Warning flags for that compiler
were previous hard-coded into the build with /WX enabled
unconditionally.
* Split warning flags into WFLAGS in autoconf.mk to make them
easier to override. Before they were repeated in CFLAGS and
CXXFLAGS and were commingled with other compiler flags.
* qpdf --check now does syntactic checks all pages' content * qpdf --check now does syntactic checks all pages' content
streams as well as checking overall document structure. Semantic streams as well as checking overall document structure. Semantic
errors are still not checked, and there are no plans to add errors are still not checked, and there are no plans to add

View File

@ -12,12 +12,13 @@ docdir=@docdir@
htmldir=@htmldir@ htmldir=@htmldir@
pdfdir=@pdfdir pdfdir=@pdfdir
CC=@CC@ CC=@CC@
CFLAGS=@CFLAGS@ WFLAGS=@WFLAGS@
CFLAGS=@CFLAGS@ $(WFLAGS)
LDFLAGS=@LDFLAGS@ LDFLAGS=@LDFLAGS@
LIBS=@LIBS@ LIBS=@LIBS@
CPPFLAGS=@CPPFLAGS@ CPPFLAGS=@CPPFLAGS@
CXX=@CXX@ CXX=@CXX@
CXXFLAGS=@CXXFLAGS@ CXXFLAGS=@CXXFLAGS@ $(WFLAGS)
AR=@AR@ AR=@AR@
RANLIB=@RANLIB@ RANLIB=@RANLIB@
DLLTOOL=@DLLTOOL@ DLLTOOL=@DLLTOOL@

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
./configure --disable-test-compare-images --enable-external-libs --with-windows-wordsize=32 --with-buildrules=mingw ./configure --disable-test-compare-images --enable-external-libs --enable-werror --with-windows-wordsize=32 --with-buildrules=mingw
# As of autoconf 2.69 and gcc 4.6, autoconf's configure fails to # As of autoconf 2.69 and gcc 4.6, autoconf's configure fails to
# recognize that defining _FILE_OFFSET_BITS works with mingw32. # recognize that defining _FILE_OFFSET_BITS works with mingw32.
# Append to qpdf-config.h rather than passing CPPFLAGS on the # Append to qpdf-config.h rather than passing CPPFLAGS on the

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
./configure --disable-test-compare-images --enable-external-libs --with-windows-wordsize=64 --with-buildrules=mingw \ ./configure --disable-test-compare-images --enable-external-libs --enable-werror --with-windows-wordsize=64 --with-buildrules=mingw \
CC=x86_64-w64-mingw32-gcc \ CC=x86_64-w64-mingw32-gcc \
CXX=x86_64-w64-mingw32-g++ \ CXX=x86_64-w64-mingw32-g++ \
LD=x86_64-w64-mingw32-ld \ LD=x86_64-w64-mingw32-ld \

View File

@ -8,4 +8,4 @@ objdump=
if test "$wordsize" = "64"; then if test "$wordsize" = "64"; then
objdump=OBJDUMP=x86_64-w64-mingw32-objdump objdump=OBJDUMP=x86_64-w64-mingw32-objdump
fi fi
CC=cl CXX="cl -TP -GR" ./configure --disable-test-compare-images --enable-external-libs --with-windows-wordsize=$wordsize --with-buildrules=msvc $objdump CC=cl CXX="cl -TP -GR" ./configure --disable-test-compare-images --enable-external-libs --enable-werror --with-windows-wordsize=$wordsize --with-buildrules=msvc $objdump

View File

@ -175,39 +175,48 @@ AC_ARG_WITH(buildrules,
[BUILDRULES=libtool]) [BUILDRULES=libtool])
AC_MSG_RESULT($BUILDRULES) AC_MSG_RESULT($BUILDRULES)
if test "$BUILDRULES" != "msvc"; then AC_SUBST(WFLAGS)
qpdf_USE_WALL=0 qpdf_USE_EXTRA_WARNINGS=0
AC_MSG_CHECKING(for whether $CC supports -Wall) if test "$BUILDRULES" = "msvc"; then
oCFLAGS=$CFLAGS dnl /w14267 makes warning 4267 a level 1 warning. This warning reports
CFLAGS="$CFLAGS -Wall" dnl potential issues between size_t, off_t, and non-compatible integer
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int a = 1; int b = a; a = b;]])], dnl types.
[qpdf_USE_WALL=1],[qpdf_USE_WALL=0]) try_flags="/w14267"
if test "$qpdf_USE_WALL" = "1"; then else
AC_MSG_RESULT(yes) try_flags="-Wall"
CXXFLAGS="$CXXFLAGS -Wall" fi
else AC_MSG_CHECKING(for whether $CC supports $try_flags)
AC_MSG_RESULT(no) oCFLAGS=$CFLAGS
CFLAGS=$oCFLAGS CFLAGS="$CFLAGS $try_flags"
fi AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[int a = 1; int b = a; a = b;]])],
[qpdf_USE_EXTRA_WARNINGS=1],[qpdf_USE_EXTRA_WARNINGS=0])
CFLAGS=$oCFLAGS
if test "$qpdf_USE_EXTRA_WARNINGS" = "1"; then
AC_MSG_RESULT(yes)
WFLAGS="$try_flags"
else
AC_MSG_RESULT(no)
fi fi
if test "$BUILDRULES" != "msvc"; then if test "$BUILDRULES" = "msvc"; then
AC_MSG_CHECKING(for whether to use -Werror) try_flags="/WX"
AC_ARG_ENABLE(werror, else
AS_HELP_STRING([--enable-werror], try_flags="-Werror"
[whether to use werror (default is no)]), fi
[if test "$enableval" = "yes"; then AC_MSG_CHECKING(for whether to use $try_flags)
qpdf_USE_WERROR=1; AC_ARG_ENABLE(werror,
else AS_HELP_STRING([--enable-werror],
qpdf_USE_WERROR=0; [whether to treat warnings as errors (default is no)]),
fi], [qpdf_USE_WERROR=0]) [if test "$enableval" = "yes"; then
if test "$qpdf_USE_WERROR" = "1"; then qpdf_USE_WERROR=1;
AC_MSG_RESULT(yes) else
CFLAGS="$CFLAGS -Werror" qpdf_USE_WERROR=0;
CXXFLAGS="$CXXFLAGS -Werror" fi], [qpdf_USE_WERROR=0])
else if test "$qpdf_USE_WERROR" = "1"; then
AC_MSG_RESULT(no) AC_MSG_RESULT(yes)
fi WFLAGS="$WFLAGS $try_flags"
else
AC_MSG_RESULT(no)
fi fi
AC_SUBST(QPDF_SKIP_TEST_COMPARE_IMAGES) AC_SUBST(QPDF_SKIP_TEST_COMPARE_IMAGES)

View File

@ -19,16 +19,6 @@ endef
CFLAGS := $(filter-out -g,$(CFLAGS)) CFLAGS := $(filter-out -g,$(CFLAGS))
CXXFLAGS := $(filter-out -g,$(CXXFLAGS)) CXXFLAGS := $(filter-out -g,$(CXXFLAGS))
# /WX makes all warnings errors.
CFLAGS += /WX
CXXFLAGS += /WX
# /w14267 makes warning 4267 a level 1 warning. This warning reports
# potential issues between size_t, off_t, and non-compatible integer
# types.
CFLAGS += /w14267
CXXFLAGS += /w14267
clean:: clean::
$(RM) *.pdb $(RM) *.pdb