forked from irods/mungefs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
279 lines (240 loc) · 12.7 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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
cmake_minimum_required(VERSION 3.5.0 FATAL_ERROR) #CPACK_DEBIAN_<COMPONENT>_PACKAGE_NAME
set(MUNGEFS_VERSION_MAJOR "1")
set(MUNGEFS_VERSION_MINOR "0")
set(MUNGEFS_VERSION_PATCH "2")
set(MUNGEFS_VERSION "${MUNGEFS_VERSION_MAJOR}.${MUNGEFS_VERSION_MINOR}.${MUNGEFS_VERSION_PATCH}")
set(MUNGEFS_CXX_STANDARD 14)
if (NOT IRODS_EXTERNALS_PACKAGE_ROOT)
set(IRODS_EXTERNALS_PACKAGE_ROOT "/opt/irods-externals" CACHE STRING "Choose the location of iRODS external packages." FORCE)
message(STATUS "Setting unspecified IRODS_EXTERNALS_PACKAGE_ROOT to '${IRODS_EXTERNALS_PACKAGE_ROOT}'. This is the correct setting for normal builds.")
endif()
macro(CHECK_DEPENDENCY_SET_FULLPATH DEPENDENCY_NAME DEPENDENCY_SUBDIRECTORY)
if (IS_DIRECTORY ${IRODS_EXTERNALS_FULLPATH_${DEPENDENCY_NAME}})
message(STATUS "Using user-specified value for IRODS_EXTERNALS_FULLPATH_${DEPENDENCY_NAME}: ${IRODS_EXTERNALS_FULLPATH_${DEPENDENCY_NAME}}")
else()
if (NOT IS_DIRECTORY ${IRODS_EXTERNALS_PACKAGE_ROOT}/${DEPENDENCY_SUBDIRECTORY})
message(FATAL_ERROR "${DEPENDENCY_NAME} not found at ${IRODS_EXTERNALS_PACKAGE_ROOT}/${DEPENDENCY_SUBDIRECTORY}")
endif()
set(IRODS_EXTERNALS_FULLPATH_${DEPENDENCY_NAME} ${IRODS_EXTERNALS_PACKAGE_ROOT}/${DEPENDENCY_SUBDIRECTORY})
endif()
endmacro()
macro(CHECK_DEPENDENCY_SET_FULLPATH_ADD_TO_PACKAGE_DEPENDENCIES_LIST DEPENDENCY_NAME DEPENDENCY_SUBDIRECTORY)
CHECK_DEPENDENCY_SET_FULLPATH(${DEPENDENCY_NAME} ${DEPENDENCY_SUBDIRECTORY})
list(APPEND MUNGEFS_PACKAGE_DEPENDENCIES_LIST irods-externals-${DEPENDENCY_SUBDIRECTORY})
endmacro()
CHECK_DEPENDENCY_SET_FULLPATH(CLANG clang6.0-0)
CHECK_DEPENDENCY_SET_FULLPATH(CPPZMQ cppzmq4.2.3-0)
CHECK_DEPENDENCY_SET_FULLPATH_ADD_TO_PACKAGE_DEPENDENCIES_LIST(ARCHIVE libarchive3.3.2-1)
CHECK_DEPENDENCY_SET_FULLPATH_ADD_TO_PACKAGE_DEPENDENCIES_LIST(AVRO avro1.9.0-0)
CHECK_DEPENDENCY_SET_FULLPATH_ADD_TO_PACKAGE_DEPENDENCIES_LIST(BOOST boost1.67.0-0)
CHECK_DEPENDENCY_SET_FULLPATH_ADD_TO_PACKAGE_DEPENDENCIES_LIST(CLANG_RUNTIME clang-runtime6.0-0)
CHECK_DEPENDENCY_SET_FULLPATH_ADD_TO_PACKAGE_DEPENDENCIES_LIST(ZMQ zeromq4-14.1.6-0)
string(REPLACE ";" ", " MUNGEFS_PACKAGE_DEPENDENCIES_STRING "${MUNGEFS_PACKAGE_DEPENDENCIES_LIST}")
project(mungefs C CXX)
set(MUNGEFS_PLATFORM_STRING linux_platform)
set(MUNGEFS_COMPILE_DEFINITIONS ${MUNGEFS_PLATFORM_STRING} _LARGEFILE_SOURCE _FILE_OFFSET_BITS=64 _LARGE_FILES _LARGEFILE64_SOURCE BOOST_SYSTEM_NO_DEPRECATED)
if (NOT MUNGEFS_LINUX_DISTRIBUTION_NAME)
execute_process(
COMMAND "python" "-c" "from __future__ import print_function; import platform; print(platform.linux_distribution()[0].split()[0].strip().lower(), end='')"
RESULT_VARIABLE MUNGEFS_EXECUTE_PROCESS_RESULT_LINUX_DISTRIBUTION_NAME
OUTPUT_VARIABLE MUNGEFS_LINUX_DISTRIBUTION_NAME
)
if (NOT ${MUNGEFS_EXECUTE_PROCESS_RESULT_LINUX_DISTRIBUTION_NAME} STREQUAL "0")
message(FATAL_ERROR "Linux platform name detection failed\n${MUNGEFS_EXECUTE_PROCESS_RESULT_LINUX_DISTRIBUTION_NAME}")
endif()
set(MUNGEFS_LINUX_DISTRIBUTION_NAME ${MUNGEFS_LINUX_DISTRIBUTION_NAME} CACHE STRING "Linux distribution name, e.g. {ubuntu, centos, ...}." FORCE)
message(STATUS "Setting unspecified MUNGEFS_LINUX_DISTRIBUTION_NAME to '${MUNGEFS_LINUX_DISTRIBUTION_NAME}'")
endif()
if (NOT MUNGEFS_LINUX_DISTRIBUTION_VERSION_MAJOR)
execute_process(
COMMAND "python" "-c" "from __future__ import print_function; import platform; print(platform.linux_distribution()[1].strip().lower().split('.')[0], end='')"
RESULT_VARIABLE MUNGEFS_EXECUTE_PROCESS_RESULT_LINUX_DISTRIBUTION_VERSION_MAJOR
OUTPUT_VARIABLE MUNGEFS_LINUX_DISTRIBUTION_VERSION_MAJOR
)
if (NOT ${MUNGEFS_EXECUTE_PROCESS_RESULT_LINUX_DISTRIBUTION_VERSION_MAJOR} STREQUAL "0")
message(FATAL_ERROR "Linux platform name detection failed\n${MUNGEFS_EXECUTE_PROCESS_RESULT_LINUX_DISTRIBUTION_VERSION_MAJOR}")
endif()
set(MUNGEFS_LINUX_DISTRIBUTION_VERSION_MAJOR ${MUNGEFS_LINUX_DISTRIBUTION_VERSION_MAJOR} CACHE STRING "Linux distribution name, e.g. {ubuntu, centos, ...}." FORCE)
message(STATUS "Setting unspecified MUNGEFS_LINUX_DISTRIBUTION_VERSION_MAJOR to '${MUNGEFS_LINUX_DISTRIBUTION_VERSION_MAJOR}'")
endif()
if(MUNGEFS_LINUX_DISTRIBUTION_NAME STREQUAL "ubuntu" OR MUNGEFS_LINUX_DISTRIBUTION_NAME STREQUAL "debian")
if (NOT MUNGEFS_LINUX_DISTRIBUTION_VERSION_CODENAME)
execute_process(
COMMAND "lsb_release" "-s" "-c"
RESULT_VARIABLE MUNGEFS_EXECUTE_PROCESS_RESULT_LINUX_DISTRIBUTION_VERSION_CODENAME
OUTPUT_VARIABLE MUNGEFS_LINUX_DISTRIBUTION_VERSION_CODENAME
)
string(STRIP ${MUNGEFS_LINUX_DISTRIBUTION_VERSION_CODENAME} MUNGEFS_LINUX_DISTRIBUTION_VERSION_CODENAME)
if (NOT ${MUNGEFS_EXECUTE_PROCESS_RESULT_LINUX_DISTRIBUTION_VERSION_CODENAME} STREQUAL "0")
message(FATAL_ERROR "Linux lsb_release shortname detection failed\n${MUNGEFS_EXECUTE_PROCESS_RESULT_LINUX_DISTRIBUTION_VERSION_CODENAME}")
endif()
set(MUNGEFS_LINUX_DISTRIBUTION_VERSION_CODENAME ${MUNGEFS_LINUX_DISTRIBUTION_VERSION_CODENAME} CACHE STRING "Linux distribution version codename, e.g. {precise, wheezy, trusty, jessie, ...}." FORCE)
message(STATUS "Setting unspecified MUNGEFS_LINUX_DISTRIBUTION_VERSION_CODENAME to '${MUNGEFS_LINUX_DISTRIBUTION_VERSION_CODENAME}'")
endif()
endif()
if (NOT CPACK_GENERATOR)
if (MUNGEFS_LINUX_DISTRIBUTION_NAME STREQUAL "arch")
set(CPACK_GENERATOR TGZ CACHE STRING "CPack generator to use, e.g. {DEB, RPM, TGZ}." FORCE)
message(STATUS "Setting unspecified CPACK_GENERATOR to ${CPACK_GENERATOR}. This is the correct setting for normal builds.")
elseif(MUNGEFS_LINUX_DISTRIBUTION_NAME STREQUAL "ubuntu" OR MUNGEFS_LINUX_DISTRIBUTION_NAME STREQUAL "debian")
set(CPACK_GENERATOR DEB CACHE STRING "CPack generator to use, e.g. {DEB, RPM, TGZ}." FORCE)
message(STATUS "Setting unspecified CPACK_GENERATOR to ${CPACK_GENERATOR}. This is the correct setting for normal builds.")
elseif(MUNGEFS_LINUX_DISTRIBUTION_NAME STREQUAL "centos" OR MUNGEFS_LINUX_DISTRIBUTION_NAME STREQUAL "opensuse" OR MUNGEFS_LINUX_DISTRIBUTION_NAME STREQUAL "fedora")
set(CPACK_GENERATOR RPM CACHE STRING "CPack generator to use, e.g. {DEB, RPM, TGZ}." FORCE)
message(STATUS "Setting unspecified CPACK_GENERATOR to ${CPACK_GENERATOR}. This is the correct setting for normal builds.")
else()
message(FATAL_ERROR "Failed to set CPACK_GENERATOR for unknown Linux Distribution: ${MUNGEFS_LINUX_DISTRIBUTION_NAME}")
endif()
endif()
set(MUNGEFS_CPACK_GENERATOR ${CPACK_GENERATOR})
if (CPACK_GENERATOR STREQUAL "DEB")
if (NOT CPACK_DEBIAN_PACKAGE_VERSION)
set(CPACK_DEBIAN_PACKAGE_VERSION ${MUNGEFS_VERSION} CACHE STRING "Version string used by .deb packages." FORCE)
message(STATUS "Setting unspecified CPACK_DEBIAN_PACKAGE_VERSION to '${CPACK_DEBIAN_PACKAGE_VERSION}'. This is the correct setting for normal builds.")
endif()
endif()
# CPACK names component package files as "${CPACK_PACKAGE_FILE_NAME}-${COMPONENT_NAME}"
# CPackDeb TO_UPPERs all the component names when checking the ${CPACK_DEBIAN_<COMPONENT>...} variables
if (CPACK_GENERATOR STREQUAL "RPM")
set(MUNGEFS_PACKAGE_FILE_NAME_SUFFIX "-${MUNGEFS_VERSION}-1.${CMAKE_SYSTEM_PROCESSOR}")
elseif(CPACK_GENERATOR STREQUAL "DEB")
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(CMAKE_SYSTEM_PROCESSOR "amd64")
endif()
set(MUNGEFS_PACKAGE_FILE_NAME_SUFFIX "_${CPACK_DEBIAN_PACKAGE_VERSION}~${MUNGEFS_LINUX_DISTRIBUTION_VERSION_CODENAME}_${CMAKE_SYSTEM_PROCESSOR}")
else()
set(MUNGEFS_PACKAGE_FILE_NAME_SUFFIX "-${MUNGEFS_VERSION}-${MUNGEFS_LINUX_DISTRIBUTION_NAME}${MUNGEFS_LINUX_DISTRIBUTION_VERSION_MAJOR}-${CMAKE_SYSTEM_PROCESSOR}")
endif()
if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build {Debug, Release}." FORCE)
message(STATUS "Setting unspecified CMAKE_BUILD_TYPE to '${CMAKE_BUILD_TYPE}'. This is the correct setting for normal builds.")
endif()
if (NOT CPACK_PACKAGING_INSTALL_PREFIX)
set(CPACK_PACKAGING_INSTALL_PREFIX "/" CACHE STRING "Package root path. \"/\" is correct for normal package builds.." FORCE)
message(STATUS "Setting unspecified CPACK_PACKAGING_INSTALL_PREFIX to '${CPACK_PACKAGING_INSTALL_PREFIX}'. This is the correct setting for normal builds.")
endif()
add_compile_options(-nostdinc++ -Wall -Werror)
include_directories(${IRODS_EXTERNALS_FULLPATH_CLANG}/include/c++/v1)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
find_package(FUSE 2.6 REQUIRED)
add_executable(
mungefs
${CMAKE_SOURCE_DIR}/mungefs_server.cpp
${CMAKE_SOURCE_DIR}/mungefs_operations.cpp
${CMAKE_SOURCE_DIR}/main.cpp
)
target_link_libraries(
mungefs
PRIVATE
${IRODS_EXTERNALS_FULLPATH_AVRO}/lib/libavrocpp.so
${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_filesystem.so
${IRODS_EXTERNALS_FULLPATH_BOOST}/lib/libboost_system.so
${IRODS_EXTERNALS_FULLPATH_ARCHIVE}/lib/libarchive.so
${IRODS_EXTERNALS_FULLPATH_ZMQ}/lib/libzmq.so
${FUSE_LIBRARIES}
Threads::Threads
)
target_include_directories(
mungefs
PRIVATE
${IRODS_EXTERNALS_FULLPATH_AVRO}/include
${IRODS_EXTERNALS_FULLPATH_BOOST}/include
${IRODS_EXTERNALS_FULLPATH_ZMQ}/include
${IRODS_EXTERNALS_FULLPATH_CPPZMQ}/include
${CMAKE_BINARY_DIR}/include
${FUSE_INCLUDE_DIRS}
)
target_compile_definitions(mungefs PRIVATE ${MUNGEFS_COMPILE_DEFINITIONS})
target_compile_options(mungefs PRIVATE -Wno-write-strings)
set_property(TARGET mungefs PROPERTY CXX_STANDARD ${MUNGEFS_CXX_STANDARD})
add_executable(
mungefsctl
${CMAKE_SOURCE_DIR}/mungefsctl.cpp
)
target_link_libraries(
mungefsctl
PRIVATE
${AVRO_PATH}/lib/libavrocpp.so
${BOOST_PATH}/lib/libboost_filesystem.so
${BOOST_PATH}/lib/libboost_system.so
${BOOST_PATH}/lib/libboost_program_options.so
${ZMQ_PATH}/lib/libzmq.so
${FUSE_LIBRARIES}
Threads::Threads
)
target_include_directories(
mungefsctl
PRIVATE
${AVRO_PATH}/include
${BOOST_PATH}/include
${ZMQ_PATH}/include
${CPPZMQ_PATH}/include
${CMAKE_BINARY_DIR}/include
)
target_compile_definitions(mungefsctl PRIVATE ${MUNGEFS_COMPILE_DEFINITIONS})
target_compile_options(mungefsctl PRIVATE -Wno-write-strings)
set_property(TARGET mungefsctl PROPERTY CXX_STANDARD ${MUNGEFS_CXX_STANDARD})
set (
AVRO_FILE
mungefs_ctl
)
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/include)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/include/${AVRO_FILE}.hpp
COMMAND LD_LIBRARY_PATH=${BOOST_PATH}/lib:${CLANG_LIBS} ${IRODS_EXTERNALS_FULLPATH_AVRO}/bin/avrogencpp -o ${CMAKE_BINARY_DIR}/include/${AVRO_FILE}.hpp -i ${CMAKE_SOURCE_DIR}/avro_schemas/${AVRO_FILE}.json
MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/avro_schemas/${AVRO_FILE}.json
)
set_source_files_properties(
${CMAKE_SOURCE_DIR}/mungefsctl.cpp
PROPERTIES
OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/include/${AVRO_FILE}.hpp
)
set_source_files_properties(
${CMAKE_SOURCE_DIR}/mungefs_server.cpp
PROPERTIES
OBJECT_DEPENDS ${CMAKE_BINARY_DIR}/include/${AVRO_FILE}.hpp
)
install(
TARGETS
mungefs
mungefsctl
RUNTIME
DESTINATION usr/bin
)
set(CPACK_PACKAGE_FILE_NAME "mungefs${MUNGEFS_PACKAGE_FILE_NAME_SUFFIX}")
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
set(CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY OFF)
set(CPACK_COMPONENTS_GROUPING IGNORE)
set(CPACK_PACKAGE_VERSION ${MUNGEFS_VERSION})
set(CPACK_PACKAGE_VERSION_MAJOR ${MUNGEFS_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${MUNGEFS_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${MUNGEFS_VERSION_PATCH})
set(CPACK_PACKAGE_CONTACT "Renaissance Computing Institute <[email protected]>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The integrated Rule-Oriented Data System")
set(CPACK_PACKAGE_VENDOR "Renaissance Computing Institute <[email protected]>")
set(CPACK_DEB_COMPONENT_INSTALL OFF)
set(CPACK_DEBIAN_PACKAGE_SECTION "contrib/science")
set(CPACK_DEBIAN_COMPRESSION_TYPE "gzip")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "extra")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://irods.org")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS OFF)
set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION ON)
set(CPACK_RPM_COMPONENT_INSTALL OFF)
set(CPACK_RPM_PACKAGE_RELEASE "1")
set(CPACK_RPM_PACKAGE_LICENSE "BSD-3-Clause")
set(CPACK_RPM_PACKAGE_VENDOR "iRODS Consortium")
set(CPACK_RPM_PACKAGE_URL "https://irods.org")
set(CPACK_RPM_PACKAGE_AUTOREQ 0)
set(CPACK_RPM_PACKAGE_AUTOPROV 0)
set(CPACK_ARCHIVE_COMPONENT_INSTALL OFF)
set(CPACK_DEBIAN_PACKAGE_NAME "mungefs")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${MUNGEFS_PACKAGE_DEPENDENCIES_STRING}, libc6")
set(CPACK_RPM_PACKAGE_NAME "mungefs")
set(CPACK_RPM_PACKAGE_REQUIRES "${MUNGEFS_PACKAGE_DEPENDENCIES_STRING}")
if (NOT CPACK_GENERATOR)
set(CPACK_GENERATOR ${MUNGEFS_CPACK_GENERATOR} CACHE STRING "CPack generator to use, e.g. {DEB, RPM, TGZ}." FORCE)
message(STATUS "Setting unspecified CPACK_GENERATOR to ${CPACK_GENERATOR}. This is the correct setting for normal builds.")
endif()
include(CPack)