@@ -61,6 +61,13 @@ if(ENABLE_SWIFT)
6161 ${SWIFT_RUNTIME_LIBDIR} /${CMAKE_SHARED_LIBRARY_PREFIX} swiftSwiftOnoneSupport${CMAKE_SHARED_LIBRARY_SUFFIX} )
6262endif ()
6363
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+
6471option (BUILD_SHARED_LIBS "build shared libraries" ON )
6572
6673option (ENABLE_TESTING "build libdispatch tests" ON )
@@ -166,10 +173,8 @@ check_include_files("libproc_internal.h" HAVE_LIBPROC_INTERNAL_H)
166173check_include_files("mach/mach.h" HAVE_MACH)
167174if (HAVE_MACH)
168175 set (__DARWIN_NON_CANCELABLE 1)
169- set (USE_MACH_SEM 1)
170176else ()
171177 set (__DARWIN_NON_CANCELABLE 0)
172- set (USE_MACH_SEM 0)
173178endif ()
174179check_include_files("malloc/malloc.h" HAVE_MALLOC_MALLOC_H)
175180check_include_files("memory.h" HAVE_MEMORY_H)
@@ -188,11 +193,19 @@ check_include_files("sys/types.h" HAVE_SYS_TYPES_H)
188193check_include_files("unistd.h" HAVE_UNISTD_H)
189194check_include_files("objc/objc-internal.h" HAVE_OBJC)
190195
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 ()
192201if (CMAKE_SYSTEM_NAME STREQUAL Windows)
193- add_definitions (-DTARGET_OS_WIN32)
194202 add_definitions (-DUSE_WIN32_SEM)
195203endif ()
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 ()
196209
197210check_symbol_exists(CLOCK_UPTIME "time.h" HAVE_DECL_CLOCK_UPTIME)
198211check_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)
214227
215228check_symbol_exists(program_invocation_name "errno.h" HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME)
216229
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 ()
219239 add_definitions (-DDISPATCH_USE_DTRACE=1)
220240else ()
221241 add_definitions (-DDISPATCH_USE_DTRACE=0)
0 commit comments