forked from phdeniel/kvsns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
193 lines (151 loc) · 5.38 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
cmake_minimum_required(VERSION 2.6.3)
cmake_policy(SET CMP0017 NEW)
PROJECT(libkvsns C)
set(LIBKVSNS_MAJOR_VERSION 1)
set(LIBKVSNS_MINOR_VERSION 2)
set(LIBKVSNS_PATCH_LEVEL 3)
set(LIBKVSNS_EXTRA_VERSION "")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${CMAKE_SOURCE_DIR}/include -fPIC -g")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror")
set(LIBKVSNS_BASE_VERSION ${LIBKVSNS_MAJOR_VERSION}.${LIBKVSNS_MINOR_VERSION}.${LIBKVSNS_PATCH_LEVEL})
message( STATUS "cmake version ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" )
message( STATUS "libkvsns version ${LIBKVSNS_BASE_VERSION}")
# Option (for choosing KVSAL backend)
option(USE_KVS_REDIS "Use REDIS as a KVS in KVSAL" ON)
option(USE_KVS_MERO "Use MERO as a KVS in KVSAL" OFF)
option(USE_POSIX_STORE "Use POSIX directory as object store" ON)
option(USE_POSIX_OBJ "Use POSIX with objs and keys" OFF)
option(USE_RADOS "Use Ceph/RADOS via librados" OFF)
if(USE_FSAL_LUSTRE)
set(BCOND_LUSTRE "%bcond_without")
else(USE_FSAL_LUSTRE)
set(BCOND_LUSTRE "%bcond_with")
endif(USE_FSAL_LUSTRE)
# BCOND* variables for spec file */
if (USE_KVS_REDIS)
set(BCOND_KVS_REDIS "%bcond_without")
else (USE_KVS_REDIS)
set(BCOND_KVS_REDIS "%bcond_with")
endif (USE_KVS_REDIS)
if (USE_POSIX_STORE)
set(BCOND_POSIX_STORE "%bcond_without")
else (USE_POSIX_STORE)
set(BCOND_POSIX_STORE "%bcond_with")
endif (USE_POSIX_STORE)
if (USE_POSIX_OBJ)
set(BCOND_POSIX_OBJ "%bcond_without")
else (USE_POSIX_OBJ)
set(BCOND_POSIX_OBJ "%bcond_with")
endif (USE_POSIX_OBJ)
if (USE_RADOS)
set(BCOND_RADOS "%bcond_without")
else (USE_RADOS)
set(BCOND_RADOS "%bcond_with")
endif (USE_RADOS)
# Final tuning
if (USE_POSIX_OBJ OR USE_RADOS)
set(USE_POSIX_STORE OFF)
message(STATUS "Disabling POSIX Store")
endif(USE_POSIX_OBJ OR USE_RADOS)
message(STATUS "USE_KVS_REDIS=${USE_KVS_REDIS}")
message(STATUS "USE_POSIX_STORE=${USE_POSIX_STORE}")
message(STATUS "USE_POSIX_OBJ=${USE_POSIX_OBJ}")
message(STATUS "USE_RADOS=${USE_RADOS}")
include(CheckIncludeFiles)
include(CheckLibraryExists)
## Check ini_config
check_include_files("ini_config.h" HAVE_INI_CONFIG_H)
find_library(HAVE_INI_CONFIG ini_config)
check_library_exists(
ini_config
config_from_file
""
HAVE_INI_CONFIG
)
if((NOT HAVE_INI_CONFIG) OR (NOT HAVE_INI_CONFIG_H))
message(FATAL_ERROR "Cannot find ini_config")
endif((NOT HAVE_INI_CONFIG) OR (NOT HAVE_INI_CONFIG_H))
## Start building stuff ##
if(USE_KVS_REDIS)
find_library(HAVE_HIREDIS hiredis)
check_library_exists(
hiredis
redisCommand
""
HAVE_HIREDIS
)
check_include_files("hiredis/hiredis.h" HAVE_HIREDIS_H)
if((NOT HAVE_HIREDIS) OR (NOT HAVE_HIREDIS_H))
message(FATAL_ERROR "Cannot find hiredis")
endif((NOT HAVE_HIREDIS) OR (NOT HAVE_HIREDIS_H))
endif(USE_KVS_REDIS)
### Check for rados ###
if(USE_RADOS)
check_library_exists(
rados
rados_connect
""
HAVE_LIBRADOS
)
check_include_files("rados/librados.h" HAVE_RADOS_H)
if((NOT HAVE_LIBRADOS) OR (NOT HAVE_RADOS_H))
message(FATAL_ERROR "Cannot find librados")
endif((NOT HAVE_LIBRADOS) OR (NOT HAVE_RADOS_H))
endif(USE_RADOS)
# Build ancillary libs
add_subdirectory(extstore)
set(STORE_LIBRARY extstore)
add_subdirectory(kvsal)
set(KVSAL_LIBRARY kvsal)
add_subdirectory(kvsns)
add_subdirectory(tests)
add_subdirectory(kvsns_shell)
add_subdirectory(kvsns_attach)
add_subdirectory(kvsal_non_reg)
# CPack / rpmbuild specific stuff
set(CPACK_PACKAGE_FILE_NAME "libkvsns-Source" )
set(CPACK_PACKAGE_VENDOR "KVSNS")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "KVSNS - a namespace on top of a KVS")
SET(CPACK_PACKAGE_VERSION_MAJOR ${LIBKVSNS_MAJOR_VERSION})
SET(CPACK_PACKAGE_VERSION_MINOR ${LIBKVSNS_MINOR_VERSION})
SET(CPACK_PACKAGE_VERSION_PATCH ${LIBKVSNS_PATCH_LEVEL})
# Tell CPack the kind of packages to be generated
set(CPACK_GENERATOR "TGZ")
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_IGNORE_FILES
"/.git/;/.gitignore/;/build/;/.bzr/;~$;${CPACK_SOURCE_IGNORE_FILES}")
include(CPack)
set(PKG_NAME "${CPACK_PACKAGE_NAME}.tar.gz")
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
# Create the .pc file
configure_file(
"${PROJECT_SOURCE_DIR}/libkvsns.pc-in.cmake"
"${PROJECT_SOURCE_DIR}/libkvsns.pc"
)
# Now create a useable specfile
configure_file(
"${PROJECT_SOURCE_DIR}/libkvsns.spec-in.cmake"
"${PROJECT_SOURCE_DIR}/libkvsns.spec"
)
set(RPMDEST "--define '_srcrpmdir ${CMAKE_CURRENT_BINARY_DIR}'")
add_custom_target( rpms DEPENDS dist)
add_custom_command(TARGET rpms
COMMAND sh -c "rpmbuild ${RPMDEST} -ta ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz"
VERBATIM
DEPENDS dist)
add_custom_target( rpm DEPENDS dist)
add_custom_command(TARGET rpm
COMMAND sh -c "rpmbuild ${RPMDEST} -tb ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz"
VERBATIM
DEPENDS dist)
add_custom_target( srpm DEPENDS dist)
add_custom_command(TARGET srpm
COMMAND sh -c "rpmbuild ${RPMDEST} -ts ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz"
VERBATIM
DEPENDS dist)
# INSTALL
install(FILES ${PROJECT_SOURCE_DIR}/libkvsns.pc DESTINATION lib)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/kvsns DESTINATION include)
#install(FILES ${PROJECT_SOURCE_DIR}/include/kvsns/kvsns.h DESTINATION include/kvsns)
#install(FILES ${PROJECT_SOURCE_DIR}/include/kvsns/kvsal.h DESTINATION include/kvsns)
##install(FILES ${PROJECT_SOURCE_DIR}/include/kvsns/extstore.h DESTINATION include/kvsns)