1
- cmake_minimum_required (VERSION 2.8.12 )
1
+ cmake_minimum_required (VERSION 3.0.0 )
2
2
3
- project (zipkin C CXX)
3
+ project (zipkin-cpp
4
+ VERSION 0.3.0
5
+ LANGUAGES C CXX)
4
6
5
- set (zipkin_VERSION_MAJOR 0)
6
- set (zipkin_VERSION_MINOR 2)
7
- set (zipkin_VERSION_PATCH 0)
8
- set (zipkin_VERSION ${zipkin_VERSION_MAJOR} .${zipkin_VERSION_MINOR} .${zipkin_VERSION_PATCH} )
7
+ include (CTest)
8
+ enable_testing ()
9
+
10
+ set (CMAKE_C_STANDARD 99)
11
+ set (CMAKE_C_STANDARD_REQUIRED ON )
12
+ set (CMAKE_CXX_STANDARD 11)
13
+ set (CMAKE_CXX_STANDARD_REQUIRED ON )
14
+ set (CMAKE_CXX_EXTENSIONS OFF )
15
+ set (CMAKE_COLOR_MAKEFILE ON )
9
16
10
- include (${PROJECT_SOURCE_DIR} /conanbuildinfo.cmake)
11
- conan_basic_setup()
17
+ if (APPLE )
18
+ set (CMAKE_MACOSX_RPATH ON )
19
+ endif ()
12
20
13
21
if (NOT CMAKE_BUILD_TYPE )
14
22
message (STATUS "Default build type 'Release with debug info'" )
@@ -30,29 +38,84 @@ set(Boost_USE_STATIC_LIBS ON) # only find static libs
30
38
set (Boost_USE_MULTITHREADED ON )
31
39
set (Boost_USE_STATIC_RUNTIME OFF )
32
40
33
- find_package (Boost REQUIRED COMPONENTS regex system )
41
+ find_package (Boost REQUIRED COMPONENTS regex system thread )
34
42
if (Boost_FOUND)
35
43
include_directories (${Boost_INCLUDE_DIRS} )
36
44
endif ()
37
45
38
- find_package (Thrift REQUIRED)
39
- find_package (LibRDKafka REQUIRED)
40
- find_package (Doxygen QUIET )
46
+ find_package (Threads REQUIRED)
47
+ find_package (OpenSSL REQUIRED)
48
+ find_package (ZLIB)
49
+ find_package (Thrift)
50
+ find_package (LibRDKafka)
51
+ find_package (Folly)
52
+ find_package (RapidJSON)
53
+ find_package (DoubleConversion)
54
+ find_package (GFlags)
55
+ find_package (GLog)
56
+ find_package (GTest)
57
+ find_package (GBench)
58
+ find_package (CURL)
59
+ find_package (Protobuf)
60
+ find_package (GRPC)
61
+ find_package (Gperftools)
62
+ find_package (Doxygen)
63
+
64
+ if (OPENSSL_FOUND)
65
+ list (GET OPENSSL_LIBRARIES 0 openssl_libname)
66
+ get_filename_component (OPENSSL_LIBRARY_DIR ${openssl_libname} DIRECTORY )
67
+ get_filename_component (OPENSSL_ROOT_DIR ${OPENSSL_LIBRARY_DIR} DIRECTORY )
68
+
69
+ if (APPLE )
70
+ set (WITH_OPENSSL "--with-openssl=${OPENSSL_ROOT_DIR} " )
71
+ endif ()
72
+
73
+ message (STATUS "Found OpenSSL ${OPENSSL_VERSION} , inc=${OPENSSL_INCLUDE_DIR} , libs=${OPENSSL_LIBRARIES} root=${OPENSSL_ROOT_DIR} " )
74
+ endif ()
75
+
76
+ include (InstallExternalProjects)
77
+
78
+ if (CURL_FOUND AND ZLIB_FOUND)
79
+ set (WITH_CURL ON )
80
+ else ()
81
+ set (WITH_CURL OFF )
82
+ endif ()
83
+
84
+ if (GRPC_FOUND)
85
+ set (WITH_GRPC ON )
86
+ else ()
87
+ set (WITH_GRPC OFF )
88
+ endif ()
41
89
42
- if (${DOXYGEN_FOUND} AND ${RELEASE_BUILD} )
90
+ # gperftools - Google Performance Tool
91
+ #
92
+ # https://github.com/gperftools/gperftools
93
+ if (GPERFTOOLS_FOUND)
94
+ set (WITH_TCMALLOC ON )
95
+ if (RELEASE_BUILD)
96
+ set (WITH_PROFILER OFF )
97
+ else ()
98
+ set (WITH_PROFILER ON )
99
+ endif ()
100
+ else ()
101
+ set (WITH_TCMALLOC OFF )
102
+ set (WITH_PROFILER OFF )
103
+ endif ()
104
+
105
+ if (DOXYGEN_FOUND AND RELEASE_BUILD)
43
106
set (BUILD_DOCS ON )
44
- else ()
107
+ else ()
45
108
set (BUILD_DOCS OFF )
46
- endif ()
109
+ endif ()
47
110
111
+ option (WITH_CURL "Build with cURL propagation" WITH_CURL)
112
+ option (WITH_GRPC "Build with gRPC propagation" WITH_GRPC)
48
113
option (WITH_FPIC "Build with -fPIC for shared library" OFF )
114
+ option (WITH_TCMALLOC "Build with tcmalloc library" WITH_TCMALLOC)
115
+ option (WITH_PROFILER "Build with CPU profiler" WITH_PROFILER)
49
116
option (SHARED_LIB "Build shared library" OFF )
50
117
option (BUILD_DOCS "Build API documentation (requires Doxygen)" BUILD_DOCS)
51
118
52
- if (APPLE )
53
- set (CMAKE_MACOSX_RPATH ON )
54
- endif ()
55
-
56
119
if (RELEASE_BUILD)
57
120
add_compile_options (-O2)
58
121
else ()
@@ -75,21 +138,80 @@ endif()
75
138
76
139
include_directories (${PROJECT_SOURCE_DIR} /src)
77
140
include_directories (${PROJECT_SOURCE_DIR} /include )
78
- include_directories (${PROJECT_SOURCE_DIR } /gen-cpp)
79
- include_directories (${PROJECT_BINARY_DIR} )
141
+ include_directories (${PROJECT_BINARY_DIR } /gen-cpp)
142
+ include_directories (${PROJECT_BINARY_DIR} /src )
80
143
include_directories (SYSTEM include )
81
144
82
- set (zipkin_DEPENDENCIES
83
- ${CONAN_LIBS_GLOG }
84
- ${CONAN_LIBS_GFLAGS }
145
+ set (zipkin_DEPENDENCIES
146
+ ${GLOG_LIBRARY }
147
+ ${GFLAGS_LIBRARIES }
85
148
${THRIFT_LIBRARIES}
86
149
${LibRDKafka_LIBRARIES}
150
+ ${ZLIB_LIBRARIES}
151
+ ${OPENSSL_LIBRARIES}
152
+ ${FOLLY_STATIC_LIBRARY}
153
+ ${DOUBLE_CONVERSION_LIBRARY}
87
154
${Boost_LIBRARIES}
155
+ ${CMAKE_THREAD_LIBS_INIT}
88
156
)
89
157
90
- message (STATUS "Link with ${zipkin_DEPENDENCIES} " )
158
+ if (WITH_CURL)
159
+ if (NOT CURL_FOUND)
160
+ message (SEND_ERROR "cURL not found" )
161
+ endif ()
91
162
92
- enable_testing ()
163
+ if (NOT ZLIB_FOUND)
164
+ message (SEND_ERROR "zlib not found" )
165
+ endif ()
166
+
167
+ message (STATUS "Build with cURL propagation" )
168
+
169
+ list (APPEND zipkin_DEPENDENCIES ${CURL_LIBRARIES} )
170
+
171
+ set (CURL_ENABLED 1)
172
+ else ()
173
+ message (STATUS "cURL supports disabled" )
174
+ endif ()
175
+
176
+ if (WITH_GRPC)
177
+ if (NOT GRPC_FOUND)
178
+ message (SEND_ERROR "gRPC not found" )
179
+ endif ()
180
+
181
+ message (STATUS "Build with gRPC propagation" )
182
+
183
+ list (APPEND zipkin_DEPENDENCIES ${GRPC_LIBRARIES} )
184
+
185
+ set (GRPC_ENABLED 1)
186
+ else ()
187
+ message (STATUS "gRPC supports disabled" )
188
+ endif ()
189
+
190
+ if (WITH_TCMALLOC OR WITH_PROFILER)
191
+ if (NOT GPERFTOOLS_FOUND)
192
+ message (SEND_ERROR "gperftools not found" )
193
+ endif ()
194
+
195
+ if (WITH_TCMALLOC)
196
+ add_compile_options (-fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free)
197
+ endif ()
198
+
199
+ if (WITH_TCMALLOC AND WITH_PROFILER)
200
+ message (STATUS "Build with tcmalloc and profiler library" )
201
+
202
+ list (APPEND zipkin_DEPENDENCIES ${GPERFTOOLS_LIBRARIES} )
203
+ elseif (WITH_TCMALLOC)
204
+ message (STATUS "Build with tcmalloc library" )
205
+
206
+ list (APPEND zipkin_DEPENDENCIES ${GPERFTOOLS_TCMALLOC} )
207
+ elseif (WITH_PROFILER)
208
+ message (STATUS "Build with profiler library" )
209
+
210
+ list (APPEND zipkin_DEPENDENCIES ${GPERFTOOLS_PROFILER} )
211
+ endif ()
212
+ endif ()
213
+
214
+ message (STATUS "Link with ${zipkin_DEPENDENCIES} " )
93
215
94
216
add_subdirectory (docs)
95
217
add_subdirectory (src)
0 commit comments