File tree 2 files changed +20
-3
lines changed
2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -105,15 +105,26 @@ if(NOT SIMDJSON_EXCEPTIONS)
105
105
target_compile_definitions (simdjson-internal -flags INTERFACE SIMDJSON_EXCEPTIONS=0)
106
106
endif ()
107
107
108
- option (SIMDJSON_ENABLE_THREADS "Enable threaded operation " ON )
108
+ option (SIMDJSON_ENABLE_THREADS "Link with thread support " ON )
109
109
if (SIMDJSON_ENABLE_THREADS)
110
110
set (CMAKE_THREAD_PREFER_PTHREAD TRUE )
111
111
set (THREADS_PREFER_PTHREAD_FLAG TRUE )
112
112
find_package (Threads REQUIRED)
113
113
target_link_libraries (simdjson-flags INTERFACE Threads::Threads)
114
114
target_link_libraries (simdjson-flags INTERFACE ${CMAKE_THREAD_LIBS_INIT} )
115
115
target_compile_options (simdjson-flags INTERFACE ${CMAKE_THREAD_LIBS_INIT} )
116
- target_compile_definitions (simdjson-flags INTERFACE SIMDJSON_THREADS_ENABLED=1)
116
+ target_compile_definitions (simdjson-flags INTERFACE SIMDJSON_THREADS_ENABLED=1) # This will be set in the code automatically.
117
+ endif ()
118
+
119
+ # Some users compile simdjson with thread support but still do not want simdjson to use threads.
120
+ #
121
+ # Important : Expect this option to disappear in the future.
122
+ #
123
+ option (SIMDJSON_DO_NOT_USE_THREADS_NO_MATTER_WHAT "Whether we enabled thread support or not (SIMDJSON_ENABLE_THREADS), do not use threads.\
124
+ This option does nothing when thread support is not enabled. We reserve the right to remove this option in a future release in\
125
+ favor of a runtime approach." OFF )
126
+ if (SIMDJSON_DO_NOT_USE_THREADS_NO_MATTER_WHAT)
127
+ target_compile_definitions (simdjson-flags INTERFACE SIMDJSON_DO_NOT_USE_THREADS_NO_MATTER_WHAT=1)
117
128
endif ()
118
129
119
130
if (SIMDJSON_USE_LIBCPP)
Original file line number Diff line number Diff line change @@ -122,7 +122,6 @@ compiling for a known 64-bit platform."
122
122
#endif
123
123
#endif
124
124
125
-
126
125
// workaround for large stack sizes under -O0.
127
126
// https://github.com/simdjson/simdjson/issues/691
128
127
#ifdef __APPLE__
@@ -136,6 +135,13 @@ compiling for a known 64-bit platform."
136
135
#endif
137
136
#endif
138
137
138
+
139
+ #if SIMDJSON_DO_NOT_USE_THREADS_NO_MATTER_WHAT
140
+ // No matter what happened, we undefine SIMDJSON_THREADS_ENABLED and so disable threads.
141
+ #undef SIMDJSON_THREADS_ENABLED
142
+ #endif
143
+
144
+
139
145
#if defined(__clang__)
140
146
#define NO_SANITIZE_UNDEFINED __attribute__((no_sanitize(" undefined" )))
141
147
#elif defined(__GNUC__)
You can’t perform that action at this time.
0 commit comments