summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Help/release/dev/WCDH-thread_local.rst7
-rw-r--r--Modules/WriteCompilerDetectionHeader.cmake15
2 files changed, 22 insertions, 0 deletions
diff --git a/Help/release/dev/WCDH-thread_local.rst b/Help/release/dev/WCDH-thread_local.rst
new file mode 100644
index 0000000000..44516a78e0
--- /dev/null
+++ b/Help/release/dev/WCDH-thread_local.rst
@@ -0,0 +1,7 @@
+WriteCompilerDetectionHeader thread_local portability
+-----------------------------------------------------
+
+* The :module:`WriteCompilerDetectionHeader` module learned to
+ create a define for portability of the cxx_thread_local feature. The define
+ expands to either the C++11 ``thread_local`` keyword, or a
+ pre-standardization compiler-specific equivalent, as appropriate.
diff --git a/Modules/WriteCompilerDetectionHeader.cmake b/Modules/WriteCompilerDetectionHeader.cmake
index 36b9706e01..d61358fa2e 100644
--- a/Modules/WriteCompilerDetectionHeader.cmake
+++ b/Modules/WriteCompilerDetectionHeader.cmake
@@ -194,6 +194,7 @@
# ``cxx_static_assert`` ``<PREFIX>_STATIC_ASSERT_MSG`` ``static_assert``
# ``cxx_attribute_deprecated`` ``<PREFIX>_DEPRECATED`` ``[[deprecated]]``
# ``cxx_attribute_deprecated`` ``<PREFIX>_DEPRECATED_MSG`` ``[[deprecated]]``
+# ``cxx_thread_local`` ``<PREFIX>_THREAD_LOCAL`` ``thread_local``
# ============================= ================================ =====================
#
# A use-case which arises with such deprecation macros is the deprecation
@@ -573,6 +574,20 @@ function(write_compiler_detection_header
# endif
\n")
endif()
+ if (feature STREQUAL cxx_thread_local)
+ set(def_value "${prefix_arg}_THREAD_LOCAL")
+ set(file_content "${file_content}
+# if ${def_name}
+# define ${def_value} thread_local
+# elif ${prefix_arg}_COMPILER_IS_GNU || ${prefix_arg}_COMPILER_IS_Clang || ${prefix_arg}_COMPILER_IS_AppleClang
+# define ${def_value} __thread
+# elif ${prefix_arg}_COMPILER_IS_MSVC
+# define ${def_value} __declspec(thread)
+# else
+// ${def_value} not defined for this configuration.
+# endif
+\n")
+ endif()
if (feature STREQUAL cxx_attribute_deprecated)
set(def_name ${prefix_arg}_${feature_PP})
set(def_value "${prefix_arg}_DEPRECATED")