forked from open-iscsi/tcmu-runner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
263 lines (235 loc) · 5.96 KB
/
CMakeLists.txt
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
cmake_minimum_required (VERSION 2.8 FATAL_ERROR)
project (tcmu-runner C)
set(VERSION 1.2.0)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=c99")
include(GNUInstallDirs)
include(CheckIncludeFile)
set(tcmu-runner_HANDLER_PATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/tcmu-runner")
option(with-glfs "build Gluster glfs handler" true)
option(with-qcow "build qcow handler" true)
option(with-rbd "build Ceph rbd handler" true)
find_library(LIBNL_LIB nl-3)
find_library(LIBNL_GENL_LIB nl-genl-3)
set(LIBNL_LIBS
${LIBNL_LIB}
${LIBNL_GENL_LIB}
)
find_path (LIBNL_INCLUDE_DIR
NAMES
netlink/netlink.h
PATH_SUFFIXES
libnl3
)
find_package(PkgConfig)
pkg_check_modules(GLIB REQUIRED gio-unix-2.0)
pkg_check_modules(KMOD REQUIRED libkmod)
find_library(PTHREAD pthread)
find_library(DL dl)
# Stuff for building the shared library
add_library(tcmu
SHARED
configfs.c
api.c
libtcmu.c
libtcmu-register.c
tcmuhandler-generated.c
libtcmu_log.c
libtcmu_config.c
libtcmu_time.c
)
set_target_properties(tcmu
PROPERTIES
SOVERSION "1"
)
target_include_directories(tcmu
PUBLIC ${LIBNL_INCLUDE_DIR}
PUBLIC ${GLIB_INCLUDE_DIRS}
PUBLIC ${PROJECT_SOURCE_DIR}/ccan
)
target_link_libraries(tcmu
${LIBNL_LIB}
${LIBNL_GENL_LIB}
${GLIB_LIBRARIES}
)
install(TARGETS tcmu LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
# Stuff for building the static library
add_library(tcmu_static
configfs.c
api.c
libtcmu.c
libtcmu-register.c
tcmuhandler-generated.c
libtcmu_log.c
libtcmu_config.c
)
target_include_directories(tcmu_static
PUBLIC ${LIBNL_INCLUDE_DIR}
PUBLIC ${GLIB_INCLUDE_DIRS}
PUBLIC ${PROJECT_SOURCE_DIR}/ccan
)
target_link_libraries(tcmu_static
${GLIB_LIBRARIES}
)
# Stuff for building the main binary
add_executable(tcmu-runner
tcmur_cmd_handler.c
tcmur_aio.c
alua.c
main.c
tcmuhandler-generated.c
)
target_link_libraries(tcmu-runner tcmu)
target_include_directories(tcmu-runner
PUBLIC ${PROJECT_BINARY_DIR}
PUBLIC ${GLIB_INCLUDE_DIRS}
PUBLIC ${KMOD_INCLUDE_DIRS}
PUBLIC ${PROJECT_SOURCE_DIR}/ccan
)
target_link_libraries(tcmu-runner
${GLIB_LIBRARIES}
${PTHREAD}
${DL}
${KMOD_LIBRARIES}
-Wl,--no-export-dynamic
-Wl,--dynamic-list=${CMAKE_SOURCE_DIR}/main-syms.txt
)
install(TARGETS tcmu-runner RUNTIME DESTINATION bin)
add_executable(tcmu-synthesizer
tcmu-synthesizer.c
)
target_link_libraries(tcmu-synthesizer tcmu)
target_include_directories(tcmu-synthesizer
PUBLIC ${PROJECT_BINARY_DIR}
PUBLIC ${GLIB_INCLUDE_DIRS}
PUBLIC ${PROJECT_SOURCE_DIR}/ccan
)
target_link_libraries(tcmu-synthesizer
${GLIB_LIBRARIES}
)
install(TARGETS RUNTIME DESTINATION bin)
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/tcmuhandler-generated.c ${CMAKE_SOURCE_DIR}/tcmuhandler-generated.h
COMMAND gdbus-codegen ${CMAKE_SOURCE_DIR}/tcmu-handler.xml --generate-c-code ${CMAKE_SOURCE_DIR}/tcmuhandler-generated --c-generate-object-manager --interface-prefix org.kernel
MAIN_DEPENDENCY tcmu-handler.xml
)
add_custom_target(
cscope
COMMAND find -name '*.[ch]' > cscope.files
COMMAND cscope -bq
)
set_directory_properties(
PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
"cscope.files;cscope.in.out;cscope.out;cscope.po.out"
)
# Stuff for building the file handler
add_library(handler_file
SHARED
file_example.c
)
set_target_properties(handler_file
PROPERTIES
PREFIX ""
)
target_include_directories(handler_file
PUBLIC ${PROJECT_SOURCE_DIR}/ccan
)
# Stuff for building the file optical handler
add_library(handler_file_optical
SHARED
file_optical.c
)
set_target_properties(handler_file_optical
PROPERTIES
PREFIX ""
)
target_include_directories(handler_file_optical
PUBLIC ${PROJECT_SOURCE_DIR}/ccan
)
target_link_libraries(handler_file_optical ${PTHREAD})
# The minimal library consumer
add_executable(consumer
consumer.c
)
target_link_libraries(consumer tcmu)
if (with-rbd)
find_library(LIBRBD rbd)
# Stuff for building the rbd handler
add_library(handler_rbd
SHARED
rbd.c
)
set_target_properties(handler_rbd
PROPERTIES
PREFIX ""
)
target_include_directories(handler_rbd
PUBLIC ${PROJECT_SOURCE_DIR}/ccan
)
target_link_libraries(handler_rbd
${LIBRBD}
)
install(TARGETS handler_rbd DESTINATION ${CMAKE_INSTALL_LIBDIR}/tcmu-runner)
endif (with-rbd)
if (with-glfs)
find_library(GFAPI gfapi)
# Stuff for building the glfs handler
add_library(handler_glfs
SHARED
glfs.c
)
set_target_properties(handler_glfs
PROPERTIES
PREFIX ""
)
target_include_directories(handler_glfs
PUBLIC ${PROJECT_SOURCE_DIR}/ccan
)
target_link_libraries(handler_glfs
${GFAPI}
)
install(TARGETS handler_glfs DESTINATION ${CMAKE_INSTALL_LIBDIR}/tcmu-runner)
endif (with-glfs)
if (with-qcow)
find_package(ZLIB REQUIRED)
# Stuff for building the qcow handler
add_library(handler_qcow
SHARED
qcow.c
)
set_target_properties(handler_qcow
PROPERTIES
PREFIX ""
)
target_include_directories(handler_qcow
PUBLIC ${PROJECT_SOURCE_DIR}/ccan
)
CHECK_INCLUDE_FILE("linux/falloc.h" HAVE_LINUX_FALLOC)
if (HAVE_LINUX_FALLOC)
set_target_properties(handler_qcow
PROPERTIES
COMPILE_FLAGS "-DHAVE_LINUX_FALLOC"
)
endif (HAVE_LINUX_FALLOC)
target_link_libraries(handler_qcow
${ZLIB_LIBRARIES}
)
install(TARGETS handler_qcow DESTINATION ${CMAKE_INSTALL_LIBDIR}/tcmu-runner)
endif (with-qcow)
# stamp out a header file to pass some of the CMake settings
# to the source code
configure_file (
"${PROJECT_SOURCE_DIR}/version.h.in"
"${PROJECT_SOURCE_DIR}/version.h"
)
install(FILES libtcmu.h libtcmu_common.h tcmu-runner.h
DESTINATION include)
install(FILES tcmu.conf
DESTINATION /etc/tcmu)
install(FILES org.kernel.TCMUService1.service
DESTINATION /usr/share/dbus-1/system-services)
install(FILES tcmu-runner.conf DESTINATION /etc/dbus-1/system.d)
if (SUPPORT_SYSTEMD)
install(FILES tcmu-runner.service DESTINATION /usr/lib/systemd/system/)
endif (SUPPORT_SYSTEMD)
install(FILES tcmu-runner.8
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/man/man8)