This repository has been archived by the owner on Dec 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
208 lines (185 loc) · 8.06 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
cmake_minimum_required(VERSION 2.8.6)
project(kineticio CXX C)
execute_process(
COMMAND git log --oneline
COMMAND wc -l
COMMAND tr -d [:space:]
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMITS
)
set(PROJECT_VERSION_MAJOR 2)
set(PROJECT_VERSION_MINOR 0)
set(PROJECT_VERSION_PATCH ${GIT_COMMITS})
set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
add_definitions(-DKIO_VERSION="${PROJECT_VERSION}")
message(STATUS "Project version set to ${PROJECT_VERSION}")
################################################################################
# Options
option(BUILD_TEST "Build test executables." off)
option(CPACK_HEADER_ONLY "make package builds a headers-only rpm instead of the full package." off)
message(STATUS "Set Options: BUILD_TEST=${BUILD_TEST} CPACK_HEADER_ONLY=${CPACK_HEADER_ONLY}")
################################################################################
# Check for Gcc >=4.4
if (CMAKE_COMPILER_IS_GNUCXX)
exec_program(
${CMAKE_CXX_COMPILER}
ARGS --version
OUTPUT_VARIABLE _compiler_output)
string(REGEX REPLACE ".* ([0-9]\\.[0-9]\\.[0-9]) .*" "\\1"
gcc_compiler_version ${_compiler_output})
message(STATUS "C++ compiler version: ${gcc_compiler_version} [${CMAKE_CXX_COMPILER}]")
if (gcc_compiler_version MATCHES "4\\.[0-3]\\.[0-9]")
message(FATAL_ERROR "Error: you need atleast gcc 4.4.x to compile kineticio")
endif (gcc_compiler_version MATCHES "4\\.[0-3]\\.[0-9]")
endif (CMAKE_COMPILER_IS_GNUCXX)
################################################################################
# Set CXX flags and preprocessor definitions
set(CMAKE_CXX_FLAGS "--std=c++0x -pthread -g -Wall -Wextra -Wno-unused-function -Wno-unused-parameter")
if(NOT APPLE) # don't error on warning for OSX
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif()
add_definitions(-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64)
################################################################################
# Dependencies
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
find_package(jsonc REQUIRED)
find_package(uuid REQUIRED)
find_package(kinetic-c++ REQUIRED)
find_package(isal REQUIRED)
find_package(Git REQUIRED)
find_package(Threads REQUIRED)
################################################################################
# Compile main project
include_directories(
include/kio
include
${KINETIC-C++_INCLUDE_DIRS}
${JSONC_INCLUDE_DIRS}
${UUID_INCLUDE_DIRS}
${ISAL_INCLUDE_DIRS}
)
set(kineticio_SRC
src/FileIo.cc
src/KineticIoFactory.cc
src/DataBlock.cc
src/DataCache.cc
src/ClusterMap.cc
src/KineticIoSingleton.cc
src/KineticAutoConnection.cc
src/KineticClusterOperation.cc
src/KineticClusterStripeOperation.cc
src/KineticCallbacks.cc
src/KineticCluster.cc
src/KineticAdminCluster.cc
src/SocketListener.cc
src/RedundancyProvider.cc
src/PrefetchOracle.cc
src/BackgroundOperationHandler.cc
src/Utility.cc
src/outside/crc32c.c
src/outside/MurmurHash3.cpp
)
set(kineticio_LIB
${JSONC_LIBRARIES}
${UUID_LIBRARIES}
${ISAL_LIBRARIES}
${KINETIC-C++_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
add_library(kineticio SHARED ${kineticio_SRC})
target_link_libraries(kineticio ${kineticio_LIB})
# set lib or lib64 as installation directory depending on architecture
get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
set(LIBSUFFIX "")
if ("${LIB64}" STREQUAL "TRUE" AND "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
set(LIBSUFFIX 64)
endif ()
message(STATUS "Library installation directory is set to ${CMAKE_INSTALL_PREFIX}/lib${LIBSUFFIX}")
# set library versioning
set_target_properties(kineticio PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
################################################################################
# Compile cluster admin tool
add_executable(kineticio-admin ${kineticio_SRC} tools/admin.cc)
target_link_libraries(kineticio-admin ${kineticio_LIB} ${CMAKE_THREAD_LIBS_INIT})
################################################################################
# make install targets
install(TARGETS kineticio LIBRARY DESTINATION lib${LIBSUFFIX} COMPONENT library)
install(DIRECTORY ${kineticio_SOURCE_DIR}/include/kio DESTINATION include COMPONENT devel)
install(TARGETS kineticio-admin RUNTIME DESTINATION bin COMPONENT tools)
################################################################################
# Compile test & test dependencies if requested
if (BUILD_TEST)
include(ExternalProject)
find_package(z REQUIRED)
add_custom_command(OUTPUT ivy.jar
COMMAND wget -q https://repo.maven.apache.org/maven2/org/apache/ivy/ivy/2.4.0/ivy-2.4.0.jar -O ivy.jar
COMMAND java -jar ivy.jar -error -dependency com.seagate.kinetic kinetic-all 0.8.0.5 -retrieve 'simulator/[artifact]-[revision] (-[classifier]) .[ext]'
COMMENT "Downloading simulator"
)
add_custom_target(kinetic-simulator DEPENDS ivy.jar)
add_definitions(-DTESTJSON_LOCATION="${kineticio_SOURCE_DIR}/test/localhost.json")
add_definitions(-DTESTSIMULATOR_LOCATION="${kineticio_BINARY_DIR}/simulator")
ExternalProject_add(catch
PREFIX catch
DOWNLOAD_COMMAND wget -q https://raw.githubusercontent.com/philsquared/Catch/master/single_include/catch.hpp -O catch.hpp
CONFIGURE_COMMAND ""
BUILD_IN_SOURCE 1
BUILD_COMMAND ""
INSTALL_COMMAND ""
)
include_directories(${Z_INCLUDE_DIRS})
include_directories(${kineticio_BINARY_DIR}/catch/src)
add_executable(kio-test
${kineticio_SRC}
test/TestMain.cc
test/DataBlockTest.cc
test/FileIoTest.cc
test/ClusterMapTest.cc
test/KineticClusterTest.cc
test/SocketListenerTest.cc
test/RedundancyProviderTest.cc
test/UtilityTest.cc
test/PrefetchOracleTest.cc
test/SimulatorController.cc
test/LoggingTest.cc
test/KineticAdminClusterTest.cc
test/DataCacheTest.cc
test/KineticAutoConnectionTest.cc
test/ConcurrencyTest.cc
test/ConcurrencyAppendTest.cc
)
target_link_libraries(kio-test
${Z_LIBRARIES}
${kineticio_LIB}
)
add_dependencies(kio-test catch kinetic-simulator)
add_executable(kio-test-dynamic-load test/DynamicLibraryLoadingTest.cc)
target_link_libraries(kio-test-dynamic-load ${CMAKE_DL_LIBS})
add_dependencies(kio-test-dynamic-load catch)
add_executable(replay ${kineticio_SRC} test/replay.cc)
target_link_libraries(replay ${kineticio_LIB})
endif (BUILD_TEST)
################################################################################
# RPM generation rules
set(CPACK_PACKAGE_NAME ${CMAKE_PROJECT_NAME})
set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
set(CPACK_RPM_PACKAGE_LICENSE "Mozilla Public License, v. 2.0")
set(CPACK_PACKAGE_CONTACT "paul.lensing@gmail.com")
if(CPACK_HEADER_ONLY)
set(CPACK_GENERATOR TGZ RPM)
set(CPACK_RPM_COMPONENT_INSTALL ON)
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
set(CPACK_COMPONENTS_ALL devel)
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "kineticio library headers")
set(CPACK_RPM_PACKAGE_DESCRIPTION "C++ header files for kineticio library.")
else()
set(CPACK_GENERATOR RPM)
set(CPACK_RPM_COMPONENT_INSTALL OFF)
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "kineticio library")
set(CPACK_RPM_PACKAGE_DESCRIPTION "A byte-range IO library for a kinetic backend.")
set(CPACK_RPM_PACKAGE_REQUIRES "isal, kinetic_cpp_client >= 0.2.0, json-c, libuuid")
endif(CPACK_HEADER_ONLY)
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
include(CPack)