This repository has been archived by the owner on Nov 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
executable file
·166 lines (126 loc) · 6.75 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
# We are very grateful to Utrecht University for inspiration on CMake procedures
# https://github.com/UtrechtUniversity/irods-uu-microservices (feature branch 4.2.3)
# Note: Microservices for iRODS >= 4.2 need to be built with the compiler and
# standard library provided by iRODS-externals packages.
# The following packages need to be installed to build the irods-microservices:
#
# irods-externals-clang-runtime3.8-0
# irods-externals-clang3.8-0
# irods-externals
# Specify the minimum version for CMake
cmake_minimum_required(VERSION 3.3.0 FATAL_ERROR)
# Set global CMAKE variables
# Note: Some of the include dirs (like CURL) can automatically be found by CMake at the 'include_directories' step and do not have to be set here.
# See https://cmake.org/cmake/help/v3.0/module/FindCURL.html
set(MSI_RELEASE_VERSION "2.0.0")
set(IRODS_VERSION $ENV{IRODS_VERSION}) # Get iRODS version from environment
#set(IRODS_VERSION "4.2.4") # Or specificy iRODS version manually
# Set additional modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/CMakeModules")
# Set some paths for dependencies from irods-externals
set(BOOST_ROOT "/opt/irods-externals/boost1.67.0-0")
set(IRODS_EXTERNALS_FULLPATH_CLANG /opt/irods-externals/clang6.0-0)
# Set compiler options
add_compile_options(-std=c++14
-Os
-fPIC
-DRODS_SERVER
-nostdinc++
-Wall
-Wextra
-Wpedantic
-Wcast-align
-Wredundant-decls
-Wuninitialized
-Wconversion
-Wno-missing-field-initializers
-Wno-unused-parameter
-Wno-gnu-zero-variadic-macro-arguments)
# Use shared libraries in this project
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -stdlib=libc++")
link_libraries(c++abi)
# Specify which C and C++ compiler to use
set(CMAKE_C_COMPILER ${IRODS_EXTERNALS_FULLPATH_CLANG}/bin/clang)
set(CMAKE_CXX_COMPILER ${IRODS_EXTERNALS_FULLPATH_CLANG}/bin/clang++)
# Set the project's name and which compiler(s) to use
project(irods-microservices C CXX)
# Check installed iRODS version
#find_package(IRODS ${IRODS_VERSION} EXACT REQUIRED)
message(STATUS "Building microservices version ${MSI_RELEASE_VERSION} for irods-server version ${IRODS_VERSION}")
# Include the header files into the project
include_directories("${IRODS_EXTERNALS_FULLPATH_CLANG}/include/c++/v1")
include_directories("/usr/include/irods")
find_package(Boost REQUIRED)
include_directories(SYSTEM ${Boost_INCLUDE_DIR})
find_package(CURL REQUIRED)
include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
find_package(Jansson REQUIRED)
include_directories(SYSTEM ${JANSSON_INCLUDE_DIRS})
find_package(Rabbitmq REQUIRED)
include_directories(SYSTEM ${RABBITMQ_INCLUDE_DIRS} )
include_directories("/usr/include/irods")
# Generate the shared Library (= binary) from the source code
# Note: unlike an Executable, a library does not contain a main method. It just contains the classes
add_library(msi_getenv SHARED msi_getenv/msi_getenv.cpp)
add_library(msi_json_arrayops SHARED msi_json_arrayops/libmsi_json_arrayops.cpp)
add_library(msi_json_objops SHARED msi_json_objops/libmsi_json_objops.cpp)
#add_library(msi_time_ts2str SHARED msi_time_ts2str/libmsi_time_ts2str.cpp)
# Link the generated library to dependency libraries
target_link_libraries(msi_getenv LINK_PUBLIC ${Boost_LIBRARIES})
target_link_libraries(msi_json_arrayops LINK_PUBLIC ${JANSSON_LIBRARIES} ${Boost_LIBRARIES})
target_link_libraries(msi_json_objops LINK_PUBLIC ${JANSSON_LIBRARIES} ${Boost_LIBRARIES})
#target_link_libraries(msi_time_ts2str LINK_PUBLIC ${Boost_LIBRARIES})
# Set the location for library installation
install(CODE "MESSAGE(\"Installing microservices to iRODS plugins folder...\")")
install(TARGETS
msi_getenv
msi_json_arrayops
msi_json_objops
# msi_time_ts2str
DESTINATION
/usr/lib/irods/plugins/microservices)
# Packaging {{{
# Make sure your umask is set correctly when packaging:
# The default umask on CentOS 7 is 0002, which results in e.g. rwxrwxr-x
# directories within generated RPMs, which will conflict with existing
# directories from irods packages, which will be rwxr-xr-x.
# To create packages on CentOS 7, set your umask to 0022 first (`umask 0022`).
set(CPACK_MONOLITHIC_INSTALL 1)
set(CPACK_CMAKE_GENERATOR "Unix Makefiles")
# Run custom CMake module to detect OS family
include(/microservices/CMakeModules/DetectOS.cmake)
message(STATUS "Found Linux distro ${DETECTED_OS}")
# Determine which type of package should be generated
if(DETECTED_OS MATCHES "^(Ubuntu|Debian)$")
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_VERSION "${IRODS_VERSION}-${MSI_RELEASE_VERSION}")
elseif(DETECTED_OS MATCHES "^(CentOS|RedHatCompatible)$")
set(CPACK_GENERATOR "RPM")
set(CPACK_PACKAGE_VERSION "${IRODS_VERSION}_${MSI_RELEASE_VERSION}")
endif()
message(STATUS "Using CPACK generator ${CPACK_GENERATOR}")
set(CPACK_PACKAGE_NAME "rit-irods-microservices")
set(CPACK_PACKAGE_VENDOR "DataHub Maastricht University <[email protected]>")
set(CPACK_PACKAGE_CONTACT "DataHub Maastricht University <[email protected]>")
#set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/packaging/description.txt")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "iRODS microservices for the RIT project")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RPM_PACKAGE_RELEASE "1")
set(CPACK_RPM_PACKAGE_LICENSE "LGPLv3")
set(CPACK_RPM_PACKAGE_REQUIRES "irods-server = ${IRODS_VERSION}, irods-runtime = ${IRODS_VERSION}, libcurl >= 7.29.0, libxml2 >= 2.9.1, irods-externals-jansson2.7-0 >= 1.0")
set(CPACK_RPM_PACKAGE_CONFLICTS "irods-uu-microservices")
set(CPACK_RPM_PACKAGE_URL "https://github.com/MaastrichtUniversity/rit-irods-microservices")
set(CPACK_RPM_PACKAGE_AUTOREQ 0)
set(CPACK_RPM_PACKAGE_AUTOPROV 0)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "irods-server (= ${IRODS_VERSION}), irods-runtime (= ${IRODS_VERSION}), libcurl3 (>= 7.29.0), libxml2 (>= 2.9.1), irods-externals-jansson2.7-0")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/MaastrichtUniversity/rit-irods-microservices")
set(CPACK_DEBIAN_PACKAGE_SECTION "contrib/science")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_RPM_PACKAGE_RELEASE}")
include(CPack)
add_custom_target(rit-package
COMMAND ${CMAKE_CPACK_COMMAND}
COMMAND mkdir -p /microservices/packages/
# TODO: This is not very pretty. I couldn't find a way to get the resulting deb or rpm name in reliable way
COMMAND mv ${CMAKE_CURRENT_BINARY_DIR}/rit-irods-microservices* /microservices/packages/.
)
# }}}