@@ -61,6 +61,13 @@ if(ENABLE_SWIFT)
61
61
${SWIFT_RUNTIME_LIBDIR} /${CMAKE_SHARED_LIBRARY_PREFIX} swiftSwiftOnoneSupport${CMAKE_SHARED_LIBRARY_SUFFIX} )
62
62
endif ()
63
63
64
+ if (CMAKE_SYSTEM_NAME STREQUAL Android)
65
+ set (ENABLE_DTRACE_DEFAULT OFF )
66
+ else ()
67
+ set (ENABLE_DTRACE_DEFAULT ON )
68
+ endif ()
69
+ option (ENABLE_DTRACE "enable dtrace support" ${ENABLE_DTRACE_DEFAULT} )
70
+
64
71
option (BUILD_SHARED_LIBS "build shared libraries" ON )
65
72
66
73
option (ENABLE_TESTING "build libdispatch tests" ON )
@@ -166,10 +173,8 @@ check_include_files("libproc_internal.h" HAVE_LIBPROC_INTERNAL_H)
166
173
check_include_files("mach/mach.h" HAVE_MACH)
167
174
if (HAVE_MACH)
168
175
set (__DARWIN_NON_CANCELABLE 1)
169
- set (USE_MACH_SEM 1)
170
176
else ()
171
177
set (__DARWIN_NON_CANCELABLE 0)
172
- set (USE_MACH_SEM 0)
173
178
endif ()
174
179
check_include_files("malloc/malloc.h" HAVE_MALLOC_MALLOC_H)
175
180
check_include_files("memory.h" HAVE_MEMORY_H)
@@ -188,11 +193,19 @@ check_include_files("sys/types.h" HAVE_SYS_TYPES_H)
188
193
check_include_files("unistd.h" HAVE_UNISTD_H)
189
194
check_include_files("objc/objc-internal.h" HAVE_OBJC)
190
195
191
- check_library_exists(pthread sem_init "" USE_POSIX_SEM)
196
+ if (HAVE_MACH)
197
+ set (USE_MACH_SEM 1)
198
+ else ()
199
+ set (USE_MACH_SEM 0)
200
+ endif ()
192
201
if (CMAKE_SYSTEM_NAME STREQUAL Windows)
193
- add_definitions (-DTARGET_OS_WIN32)
194
202
add_definitions (-DUSE_WIN32_SEM)
195
203
endif ()
204
+ check_library_exists(pthread sem_init "" USE_POSIX_SEM)
205
+ # NOTE: android has not always provided a libpthread, but uses the pthreads API
206
+ if (CMAKE_SYSTEM_NAME STREQUAL Android)
207
+ set (USE_POSIX_SEM 1)
208
+ endif ()
196
209
197
210
check_symbol_exists(CLOCK_UPTIME "time.h" HAVE_DECL_CLOCK_UPTIME)
198
211
check_symbol_exists(CLOCK_UPTIME_FAST "time.h" HAVE_DECL_CLOCK_UPTIME_FAST)
@@ -214,8 +227,15 @@ check_symbol_exists(VQ_VERYLOWDISK "sys/mount.h" HAVE_DECL_VQ_VERYLOWDISK)
214
227
215
228
check_symbol_exists(program_invocation_name "errno.h" HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME)
216
229
217
- find_program (dtrace_EXECUTABLE dtrace)
218
- if (dtrace_EXECUTABLE)
230
+ if (CMAKE_SYSTEM_NAME STREQUAL Windows)
231
+ add_definitions (-DTARGET_OS_WIN32)
232
+ endif ()
233
+
234
+ if (ENABLE_DTRACE)
235
+ find_program (dtrace_EXECUTABLE dtrace)
236
+ if (NOT dtrace_EXECUTABLE)
237
+ message (FATAL_ERROR "dtrace not found but explicitly requested" )
238
+ endif ()
219
239
add_definitions (-DDISPATCH_USE_DTRACE=1)
220
240
else ()
221
241
add_definitions (-DDISPATCH_USE_DTRACE=0)
0 commit comments