-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
268 lines (191 loc) · 8.19 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
# Jetstream Build Script
#
# http://www.cmake.org/cmake/help/cmake_tutorial.html
cmake_minimum_required (VERSION 2.4)
cmake_policy(SET CMP0003 NEW)
# Add Compiler Definitions. Must be done before project or language set.
option(USE_CLANG "build application with clang" ON)
option(FULL_STATIC "build application maximally statically" OFF)
if(USE_CLANG)
SET (CMAKE_C_COMPILER "/usr/bin/clang")
SET (CMAKE_CXX_COMPILER "/usr/bin/clang++")
# SET (CMAKE_AR "/usr/bin/llvm-ar")
# SET (CMAKE_LINKER "/usr/bin/llvm-ld")
# SET (CMAKE_NM "/usr/bin/llvm-nm")
# SET (CMAKE_OBJDUMP "/usr/bin/llvm-objdump")
# SET (CMAKE_RANLIB "/usr/bin/llvm-ranlib")
else (USE_CLANG)
SET (CMAKE_C_COMPILER "/usr/bin/gcc")
SET (CMAKE_CXX_COMPILER "/usr/bin/g++")
endif(USE_CLANG)
message (STATUS "Compiler is ${CMAKE_CXX_COMPILER}")
set (CMAKE_VERBOSE_MAKEFILE ON)
if (FULL_STATIC)
set (BUILD_SHARED_LIBS OFF)
message (STATUS "library suffixes were ${CMAKE_FIND_LIBRARY_SUFFIXES} now .a;.so")
set(CMAKE_FIND_LIBRARY_SUFFIXES .a;.so)
set(Boost_USE_STATIC_LIBS ON)
else (FULL_STATIC)
set (BUILD_SHARED_LIBS ON)
set(Boost_USE_STATIC_LIBS OFF)
endif (FULL_STATIC)
SET (CMAKE_C_COMMON "-std=c99 -DNO_SSL")
SET (CMAKE_C_FLAGS "-Wall -Werror ${CMAKE_C_COMMON}")
SET (CMAKE_C_FLAGS_DEBUG "-g -O0 ${CMAKE_C_COMMON}")
SET (CMAKE_C_FLAGS_RELEASE "-O4 -DNDEBUG ${CMAKE_C_COMMON}")
SET (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g ${CMAKE_C_COMMON}")
SET (CMAKE_CXX_COMMON "-DNO_SSL -fPIC -DGTEST_HAS_TR1_TUPLE=0 -pthread")
SET (CMAKE_CXX_FLAGS "-Wall ${CMAKE_CXX_COMMON}")
# -std=c++11 -DBOOST_NO_CXX11_RVALUE_REFERENCES
# -D BOOST_NO_CXX11_NUMERIC_LIMITS=1 -DBOOST_NO_CXX11_RVALUE_REFERENCES
SET (CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Werror ${CMAKE_CXX_COMMON}")
SET (CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG ${CMAKE_CXX_COMMON}")
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g ${CMAKE_CXX_COMMON}")
# NOTE: can't use -Werror in release mode since it means asserts don't count as
# variable uses, and that results in spurious warnings/errors.
add_definitions (${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG})
set (TOP_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set (SRC_DIR ${TOP_DIR}/src)
set (BUILD_DIR ${TOP_DIR}/src)
set (TESTLIB "js_tests") #name for the library containing our unit tests
#######################################################
# Project flags
project (jetstream)
if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem ")
endif()
set (JETSTREAM_VERSION_MAJOR "0" CACHE STRING "Jetstream's major version" FORCE)
set (JETSTREAM_VERSION_MINOR "0" CACHE STRING "Jetstream's minor version" FORCE)
set (JETSTREAM_VERSION_REVISION "1" CACHE STRING "Jetstream's revision version" FORCE)
set (JETSTREAM_VERSION "${JETSTREAM_VERSION_MAJOR}.${JETSTREAM_VERSION_MINOR}.${JETSTREAM_VERSION_REVISION}" CACHE STRING "Jetstream's complete version" FORCE)
# Generate a configuration file with these settings
configure_file (${SRC_DIR}/utils/js_version.h.in ${SRC_DIR}/utils/js_version.h)
#######################################################
# Finding libraries
# Requires Boost
find_package (Boost 1.50 REQUIRED COMPONENTS system thread chrono regex program_options filesystem REQUIRED)
if (APPLE)
set (Boost_USE_STATIC_LIBS ON)
set (Boost_USE_MULTITHREADED ON)
endif ()
include_directories (SYSTEM ${Boost_INCLUDE_DIRS})
#message ("after adding boost, includes were ${INCLUDE_DIRECTORIES}")
#hack because something messes up the suffixes
if (FULL_STATIC)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a;.so)
endif (FULL_STATIC)
# Require ProtoBufs
include (FindProtobuf)
find_package (Protobuf REQUIRED)
include_directories (SYSTEM ${PROTOBUF_INCLUDE_DIR})
# Require Google Test
include (FindGTest)
find_package (GTest REQUIRED)
include_directories (SYSTEM ${GTEST_INCLUDE_DIR})
# Google's glog logger
find_library(GLOG_LIB glog) #glog has no dependencies and so this is safe. --ASR
# SQL connectors
include_directories (/opt/local/include/mysql5-connector-cpp/driver /opt/local/include/mysql5-connector-cpp)
### Build Masstree
#
if(OMIT_MASSTREE)
message (STATUS "omitting masstree")
SET (CMAKE_CXX_FLAGS "-DNO_MASSTREE")
else(OMIT_MASSTREE)
add_custom_target(masstree
COMMENT "Building Masstree"
COMMAND make libmtree.a
COMMAND cp ${TOP_DIR}/masstree_source/libmtree.a ${SRC_DIR}/utils/
DEPENDS ${TOP_DIR}/masstree_source/*.cc ${TOP_DIR}/masstree_source/*.hh ${TOP_DIR}/masstree_source/*.h ${TOP_DIR}/masstree_source/*.c
WORKING_DIRECTORY ${TOP_DIR}/masstree_source)
include_directories (${TOP_DIR}/masstree_source)
endif()
#######################################################
# Set library locations and sources
set (LIBRARY_NAME jsproto)
add_subdirectory (${SRC_DIR}/proto)
link_directories (${BUILD_DIR}/proto)
set (LIBRARIES ${LIBRARIES} ${LIBRARY_NAME})
include_directories (SYSTEM ${SRC_DIR}/proto/cpp)
set (LIBRARY_NAME jsutils)
add_subdirectory (${SRC_DIR}/utils)
link_directories (${BUILD_DIR}/utils)
if(NOT OMIT_MASSTREE)
add_dependencies (${LIBRARY_NAME} ${SRC_DIR}/utils/libmtree.a)
endif()
set (LIBRARIES ${LIBRARIES} ${LIBRARY_NAME})
include_directories (${SRC_DIR}/utils)
set (LIBRARY_NAME jsaggregates)
add_subdirectory (${SRC_DIR}/aggregates)
link_directories (${BUILD_DIR}/aggregates)
set (LIBRARIES ${LIBRARIES} ${LIBRARY_NAME})
include_directories (${SRC_DIR}/aggregates)
set (LIBRARY_NAME jsmysqludfs)
add_subdirectory (${SRC_DIR}/mysql_udfs)
#mysql udfs should not be used by other code
#link_directories (${BUILD_DIR}/mysql_udfs)
#set (LIBRARIES ${LIBRARIES} ${LIBRARY_NAME})
#include_directories (${SRC_DIR}/aggregates)
set (LIBRARY_NAME jscomm)
add_subdirectory (${SRC_DIR}/comm)
link_directories (${BUILD_DIR}/comm)
set (LIBRARIES ${LIBRARIES} ${LIBRARY_NAME})
include_directories (${SRC_DIR}/comm)
add_subdirectory (${SRC_DIR}/mongoose)
link_directories (${BUILD_DIR}/mongoose)
set (LIBRARIES ${LIBRARIES} mongoose)
include_directories (${SRC_DIR}/mongoose)
# Dependencies are tricky, because protobuf .h files autogenerated, so we need
# to make sure it's built before other libraries which include it
include_directories (${SRC_DIR}/cube ${SRC_DIR}/dataplane)
set (LIBRARY_NAME jscube)
add_subdirectory (${SRC_DIR}/cube)
link_directories (${BUILD_DIR}/cube)
set (LIBRARIES ${LIBRARIES} ${LIBRARY_NAME})
include_directories (${SRC_DIR}/cube/mysql)
if(OMIT_MASSTREE)
else()
include_directories (${SRC_DIR}/cube/masstree)
add_dependencies (${LIBRARY_NAME} masstree)
endif()
set (LIBRARY_NAME jsdataplane)
add_subdirectory (${SRC_DIR}/dataplane)
add_dependencies (${LIBRARY_NAME} jsproto)
link_directories (${BUILD_DIR}/dataplane)
set (LIBRARIES ${LIBRARIES} ${LIBRARY_NAME})
#add_subdirectory (${SRC_DIR}/cube)
#######################################################
# Use CLang by default
#######################################################
# Build executables
set (LIBRARIES ${LIBRARIES}
${Boost_LIBRARIES}
${PROTOBUF_LIBRARY}
${GTEST_LIBRARY}
${GLOG_LIB}
"pthread"
)
message (STATUS "Linking libraries ${LIBRARIES}")
##### The worker process, jsnoded
set (JSNODED jsnoded)
add_executable (${JSNODED} ${SRC_DIR}/dataplane/node_daemon.cc)
target_link_libraries (${JSNODED} ${CMAKE_DL_LIBS})
add_dependencies (${JSNODED} jsproto) #A js-specific entry to add our protobuf generated code
target_link_libraries (${JSNODED} ${LIBRARIES})
###################################################
# Build the unit tests
file (GLOB_RECURSE TESTS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "src/test_*.cc")
set (TESTS ${SRC_DIR}/js_unit_tests.cc ${TESTS})
if(CMAKE_BUILD_TYPE MATCHES RELWITHDEBINFO)
add_executable (js_unit_tests EXCLUDE_FROM_ALL ${TESTS})
else(CMAKE_BUILD_TYPE MATCHES RELWITHDEBINFO)
add_executable (js_unit_tests ${TESTS})
endif(CMAKE_BUILD_TYPE MATCHES RELWITHDEBINFO)
target_link_libraries (js_unit_tests ${CMAKE_DL_LIBS})
target_link_libraries (js_unit_tests ${LIBRARIES})
target_link_libraries (js_unit_tests ${LIBRARY_NAME}) #the js node library
file (GLOB_RECURSE OPS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "src/*_operator.cc")
foreach(OP ${OPS})
get_filename_component(OP_NAME ${OP} NAME_WE)
target_link_libraries (js_unit_tests ${OP_NAME})
endforeach(OP)