Silence warnings about scanner.cpp
authorMark Abraham <mark.j.abraham@gmail.com>
Tue, 29 Oct 2013 17:15:36 +0000 (18:15 +0100)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Wed, 30 Oct 2013 19:56:55 +0000 (20:56 +0100)
This file is generated, so it is awkward to suppress inline.
So we suppress on the compiler command line, and test to
make sure that will work cleanly.

Change-Id: I8d7b78d71f13fb91b900ff994e319f6360a4bb86

src/gromacs/CMakeLists.txt

index 3b40dbc374d1653514512b6ae5f59155d09d6f96..d0ee4bbfeb564579341cfb6b0c0bfba68bb9d835 100644 (file)
@@ -106,6 +106,23 @@ if (GMX_GIT_VERSION_INFO)
     add_dependencies(libgromacs gmx-version)
 endif ()
 
+# Recent versions of gcc and clang give warnings on scanner.cpp, which
+# is a generated source file. These are awkward to suppress inline, so
+# we do it in the compilation command (after testing that the compiler
+# supports the suppressions). Setting the properties only works after
+# the related target has been created, e.g. after when the file is
+# used with add_library().
+include(CheckCXXCompilerFlag)
+check_cxx_compiler_flag(-Wno-unused-parameter HAS_NO_UNUSED_PARAMETER)
+check_cxx_compiler_flag(-Wno-deprecated-register HAS_NO_DEPRECATED_REGISTER)
+if (HAS_NO_UNUSED_PARAMETER)
+    set(_scanner_cpp_compiler_flags "${_scanner_cpp_compiler_flags} -Wno-unused-parameter")
+endif()
+if (HAS_NO_DEPRECATED_REGISTER)
+    set(_scanner_cpp_compiler_flags "${_scanner_cpp_compiler_flags} -Wno-deprecated-register")
+endif()
+set_source_files_properties(selection/scanner.cpp PROPERTIES COMPILE_FLAGS "${_scanner_cpp_compiler_flags}")
+
 if(GMX_BUILD_OWN_FFTW)
     # Only needed for cmake 2.8.7, otherwise this should be automatic
     # This dependency has to be made here rather than the CMakeLists.txt that