[PATCH] Detect good set of warninig flags for C++ compiler
- From: Santtu Lakkala <inz inz fi>
- To: easytag-list gnome org
- Subject: [PATCH] Detect good set of warninig flags for C++ compiler
- Date: Fri, 11 Apr 2014 12:07:38 +0300
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 deletion(-)
diff --git a/Makefile.am b/Makefile.am
index e2c0b8d..b2c5409 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 032677c..a72262f 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
--
1.8.3.2
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]