diff options
| author | Björn Esser <besser82@fedoraproject.org> | 2020-05-18 11:38:58 +0200 |
|---|---|---|
| committer | Björn Esser <besser82@fedoraproject.org> | 2020-05-18 12:27:19 +0200 |
| commit | 78642dcb9b9b58bd0111ffba5e46b9346b8d486b (patch) | |
| tree | 747245514835a8b448fbb88532d036441390a31b | |
| parent | dd040ba44605da3d186e76add85926423b588a75 (diff) | |
| download | json-c-78642dcb9b9b58bd0111ffba5e46b9346b8d486b.tar.gz | |
CMake: Add an option to disable the use of thread-local storage.
Using thread-local storage may not be desired in all environments
and/or use-cases, thus there should be an option to disable its use
on purpose.
Fixes #451.
| -rw-r--r-- | CMakeLists.txt | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 254d324..180d6e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,6 +87,7 @@ option(ENABLE_RDRAND "Enable RDRAND Hardware RNG Hash Seed" option(ENABLE_THREADING "Enable partial threading support." OFF) option(DISABLE_WERROR "Avoid treating compiler warnings as fatal errors" OFF) option(DISABLE_BSYMBOLIC "Avoid linking with -Bsymbolic-function" OFF) +option(DISABLE_THREAD_LOCAL_STORAGE "Disable Thread-Local Storage (HAVE___THREAD)" OFF) if (UNIX OR MINGW OR CYGWIN) list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE) @@ -217,14 +218,16 @@ check_c_source_compiles( "int main() { int i, x = 0; i = __sync_add_and_fetch(&x,1); return x; }" HAVE_ATOMIC_BUILTINS) -check_c_source_compiles( - "__thread int x = 0; int main() { return 0; }" - HAVE___THREAD) +if (NOT DISABLE_THREAD_LOCAL_STORAGE) + check_c_source_compiles( + "__thread int x = 0; int main() { return 0; }" + HAVE___THREAD) -if (HAVE___THREAD) - set(SPEC___THREAD __thread) -elseif (MSVC) - set(SPEC___THREAD __declspec(thread)) + if (HAVE___THREAD) + set(SPEC___THREAD __thread) + elseif (MSVC) + set(SPEC___THREAD __declspec(thread)) + endif() endif() # Hardware random number is not available on Windows? Says, config.h.win32. Best to preserve compatibility. |
