]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Make sure the compiler actually warns.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 28 Sep 2012 01:00:51 +0000 (01:00 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 28 Sep 2012 01:00:51 +0000 (01:00 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_cmake@26815 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/cmake/checks/check_for_compiler_features.cmake

index 7363c1481314dbbb41bc2d554061c3330b4b0c6f..f112d030fd8a3960fbe46b5a1cced3108243a037 100644 (file)
@@ -413,6 +413,8 @@ ENDIF()
 # variable in config.h), i.e., to something the compiler will
 # ignore
 #
+
+# first see if the compiler accepts the attribute
 CHECK_CXX_SOURCE_COMPILES(
   "
           int old_fn () __attribute__((deprecated));
@@ -423,8 +425,26 @@ CHECK_CXX_SOURCE_COMPILES(
   "
   DEAL_II_COMPILER_HAS_ATTRIBUTE_DEPRECATED)
 
-IF(DEAL_II_COMPILER_HAS_ATTRIBUTE_DEPRECATED)
+# ...and then verify whether it actually errors out if
+# -Werror is given
+ADD_FLAGS(CMAKE_REQUIRED_FLAGS "-Werror")
+CHECK_CXX_SOURCE_COMPILES(
+  "
+          int old_fn () __attribute__((deprecated));
+          int old_fn () { return 0; }
+          int (*fn_ptr)() = old_fn;
+
+         int main () {}
+  "
+  DEAL_II_COMPILER_HAS_ATTRIBUTE_DEPRECATED_WARNING)
+STRIP_FLAG(CMAKE_REQUIRED_FLAGS "-Werror")
+
+IF(DEAL_II_COMPILER_HAS_ATTRIBUTE_DEPRECATED
+   AND
+   (NOT DEAL_II_COMPILER_HAS_ATTRIBUTE_DEPRECATED_WARNING))
+  MESSAGE(STATUS "Compiler supports the deprecated attribute")
   SET(DEAL_II_DEPRECATED "__attribute__((deprecated))")
 ELSE()
+  MESSAGE(STATUS "Compiler does not support the deprecated attribute")
   SET(DEAL_II_DEPRECATED " ")
 ENDIF()

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.