summaryrefslogtreecommitdiff
path: root/Modules/WriteCompilerDetectionHeader.cmake
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-05-14 22:10:10 +0200
committerBrad King <brad.king@kitware.com>2014-06-09 10:28:24 -0400
commit62863106f0e03a98d6de2fb8580162dce8702c1a (patch)
tree659286c4020f355afe5a38d01fb227b606ab320d /Modules/WriteCompilerDetectionHeader.cmake
parent8ab2d7d462a0f812b4ce1c555c6a7cbcea7abfef (diff)
downloadcmake-62863106f0e03a98d6de2fb8580162dce8702c1a.tar.gz
WCDH: Add compatibility defines for deprecation.
Diffstat (limited to 'Modules/WriteCompilerDetectionHeader.cmake')
-rw-r--r--Modules/WriteCompilerDetectionHeader.cmake62
1 files changed, 52 insertions, 10 deletions
diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake
index f80943dbdc..6e64cd2096 100644
--- a/Modules/WriteCompilerDetectionHeader.cmake
+++ b/Modules/WriteCompilerDetectionHeader.cmake
@@ -133,16 +133,37 @@
# ``static_assert``, or ignored if using the backward compatibility
# implementation.
#
-# ====================== ================================ ===================
-# Feature Define Symbol
-# ====================== ================================ ===================
-# ``cxx_alignas`` ``<PREFIX>_ALIGNAS`` ``alignas``
-# ``cxx_alignof`` ``<PREFIX>_ALIGNOF`` ``alignof``
-# ``cxx_nullptr`` ``<PREFIX>_NULLPTR`` ``nullptr``
-# ``cxx_static_assert`` ``<PREFIX>_STATIC_ASSERT`` ``static_assert``
-# ``cxx_static_assert`` ``<PREFIX>_STATIC_ASSERT_MSG`` ``static_assert``
-# ====================== ================================ ===================
-
+# The ``cxx_attribute_deprecated`` feature provides a macro definition
+# ``<PREFIX>_DEPRECATED``, which expands to either the standard
+# ``[[deprecated]]`` attribute or a compiler-specific decorator such
+# as ``__attribute__((__deprecated__))`` used by GNU compilers.
+#
+# ============================= ================================ =====================
+# Feature Define Symbol
+# ============================= ================================ =====================
+# ``cxx_alignas`` ``<PREFIX>_ALIGNAS`` ``alignas``
+# ``cxx_alignof`` ``<PREFIX>_ALIGNOF`` ``alignof``
+# ``cxx_nullptr`` ``<PREFIX>_NULLPTR`` ``nullptr``
+# ``cxx_static_assert`` ``<PREFIX>_STATIC_ASSERT`` ``static_assert``
+# ``cxx_static_assert`` ``<PREFIX>_STATIC_ASSERT_MSG`` ``static_assert``
+# ``cxx_attribute_deprecated`` ``<PREFIX>_DEPRECATED`` ``[[deprecated]]``
+# ``cxx_attribute_deprecated`` ``<PREFIX>_DEPRECATED_MSG`` ``[[deprecated]]``
+# ============================= ================================ =====================
+#
+# A use-case which arises with such deprecation macros is the deprecation
+# of an entire library. In that case, all public API in the library may
+# be decorated with the ``<PREFIX>_DEPRECATED`` macro. This results in
+# very noisy build output when building the library itself, so the macro
+# may be may be defined to empty in that case when building the deprecated
+# library:
+#
+# .. code-block:: cmake
+#
+# add_library(compat_support ${srcs})
+# target_compile_definitions(compat_support
+# PRIVATE
+# CompatSupport_DEPRECATED=
+# )
#=============================================================================
# Copyright 2014 Stephen Kelly <steveire@gmail.com>
@@ -402,6 +423,27 @@ function(write_compiler_detection_header
# endif
\n")
endif()
+ if (feature STREQUAL cxx_attribute_deprecated)
+ set(def_name ${prefix_arg}_${feature_PP})
+ set(def_value "${prefix_arg}_DEPRECATED")
+ set(file_content "${file_content}
+# ifndef ${def_value}
+# if ${def_name}
+# define ${def_value} [[deprecated]]
+# define ${def_value}_MSG(MSG) [[deprecated(MSG)]]
+# elif defined(__GNUC__) || defined(__clang__)
+# define ${def_value} __attribute__((__deprecated__))
+# define ${def_value}_MSG(MSG) __attribute__((__deprecated__(MSG)))
+# elif defined(_MSC_VER)
+# define ${def_value} __declspec(deprecated)
+# define ${def_value}_MSG(MSG) __declspec(deprecated(MSG))
+# else
+# define ${def_value}
+# define ${def_value}_MSG(MSG)
+# endif
+# endif
+\n")
+ endif()
endforeach()
set(file_content "${file_content}#endif\n")