1#
2# Copyright 2018, Data61
3# Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4# ABN 41 687 119 230.
5#
6# This software may be distributed and modified according to the terms of
7# the BSD 2-Clause license. Note that NO WARRANTY is provided.
8# See "LICENSE_BSD2.txt" for details.
9#
10# @TAG(DATA61_BSD)
11#
12
13config_option(LibNfs LIB_NFS "Build libnfs" DEFAULT OFF)
14
15if(LibNfs)
16    set(HAVE_ARPA_INET_H 1)
17    set(HAVE_CLOCK_GETTIME 1)
18    set(HAVE_DLFCN_H 1)
19    set(HAVE_FUSE_H 1)
20    set(HAVE_INTTYPES_H 1)
21    set(HAVE_MEMORY_H 1)
22    set(HAVE_NETDB_H 1)
23    set(HAVE_NETINET_IN_H 1)
24    set(HAVE_NETINET_TCP_H 1)
25    set(HAVE_NET_IF_H 1)
26    set(HAVE_POLL_H 1)
27    set(HAVE_SOCKADDR_STORAGE 1)
28    set(HAVE_STDINT_H 1)
29    set(HAVE_STDLIB_H 1)
30    set(HAVE_STRINGS_H 1)
31    set(HAVE_STRINGS_H 1)
32    set(HAVE_STRING_H 1)
33    set(HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC 1)
34    set(HAVE_SYS_IOCTL_H 1)
35    set(HAVE_SYS_SOCKET_H 1)
36    set(HAVE_SYS_STATVFS_H 1)
37    set(HAVE_SYS_STAT_H 1)
38    set(HAVE_SYS_SYSMACROS_H 1)
39    set(HAVE_SYS_TIME_H 1)
40    set(HAVE_TIME_H 1)
41    set(HAVE_SYS_TYPES_H 1)
42    set(HAVE_SYS_VFS_H 1)
43    set(HAVE_TALLOC_TEVENT 1)
44    set(HAVE_UNISTD_H 1)
45    set(HAVE_UTIME_H 1)
46
47    link_libraries(muslc)
48    # definitions to make the library compile with muslc
49    add_definitions(-D__ANDROID__)
50    add_definitions(-U__linux__)
51
52    # find libnfs
53    find_file(LIBNFS_PATH libnfs PATHS ${CMAKE_SOURCE_DIR} CMAKE_FIND_ROOT_PATH_BOTH)
54    mark_as_advanced(FORCE LIBNFS_PATH)
55    if("${LIBNFS_PATH}" STREQUAL "LIBNFS_PATH-NOTFOUND")
56        message(FATAL_ERROR "Failed to find libnfs. Consider cmake -DLIBNFS_PATH=/path/to/libnfs")
57    endif()
58
59    add_subdirectory(${LIBNFS_PATH} ${CMAKE_BINARY_DIR}/libnfs)
60endif()
61