[easytag/wip/help: 5/18] Detect good set of warning flags for C++ compiler



commit dd2ce06e05705ed3587dbbdfefff4fc15d1fd94a
Author: Santtu Lakkala <inz inz fi>
Date:   Fri Apr 11 12:07:38 2014 +0300

    Detect good set of warning flags for C++ compiler
    
    At least gcc's g++ does not like all warning flags that the C compiler
    does, so try them separately. Use -Werror to get failures, as the wrong
    flags only cause a warning.

 Makefile.am  |    2 +-
 configure.ac |   21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 01ca1ad..8065838 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -29,7 +29,7 @@ easytag_CFLAGS = \
        $(EASYTAG_CFLAGS)
 
 easytag_CXXFLAGS = \
-       $(WARN_CFLAGS) \
+       $(WARN_CXXFLAGS) \
        $(EASYTAG_CFLAGS)
 
 easytag_SOURCES = \
diff --git a/configure.ac b/configure.ac
index 68e83e7..2bc4d2d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -342,6 +342,26 @@ unset option
 CFLAGS="$realsave_CFLAGS"
 
 AC_SUBST([WARN_CFLAGS], ["$tested_warning_flags"])
+AC_LANG_PUSH([C++])
+
+realsave_CFLAGS="$CXXFLAGS"
+for option in $warning_flags; do
+    save_CFLAGS="$CXXFLAGS"
+    CXXFLAGS="$CXXFLAGS -Werror $option"
+       AC_MSG_CHECKING([whether the c++ compiler understands $option])
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [has_option=yes], [has_option=no])
+       CXXFLAGS="$save_CXXFLAGS"
+       AC_MSG_RESULT([$has_option])
+       AS_IF([test $has_option = yes],
+             [tested_cxx_warning_flags="$tested_cxx_warning_flags $option"])
+       unset has_option
+       unset save_CFLAGS
+done
+unset option
+CXXFLAGS="$realsave_CXXFLAGS"
+
+AC_LANG_POP([C++])
+AC_SUBST([WARN_CXXFLAGS], ["$tested_cxx_warning_flags"])
 AC_SUBST([DEPRECATED_CPPFLAGS], ["-DG_DISABLE_SINGLE_INCLUDES -DGTK_DISABLE_SINGLE_INCLUDES 
-DG_DISABLE_DEPRECATED $GTK_DEPRECATION_FLAGS"])
 
 dnl To enable 'gprof' profiling
@@ -383,6 +403,7 @@ echo Preprocessor ............: $CC $CPPFLAGS
 echo Deprecation defines .....: $DEPRECATED_CPPFLAGS
 echo Compiler ................: $CC $CFLAGS
 echo Compiler warnings .......: $WARN_CFLAGS
+echo C++ Compiler warnings ...: $WARN_CXXFLAGS
 echo Linker ..................: $CC $LDFLAGS $LIBS
 echo GTK version .............: `$PKG_CONFIG --modversion $GTK_DEPS`
 echo MP3 file support ........: $have_mp3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]