-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
219 lines (183 loc) · 5.71 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
# CMakeLists files in this project can
# refer to the root source directory of the project as ${HXHIM_SOURCE_DIR} and
# to the root binary directory of the project as ${HXHIM_BINARY_DIR}.
cmake_minimum_required (VERSION 3.6.3)
project (HXHIM LANGUAGES C CXX)
#
# Enable C++11
#
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
#
# Enable extra compiler flags
#
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -fmax-errors=1 -O0 -g3 -DDEBUG") # -D_GLIBCXX_DEBUG
#
# linker flags used internally
#
set(EXEC_LDFLAGS)
#
# pkg-config flags
#
set(PC_CFLAGS)
set(PC_LIBS) # flags required no matter which hxhim library is being linked against
set(PC_STATIC_LIBS) # normally linked to by shared library, so only used when linking with libhxhim.a
#
# Include CMake modules
#
find_package(PkgConfig REQUIRED)
#
# Need pthread
#
find_package(Threads REQUIRED)
#
# List of common linker flags
#
list(APPEND EXEC_LDFLAGS Threads::Threads m)
list(APPEND PC_LIBS -lstdc++)
list(APPEND PC_STATIC_LIBS ${CMAKE_THREAD_LIBS_INIT} -lm)
#
# External projects
#
find_package(MPI REQUIRED)
if (CMAKE_SYSTEM_NAME STREQUAL "CrayLinuxEnvironment")
set(MPI_C_COMPILE_FLAGS "${MPI_C_COMPILE_FLAGS} -dynamic -craympich-mt")
set(MPI_CXX_COMPILE_FLAGS "${MPI_CXX_COMPILE_FLAGS} -dynamic -craympich-mt")
endif()
message(STATUS "MPI_CXX_INCLUDE_DIRS=" ${MPI_CXX_INCLUDE_DIRS})
message(STATUS "MPI_CXX_LIBRARIES=" ${MPI_CXX_LIBRARIES})
message(STATUS "MPI_CXX_LINK_FLAGS=" ${MPI_CXX_LINK_FLAGS})
include_directories(SYSTEM ${MPI_CXX_INCLUDE_DIRS})
list(APPEND EXEC_LDFLAGS ${MPI_CXX_LIBRARIES})
foreach(INCLUDE_DIR ${MPI_CXX_INCLUDE_DIRS})
list(APPEND PC_CFLAGS "-I${INCLUDE_DIR}")
endforeach()
list(APPEND PC_LIBS ${MPI_CXX_LIBRARIES})
list(APPEND PC_STATIC_LIBS ${MPI_CXX_LIBRARIES})
# jemalloc is nice to have but not necessary
pkg_search_module(JEMALLOC jemalloc)
if (JEMALLOC_FOUND)
option(ENABLE_JEMALLOC "Use jemalloc if found" On)
if (ENABLE_JEMALLOC)
message(STATUS "JEMALLOC_INCLUDEDIR=" ${JEMALLOC_INCLUDEDIR})
message(STATUS "JEMALLOC_LIBDIR=" ${JEMALLOC_LIBDIR})
list(APPEND EXEC_LDFLAGS ${JEMALLOC_LDFLAGS})
list(APPEND PC_STATIC_LIBS ${JEMALLOC_LDFLAGS})
else()
message(STATUS "jemalloc found but not used")
endif()
else()
message(STATUS "jemalloc not found")
endif()
# do not search for thallium with find_package
pkg_search_module(THALLIUM thallium)
if (THALLIUM_FOUND)
option(ENABLE_THALLIUM "Use Thallium if found" On)
if (ENABLE_THALLIUM)
# thallium needs C++14
set(CMAKE_CXX_STANDARD 14)
pkg_search_module(MERCURY REQUIRED mercury)
message(STATUS "MERCURY_INCLUDEDIR=" ${MERCURY_INCLUDEDIR})
message(STATUS "MERCURY_LIBDIR=" ${MERCURY_LIBDIR})
pkg_search_module(ARGOBOTS REQUIRED argobots)
message(STATUS "ARGOBOTS_INCLUDEDIR=" ${ARGOBOTS_INCLUDEDIR})
message(STATUS "ARGOBOTS_LIBDIR=" ${ARGOBOTS_LIBDIR})
pkg_search_module(MARGO REQUIRED margo)
message(STATUS "MARGO_INCLUDEDIR=" ${MARGO_INCLUDEDIR})
message(STATUS "MARGO_LIBDIR=" ${MARGO_LIBDIR})
message(STATUS "THALLIUM_INCLUDEDIR=" ${THALLIUM_INCLUDEDIR})
message(STATUS "THALLIUM_LIBDIR=" ${THALLIUM_LIBDIR})
include_directories(AFTER SYSTEM ${THALLIUM_INCLUDE_DIRS})
add_definitions(-DHXHIM_HAVE_THALLIUM=1)
list(APPEND EXEC_LDFLAGS ${THALLIUM_STATIC_LDFLAGS})
list(APPEND PC_CFLAGS -DHXHIM_HAVE_THALLIUM=1)
list(APPEND PC_LIBS ${THALLIUM_STATIC_LDFLAGS})
else ()
message(STATUS "Thallium found but not used")
endif()
else()
message(STATUS "Thallium not found")
endif()
#
# LevelDB Support
#
pkg_search_module(LEVELDB leveldb)
if(LEVELDB_FOUND)
option(ENABLE_LEVELDB "Use LevelDB if found" On)
if (ENABLE_LEVELDB)
message(STATUS "LevelDB Data Storage Module Enabled")
message(STATUS "LEVELDB_INCLUDEDIR=" ${LEVELDB_INCLUDEDIR})
message(STATUS "LEVELDB_LIBDIR=" ${LEVELDB_LIBDIR})
include_directories(AFTER SYSTEM ${LEVELDB_INCLUDE_DIRS})
add_definitions(-DHXHIM_HAVE_LEVELDB=1)
list(APPEND EXEC_LDFLAGS ${LEVELDB_LDFLAGS})
list(APPEND PC_CFLAGS -DHXHIM_HAVE_LEVELDB=1)
list(APPEND PC_LIBS ${LEVELDB_LDFLAGS})
option(DBBENCH "Build dbbench for hxhim" Off)
else()
message(STATUS "LevelDB found but not used")
endif()
else()
message(STATUS "LevelDB not found")
endif()
#
# RocksDB Support
#
pkg_search_module(ROCKSDB rocksdb)
if(ROCKSDB_FOUND)
option(ENABLE_ROCKSDB "Use RocksDB if found" On)
if (ENABLE_ROCKSDB)
message(STATUS "RocksDB Data Storage Module Enabled")
message(STATUS "ROCKSDB_INCLUDEDIR=" ${ROCKSDB_INCLUDEDIR})
message(STATUS "ROCKSDB_INCLUDE_DIRS=" ${ROCKSDB_INCLUDE_DIRS})
message(STATUS "ROCKSDB_LIBDIR=" ${ROCKSDB_LIBDIR})
include_directories(AFTER SYSTEM ${ROCKSDB_INCLUDE_DIRS})
add_definitions(-DHXHIM_HAVE_ROCKSDB=1)
list(APPEND EXEC_LDFLAGS ${ROCKSDB_LDFLAGS})
list(APPEND PC_CFLAGS -DHXHIM_HAVE_ROCKSDB=1)
list(APPEND PC_LIBS ${ROCKSDB_LDFLAGS})
else()
message(STATUS "RocksDB found but not used")
endif()
else()
message(STATUS "RocksDB not found")
endif()
# always look for HDF5
find_package(HDF5)
if (HDF5_FOUND)
option(ENABLE_HDF5 "Use HDF5 if found" On)
if (ENABLE_HDF5)
message(STATUS "HDF5_INCLUDE_DIRS=" ${HDF5_INCLUDE_DIRS})
message(STATUS "HDF5_LIBRARIES=" ${HDF5_LIBRARIES})
else()
message(STATUS "HDF5 found but not used")
endif()
else()
message(STATUS "HDF5 not found")
endif()
#
# build library
#
add_subdirectory(src)
#
# Install headers and libraries
#
add_subdirectory(include)
#
# Add configuration files
#
add_subdirectory(config)
#
# Add extra files
#
add_subdirectory(contrib)
#
# Add unit test executable
#
enable_testing()
add_subdirectory(test)
#
# Add example executables
#
add_subdirectory(examples)