]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
My first cmake patch: Determine whether the compiler understands the __attribute__...
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 27 Sep 2012 21:42:36 +0000 (21:42 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 27 Sep 2012 21:42:36 +0000 (21:42 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_cmake@26806 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/cmake/checks/check_for_compiler_features.cmake
deal.II/include/deal.II/base/config.h.in

index c2ea8eaad205f28037f4fc462bc48cc163039ea1..7363c1481314dbbb41bc2d554061c3330b4b0c6f 100644 (file)
@@ -399,3 +399,32 @@ IF(NOT CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
   ENABLE_IF_SUPPORTED(DEAL_II_C_FLAGS_DEBUG "-Wa,--compress-debug-sections")
 ENDIF()
 
+
+
+#
+# Gcc and some other compilers have an attribute of the form
+# __attribute__((deprecated)) that can be used to make the
+# compiler warn whenever a deprecated function is used. See
+# if this attribute is available.
+#
+# If it is, set the variable DEAL_II_DEPRECATED to its value. If
+# it isn't, set it to an empty string (actually, to a single
+# space, since the empty string causes CMAKE to #undef the
+# variable in config.h), i.e., to something the compiler will
+# ignore
+#
+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)
+
+IF(DEAL_II_COMPILER_HAS_ATTRIBUTE_DEPRECATED)
+  SET(DEAL_II_DEPRECATED "__attribute__((deprecated))")
+ELSE()
+  SET(DEAL_II_DEPRECATED " ")
+ENDIF()
index 41b9e6440ff6019c0a598416a4ab90380ec36e06..61ba163bc7f87cb9fba1d73535d6f6e0e9bc47fe 100644 (file)
 /* If the compiler supports it, then this variable is defined to a string
    that when written after a function name makes the compiler emit a warning
    whenever this function is used somewhere that its use is deprecated. */
-#define DEAL_II_DEPRECATED
+#cmakedefine DEAL_II_DEPRECATED @DEAL_II_DEPRECATED@
 
 
 

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.