aboutsummaryrefslogtreecommitdiff
path: root/dep/efsw/CMakeLists.txt
blob: 9817525931cf8f3bfc45c13ffee265f85323800a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
if (BUILD_SHARED_LIBS)
  set(EFSW_CPP_SOURCE
    src/efsw/Atomic.hpp
    src/efsw/base.hpp
    src/efsw/Debug.cpp
    src/efsw/Debug.hpp
    src/efsw/DirectorySnapshot.cpp
    src/efsw/DirectorySnapshot.hpp
    src/efsw/DirectorySnapshotDiff.cpp
    src/efsw/DirectorySnapshotDiff.hpp
    src/efsw/DirWatcherGeneric.cpp
    src/efsw/DirWatcherGeneric.hpp
    src/efsw/FileInfo.cpp
    src/efsw/FileInfo.hpp
    src/efsw/FileSystem.cpp
    src/efsw/FileSystem.hpp
    src/efsw/FileWatcher.cpp
    src/efsw/FileWatcherCWrapper.cpp
    src/efsw/FileWatcherGeneric.cpp
    src/efsw/FileWatcherGeneric.hpp
    src/efsw/FileWatcherImpl.cpp
    src/efsw/FileWatcherImpl.hpp
    src/efsw/Lock.hpp
    src/efsw/Log.cpp
    src/efsw/Mutex.cpp
    src/efsw/Mutex.hpp
    src/efsw/sophist.h
    src/efsw/String.cpp
    src/efsw/String.hpp
    src/efsw/System.cpp
    src/efsw/System.hpp
    src/efsw/Thread.cpp
    src/efsw/Thread.hpp
    src/efsw/Utf.hpp
    src/efsw/Watcher.cpp
    src/efsw/Watcher.hpp
    src/efsw/WatcherGeneric.cpp
    src/efsw/WatcherGeneric.hpp
    src/efsw/platform/platformimpl.hpp
  )

  if (WIN32)
    list (APPEND EFSW_CPP_SOURCE
      src/efsw/platform/win/FileSystemImpl.cpp
      src/efsw/platform/win/FileSystemImpl.hpp
      src/efsw/platform/win/MutexImpl.cpp
      src/efsw/platform/win/MutexImpl.hpp
      src/efsw/platform/win/SystemImpl.cpp
      src/efsw/platform/win/SystemImpl.hpp
      src/efsw/platform/win/ThreadImpl.cpp
      src/efsw/platform/win/ThreadImpl.hpp)
  else ()
    list (APPEND EFSW_CPP_SOURCE
      src/efsw/platform/posix/FileSystemImpl.cpp
      src/efsw/platform/posix/FileSystemImpl.hpp
      src/efsw/platform/posix/MutexImpl.cpp
      src/efsw/platform/posix/MutexImpl.hpp
      src/efsw/platform/posix/SystemImpl.cpp
      src/efsw/platform/posix/SystemImpl.hpp
      src/efsw/platform/posix/ThreadImpl.cpp
      src/efsw/platform/posix/ThreadImpl.hpp)
  endif()

  if (APPLE)
    list (APPEND EFSW_CPP_SOURCE
      src/efsw/FileWatcherFSEvents.cpp
      src/efsw/FileWatcherFSEvents.hpp
      src/efsw/FileWatcherKqueue.cpp
      src/efsw/FileWatcherKqueue.hpp
      src/efsw/WatcherFSEvents.cpp
      src/efsw/WatcherFSEvents.hpp
      src/efsw/WatcherKqueue.cpp
      src/efsw/WatcherKqueue.hpp)
    set(OPTIONAL_LINK_LIBRARIES "-framework CoreFoundation" "-framework CoreServices")
  elseif (WIN32)
    list (APPEND EFSW_CPP_SOURCE
      src/efsw/FileWatcherWin32.cpp
      src/efsw/FileWatcherWin32.hpp
      src/efsw/WatcherWin32.cpp
      src/efsw/WatcherWin32.hpp)
  elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
    list (APPEND EFSW_CPP_SOURCE
      src/efsw/FileWatcherInotify.cpp
      src/efsw/FileWatcherInotify.hpp
      src/efsw/WatcherInotify.cpp
      src/efsw/WatcherInotify.hpp)
    find_path(EFSW_INOTIFY_H
      NAMES
        sys/inotify.h
      NO_CACHE
    )
    if (EFSW_INOTIFY_H STREQUAL "EFSW_INOTIFY_H-NOTFOUND")
      list (APPEND EFSW_CPP_SOURCE
        src/efsw/inotify-nosys.h
      )
      set(OPTIONAL_COMPILE_DEFINITIONS "-DEFSW_INOTIFY_NOSYS")
    endif()
  elseif (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
    list (APPEND EFSW_CPP_SOURCE
      src/efsw/FileWatcherKqueue.cpp
      src/efsw/FileWatcherKqueue.hpp
      src/efsw/WatcherKqueue.cpp
      src/efsw/WatcherKqueue.hpp)
  endif()

  add_library(efsw STATIC ${EFSW_CPP_SOURCE})

  target_include_directories(efsw
    PUBLIC
      ${CMAKE_CURRENT_SOURCE_DIR}/include
    PRIVATE
      ${CMAKE_CURRENT_SOURCE_DIR}/src)

  target_compile_definitions(efsw
    PRIVATE
      ${OPTIONAL_COMPILE_DEFINITIONS})

  target_link_libraries(efsw
    PRIVATE
      trinity-dependency-interface
    PUBLIC
      threads
      ${OPTIONAL_LINK_LIBRARIES})

  set_target_properties(efsw
    PROPERTIES
      FOLDER
        "dep")
else ()
  add_library(efsw INTERFACE IMPORTED GLOBAL)
endif ()