Fixed compilation issue due to gcc4.8
[alexxy/gromacs.git] / cmake / gmxCFlags.cmake
index 1cf5dafe4cb89ce6ad5bc5ac4e20db36737ffe75..6c12a775cd92e17d35df56415c46be1a86a240e9 100644 (file)
@@ -90,7 +90,16 @@ MACRO(gmx_c_flags)
         if(NOT GMX_OPENMP)
             GMX_TEST_CXXFLAG(CXXFLAGS_PRAGMA "-Wno-unknown-pragmas" GMXC_CXXFLAGS)
         endif()
-        GMX_TEST_CXXFLAG(CXXFLAGS_WARN "-Wall -Wno-unused -Wunused-value" GMXC_CXXFLAGS)
+        if (CXX_COMPILER_VERSION VERSION_EQUAL 4.8 OR CXX_COMPILER_VERSION VERSION_GREATER 4.8)
+            # In gcc 4.8 the default settings for many warning types
+            # were changed. Fixing many of them in C is at best
+            # awkward, and some of the fixes might require ABI
+            # changes, which we prefer not to do in a bugfix
+            # branch. So we introduce these workarounds, and plan to
+            # addess problems in master branch.
+            set(extra_warn_flags_for_gxx_4_8 " -Wno-unused-parameter -Wno-array-bounds -Wno-maybe-uninitialized -Wno-strict-overflow")
+        endif()
+        GMX_TEST_CXXFLAG(CXXFLAGS_WARN "-Wall -Wno-unused -Wunused-value${extra_warn_flags_for_gxx_4_8}" GMXC_CXXFLAGS)
         GMX_TEST_CXXFLAG(CXXFLAGS_WARN_EXTRA "-Wextra -Wno-missing-field-initializers -Wno-sign-compare" GMXC_CXXFLAGS)
       # new in gcc 4.5
         GMX_TEST_CXXFLAG(CXXFLAGS_EXCESS_PREC "-fexcess-precision=fast" GMXC_CXXFLAGS_RELEASE)