-
Notifications
You must be signed in to change notification settings - Fork 19
/
CMakeLists.txt
218 lines (176 loc) · 5.34 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
cmake_minimum_required (VERSION 3.0.0)
project(zipkin-cpp
VERSION 0.3.1
LANGUAGES C CXX)
include(CTest)
enable_testing()
set (CMAKE_C_STANDARD 99)
set (CMAKE_C_STANDARD_REQUIRED ON)
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_EXTENSIONS OFF)
set (CMAKE_COLOR_MAKEFILE ON)
if (APPLE)
set (CMAKE_MACOSX_RPATH ON)
endif ()
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "Default build type 'Release with debug info'")
set(CMAKE_BUILD_TYPE RELWITHDEBINFO CACHE STRING "" FORCE )
else()
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
endif()
if(CMAKE_BUILD_TYPE MATCHES RELEASE|RELWITHDEBINFO)
set(RELEASE_BUILD TRUE)
else()
set(RELEASE_BUILD FALSE)
endif()
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost REQUIRED COMPONENTS regex system thread)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
endif()
find_package(Threads REQUIRED)
find_package(OpenSSL REQUIRED)
find_package(ZLIB)
find_package(Thrift)
find_package(LibRDKafka)
find_package(Folly)
find_package(RapidJSON)
find_package(DoubleConversion)
find_package(GFlags)
find_package(GLog)
find_package(GMock)
find_package(GBench)
find_package(CURL)
find_package(Protobuf)
find_package(GRPC)
find_package(Gperftools)
find_package(Doxygen)
if (OPENSSL_FOUND)
list(GET OPENSSL_LIBRARIES 0 openssl_libname)
get_filename_component(OPENSSL_LIBRARY_DIR ${openssl_libname} DIRECTORY)
get_filename_component(OPENSSL_ROOT_DIR ${OPENSSL_LIBRARY_DIR} DIRECTORY)
if (APPLE)
set (WITH_OPENSSL "--with-openssl=${OPENSSL_ROOT_DIR}")
endif ()
message(STATUS "Found OpenSSL ${OPENSSL_VERSION}, inc=${OPENSSL_INCLUDE_DIR}, libs=${OPENSSL_LIBRARIES} root=${OPENSSL_ROOT_DIR}")
endif ()
include(InstallExternalProjects)
if (CURL_FOUND AND ZLIB_FOUND)
set (WITH_CURL ON)
else ()
set (WITH_CURL OFF)
endif ()
if (GRPC_FOUND)
set (WITH_GRPC ON)
else ()
set (WITH_GRPC OFF)
endif ()
# gperftools - Google Performance Tool
#
# https://github.com/gperftools/gperftools
if (GPERFTOOLS_FOUND)
set (WITH_TCMALLOC ON)
if (RELEASE_BUILD)
set (WITH_PROFILER OFF)
else ()
set (WITH_PROFILER ON)
endif ()
else ()
set (WITH_TCMALLOC OFF)
set (WITH_PROFILER OFF)
endif ()
if (DOXYGEN_FOUND AND RELEASE_BUILD)
set (BUILD_DOCS ON)
else ()
set (BUILD_DOCS OFF)
endif ()
option (WITH_CURL "Build with cURL propagation" WITH_CURL)
option (WITH_GRPC "Build with gRPC propagation" WITH_GRPC)
option (WITH_FPIC "Build with -fPIC for shared library" OFF)
option (WITH_TCMALLOC "Build with tcmalloc library" WITH_TCMALLOC)
option (WITH_PROFILER "Build with CPU profiler" WITH_PROFILER)
option (SHARED_LIB "Build shared library" OFF)
option (BUILD_DOCS "Build API documentation (requires Doxygen)" BUILD_DOCS)
if (RELEASE_BUILD)
add_compile_options(-O2)
else()
add_compile_options(-g)
endif()
if (WITH_FPIC)
message(STATUS "Build with -fPIC")
add_compile_options(-fPIC)
endif()
set (INCDIR "${PROJECT_SOURCE_DIR}/include")
set (BINDIR "${PROJECT_BINARY_DIR}/bin")
set (LIBDIR "${PROJECT_BINARY_DIR}/lib")
set (GENDIR "${PROJECT_BINARY_DIR}/gen-cpp")
if(CMAKE_GENERATOR STREQUAL Xcode)
set(XCODE TRUE)
endif()
include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_BINARY_DIR}/gen-cpp)
include_directories(${PROJECT_BINARY_DIR}/src)
include_directories(SYSTEM include)
set (zipkin_DEPENDENCIES
${GLOG_LIBRARY}
${GFLAGS_LIBRARIES}
${THRIFT_LIBRARIES}
${LibRDKafka_LIBRARIES}
${ZLIB_LIBRARIES}
${OPENSSL_LIBRARIES}
${FOLLY_STATIC_LIBRARY}
${DOUBLE_CONVERSION_LIBRARY}
${Boost_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
if (WITH_CURL)
if (NOT CURL_FOUND)
message(SEND_ERROR "cURL not found")
endif()
if (NOT ZLIB_FOUND)
message(SEND_ERROR "zlib not found")
endif()
message(STATUS "Build with cURL propagation")
list (APPEND zipkin_DEPENDENCIES ${CURL_LIBRARIES})
set (CURL_ENABLED 1)
else()
message(STATUS "cURL supports disabled")
endif()
if (WITH_GRPC)
if (NOT GRPC_FOUND)
message(SEND_ERROR "gRPC not found")
endif()
message(STATUS "Build with gRPC propagation")
list(APPEND zipkin_DEPENDENCIES ${GRPC_LIBRARIES})
set (GRPC_ENABLED 1)
else()
message(STATUS "gRPC supports disabled")
endif()
if (WITH_TCMALLOC OR WITH_PROFILER)
if (NOT GPERFTOOLS_FOUND)
message(SEND_ERROR "gperftools not found")
endif()
if (WITH_TCMALLOC)
add_compile_options(-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free)
endif ()
if (WITH_TCMALLOC AND WITH_PROFILER)
message(STATUS "Build with tcmalloc and profiler library")
list(APPEND zipkin_DEPENDENCIES ${GPERFTOOLS_LIBRARIES})
elseif (WITH_TCMALLOC)
message(STATUS "Build with tcmalloc library")
list(APPEND zipkin_DEPENDENCIES ${GPERFTOOLS_TCMALLOC})
elseif (WITH_PROFILER)
message(STATUS "Build with profiler library")
list(APPEND zipkin_DEPENDENCIES ${GPERFTOOLS_PROFILER})
endif ()
endif ()
message (STATUS "Link with ${zipkin_DEPENDENCIES}")
add_subdirectory(docs)
add_subdirectory(src)
add_subdirectory(test)
add_subdirectory(bench)
add_subdirectory(examples)