]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Correctly detect -Wno-... support for gcc 297/head
authorMatthias Maier <tamiko@kyomu.43-1.org>
Thu, 11 Dec 2014 19:49:34 +0000 (20:49 +0100)
committerMatthias Maier <tamiko@kyomu.43-1.org>
Thu, 11 Dec 2014 19:53:28 +0000 (20:53 +0100)
gcc does not emit a warning if an unknown -Wno-... flag is specified on the
command line, thus the ENABLE_IF_SUPPORTED macro unconditionally enabled
-Wno-... flags for gcc. Unfortunately, gcc _does_ emit a warning for the
unrecognized compiler option if another warning is emitted in the same
compilation unit. This is now fixed by always querying for the non-negated
version, i.e. -Wfoo instead of -Wno-foo.

cmake/macros/macro_enable_if_supported.cmake
doc/news/changes.h

index 1485fb57df58a0958cb09ffc6dc6abcb41953d07..d84b2d98bbf812f0f4e06ea3a8792b2b55485dd1 100644 (file)
@@ -34,6 +34,19 @@ MACRO(ENABLE_IF_SUPPORTED _variable _flag)
   ENDIF()
 
   STRING(STRIP "${_flag}" _flag_stripped)
+  SET(_flag_stripped_orig "${_flag_stripped}")
+
+  #
+  # Gcc does not emit a warning if testing -Wno-... flags which leads to
+  # false positive detection. Unfortunately it later warns that an unknown
+  # warning option is used if another warning is emited in the same
+  # compilation unit.
+  # Therefore we invert the test for -Wno-... flags:
+  #
+  IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
+    STRING(REPLACE "-Wno-" "-W" _flag_stripped "${_flag_stripped}")
+  ENDIF()
+
   IF(NOT "${_flag_stripped}" STREQUAL "")
     STRING(REGEX REPLACE "^-" "" _flag_name "${_flag_stripped}")
     STRING(REPLACE "," "" _flag_name "${_flag_name}")
@@ -44,7 +57,7 @@ MACRO(ENABLE_IF_SUPPORTED _variable _flag)
       DEAL_II_HAVE_FLAG_${_flag_name}
       )
     IF(DEAL_II_HAVE_FLAG_${_flag_name})
-      SET(${_variable} "${${_variable}} ${_flag_stripped}")
+      SET(${_variable} "${${_variable}} ${_flag_stripped_orig}")
       STRING(STRIP "${${_variable}}" ${_variable})
     ENDIF()
   ENDIF()
index abe13a6a80d0f6014a442ff30b5835b11f3ec334..1ad9462892eabbc21037a0bff7e0b8ff02bc46cb 100644 (file)
@@ -340,6 +340,11 @@ inconvenience this causes.
 <h3>Specific improvements</h3>
 
 <ol>
+  <li>Fixed: CMake now correctly detects -Wno-... support for gcc.
+  <br>
+  (Matthias Maier, 2014/12/11)
+  </li>
+
   <li> New: The FE_Q and FE_Q_Hierarchical classes now include pictures
   of their 2d shape functions in the class documentation.
   <br>

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.