diff --git a/CMakeLists.txt b/CMakeLists.txt index da1c9a6510d..95b5ef2b639 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -722,8 +722,14 @@ if (HDF5_ENABLE_HDFS) if (HDFS_FOUND) set (H5_HAVE_LIBHDFS 1) set (H5_HAVE_HDFS_H 1) - if (NOT MSVC) - list (APPEND LINK_LIBS -pthread) + if (NOT MSVC AND NOT ANDROID) + list (APPEND LINK_LIBS -pthread) + elseif(ANDROID) + message(STATUS "Enabled HDFS adding cancelthread support library for Android") + find_library(cancelthread_LIBRARY NAMES cancelthread libcancelthread) + find_path(cancelthread_INCLUDE_DIR NAMES "bthread.h") + set (HDF5_SRC_INCLUDE_DIRS ${HDF5_SRC_INCLUDE_DIRS} ${cancelthread_INCLUDE_DIR}) + link_libraries(${cancelthread_LIBRARY}) endif () else () set (HDF5_ENABLE_HDFS OFF CACHE BOOL "Enable HDFS" FORCE) @@ -849,6 +855,14 @@ if (HDF5_ENABLE_SUBFILING_VFD) message (FATAL_ERROR "Subfiling requires thread operations support") endif () + if(ANDROID) + message(STATUS "Enabled Parallel HDF5 Subfiling VFD adding cancelthread support library for Android") + find_library(cancelthread_LIBRARY NAMES cancelthread libcancelthread) + find_path(cancelthread_INCLUDE_DIR NAMES "bthread.h") + set (HDF5_SRC_INCLUDE_DIRS ${HDF5_SRC_INCLUDE_DIRS} ${cancelthread_INCLUDE_DIR}) + link_libraries(${cancelthread_LIBRARY}) + endif() + set (H5_HAVE_SUBFILING_VFD 1) # IOC VFD is currently only built when subfiling is enabled set (H5_HAVE_IOC_VFD 1) @@ -982,6 +996,14 @@ if (HDF5_ENABLE_THREADSAFE) message (FATAL_ERROR " **** thread-safety option requires a threading package and none was found **** ") endif () + if(ANDROID) + message(STATUS "Enabled thread-safety adding cancelthread support library for Android") + find_library(cancelthread_LIBRARY NAMES cancelthread libcancelthread) + find_path(cancelthread_INCLUDE_DIR NAMES "bthread.h") + set (HDF5_SRC_INCLUDE_DIRS ${HDF5_SRC_INCLUDE_DIRS} ${cancelthread_INCLUDE_DIR}) + link_libraries(${cancelthread_LIBRARY}) + endif() + set (H5_HAVE_THREADSAFE 1) endif () diff --git a/src/H5private.h b/src/H5private.h index cff6b37390c..c6e4cdf2d80 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -67,6 +67,11 @@ /* Pthreads */ #if defined(H5_HAVE_PTHREAD_H) #include + +#if defined(__ANDROID__) +#include +#endif + #endif #endif