summaryrefslogtreecommitdiffstats
path: root/src/common/CMakeLists.txt
blob: e1f1dca4778e2cbd39bd5b871f86b8ecd8e3e88e (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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
add_library(common_buffer_obj OBJECT
  buffer.cc)

add_library(common_texttable_obj OBJECT
  TextTable.cc)

add_library(common_prioritycache_obj OBJECT
  PriorityCache.cc)

if(WIN32)
  add_library(dlfcn_win32 STATIC win32/dlfcn.cc win32/errno.cc)
endif()

set(common_srcs
  AsyncOpTracker.cc
  BackTrace.cc
  ConfUtils.cc
  Cycles.cc
  CDC.cc
  DecayCounter.cc
  FastCDC.cc
  Finisher.cc
  FixedCDC.cc
  Formatter.cc
  Graylog.cc
  HTMLFormatter.cc
  HeartbeatMap.cc
  LogClient.cc
  LogEntry.cc
  ostream_temp.cc
  OutputDataSocket.cc
  PluginRegistry.cc
  Readahead.cc
  RefCountedObj.cc
  SloppyCRCMap.cc
  Thread.cc
  Throttle.cc
  Timer.cc
  TracepointProvider.cc
  TrackedOp.cc
  WorkQueue.cc
  admin_socket.cc
  admin_socket_client.cc
  assert.cc
  bit_str.cc
  bloom_filter.cc
  ceph_argparse.cc
  ceph_context.cc
  ceph_crypto.cc
  ceph_frag.cc
  ceph_fs.cc
  ceph_hash.cc
  ceph_json.cc
  ceph_strings.cc
  ceph_releases.cc
  ceph_time.cc
  cmdparse.cc
  code_environment.cc
  common_init.cc
  compat.cc
  condition_variable_debug.cc
  config.cc
  config_values.cc
  dout.cc
  entity_name.cc
  environment.cc
  errno.cc
  escape.cc
  fd.cc
  fs_types.cc
  hex.cc
  histogram.cc
  hobject.cc
  hostname.cc
  ipaddr.cc
  iso_8601.cc
  lockdep.cc
  mempool.cc
  mime.c
  mutex_debug.cc
  numa.cc
  openssl_opts_handler.cc
  options.cc
  page.cc
  perf_counters.cc
  perf_counters_collection.cc
  perf_histogram.cc
  pick_address.cc
  random_string.cc
  reverse.c
  run_cmd.cc
  scrub_types.cc
  shared_mutex_debug.cc
  signal.cc
  snap_types.cc
  str_list.cc
  str_map.cc
  strtol.cc
  types.cc
  url_escape.cc
  pretty_binary.cc
  utf8.c
  util.cc
  version.cc)

if(WIN32)
  if(MINGW)
    set(CMAKE_MC_COMPILER x86_64-w64-mingw32-windmc)
    set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
  endif()

  add_custom_command(
    OUTPUT ${CMAKE_BINARY_DIR}/src/common/event_logging.h
    COMMAND ${CMAKE_MC_COMPILER} -b -e h -h ${CMAKE_BINARY_DIR}/src/common/
      -r ${CMAKE_BINARY_DIR}/src/common ${CMAKE_SOURCE_DIR}/src/common/win32/event_logging.mc
    COMMAND ${CMAKE_RC_COMPILER} ${CMAKE_BINARY_DIR}/src/common/event_logging.rc
      -o ${CMAKE_BINARY_DIR}/src/common/event_logging.o
    COMMAND ${CMAKE_CXX_COMPILER} -o ${CMAKE_BINARY_DIR}/bin/event_logging.dll -shared
      ${CMAKE_BINARY_DIR}/src/common/event_logging.o
    DEPENDS ${CMAKE_SOURCE_DIR}/src/common/win32/event_logging.mc)

  set_source_files_properties(${CMAKE_SOURCE_DIR}/src/common/win32/syslog.cc
    APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/src/common/event_logging.h)

  include_directories(SYSTEM "${CMAKE_BINARY_DIR}/src/common/")

  list(APPEND common_srcs
    win32/blkdev.cc
    win32/dns_resolve.cc
    win32/ifaddrs.cc
    win32/registry.cc
    win32/service.cc
    win32/SubProcess.cc
    win32/syslog.cc)
else()
  list(APPEND common_srcs
    blkdev.cc
    dns_resolve.cc
    linux_version.c
    SubProcess.cc)
endif()

set_source_files_properties(${CMAKE_SOURCE_DIR}/src/common/version.cc
  APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/src/include/ceph_ver.h)

if(HAS_VTA)
  set_source_files_properties(
    config.cc
    options.cc
    PROPERTIES COMPILE_FLAGS -fno-var-tracking-assignments)
endif()

if(FREEBSD)
  list(APPEND common_srcs freebsd_errno.cc)
elseif(APPLE)
  list(APPEND common_srcs darwin_errno.cc)
elseif(SUN)
  list(APPEND common_srcs solaris_errno.cc)
elseif(AIX)
  list(APPEND common_srcs aix_errno.cc)
elseif(WIN32)
  list(APPEND common_srcs win32/errno.cc)
endif()

if(WITH_EVENTTRACE)
  list(APPEND common_srcs EventTrace.cc)
endif()

add_library(common-common-objs OBJECT
  ${common_srcs})
# Let's not rely on the default system headers and point Cmake to the
# retrieved OpenSSL location. This is especially important when cross
# compiling (e.g. targeting Windows).
target_include_directories(common-common-objs PRIVATE ${OPENSSL_INCLUDE_DIR})
# for options.cc
target_compile_definitions(common-common-objs PRIVATE
  "CEPH_LIBDIR=\"${CMAKE_INSTALL_FULL_LIBDIR}\""
  "CEPH_PKGLIBDIR=\"${CEPH_INSTALL_FULL_PKGLIBDIR}\""
  "CEPH_DATADIR=\"${CEPH_INSTALL_DATADIR}\"")
compile_with_fmt(common-common-objs)

set(common_mountcephfs_srcs
  armor.c
  safe_io.c
  module.c
  addr_parsing.c)
add_library(common_mountcephfs_objs OBJECT
  ${common_mountcephfs_srcs})


set(crc32_srcs
  crc32c.cc
  crc32c_intel_baseline.c
  sctp_crc32.c)
if(HAVE_INTEL)
  list(APPEND crc32_srcs
    crc32c_intel_fast.c)
  if(HAVE_NASM_X64)
    set(CMAKE_ASM_FLAGS "-i ${PROJECT_SOURCE_DIR}/src/isa-l/include/ ${CMAKE_ASM_FLAGS}")
    list(APPEND crc32_srcs
      ${PROJECT_SOURCE_DIR}/src/isa-l/crc/crc32_iscsi_00.asm
      crc32c_intel_fast_zero_asm.s)
  endif(HAVE_NASM_X64)
elseif(HAVE_POWER8)
  list(APPEND crc32_srcs
    crc32c_ppc.c)
  if(HAVE_PPC64LE)
    list(APPEND crc32_srcs
      crc32c_ppc_asm.S
      crc32c_ppc_fast_zero_asm.S)
  endif(HAVE_PPC64LE)
elseif(HAVE_ARMV8_CRC)
  list(APPEND crc32_srcs
    crc32c_aarch64.c)
endif(HAVE_INTEL)

add_library(crc32 STATIC ${crc32_srcs})
if(HAVE_ARMV8_CRC)
  set_target_properties(crc32 PROPERTIES
    COMPILE_FLAGS "${CMAKE_C_FLAGS} ${ARMV8_CRC_COMPILE_FLAGS}")
endif()
target_link_libraries(crc32
  arch)

add_library(common_utf8 STATIC utf8.c)

if(HAVE_KEYUTILS)
  set(parse_secret_srcs
    secret.c)
  add_library(parse_secret_objs OBJECT ${parse_secret_srcs})
endif()