CMakeLists.txt 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. cmake_minimum_required(VERSION 2.8.10)
  2. project(brpc C CXX)
  3. # Enable MACOSX_RPATH. Run "cmake --help-policy CMP0042" for policy details.
  4. if(POLICY CMP0042)
  5. cmake_policy(SET CMP0042 NEW)
  6. endif()
  7. set(BRPC_VERSION 0.9.0)
  8. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  9. # require at least gcc 4.8
  10. if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
  11. message(FATAL_ERROR "GCC is too old, please install a newer version supporting C++11")
  12. endif()
  13. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  14. # require at least clang 3.3
  15. if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.3)
  16. message(FATAL_ERROR "Clang is too old, please install a newer version supporting C++11")
  17. endif()
  18. else()
  19. message(WARNING "You are using an unsupported compiler! Compilation has only been tested with Clang and GCC.")
  20. endif()
  21. option(WITH_GLOG "With glog" OFF)
  22. option(DEBUG "Print debug logs" OFF)
  23. option(WITH_DEBUG_SYMBOLS "With debug symbols" ON)
  24. option(WITH_THRIFT "With thrift framed protocol supported" OFF)
  25. option(BUILD_UNIT_TESTS "Whether to build unit tests" OFF)
  26. set(WITH_GLOG_VAL "0")
  27. if(WITH_GLOG)
  28. set(WITH_GLOG_VAL "1")
  29. endif()
  30. if(WITH_DEBUG_SYMBOLS)
  31. set(DEBUG_SYMBOL "-g")
  32. endif()
  33. if(WITH_THRIFT)
  34. set(THRIFT_CPP_FLAG "-DENABLE_THRIFT_FRAMED_PROTOCOL")
  35. set(THRIFTNB_LIB "thriftnb")
  36. set(THRIFT_LIB "thrift")
  37. endif()
  38. include(GNUInstallDirs)
  39. configure_file(${CMAKE_SOURCE_DIR}/config.h.in ${CMAKE_SOURCE_DIR}/src/butil/config.h @ONLY)
  40. set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
  41. find_package(GFLAGS REQUIRED)
  42. execute_process(
  43. COMMAND bash -c "grep \"namespace [_A-Za-z0-9]\\+ {\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $2}' | tr -d '\n'"
  44. OUTPUT_VARIABLE GFLAGS_NS
  45. )
  46. if(${GFLAGS_NS} STREQUAL "GFLAGS_NAMESPACE")
  47. execute_process(
  48. COMMAND bash -c "grep \"#define GFLAGS_NAMESPACE [_A-Za-z0-9]\\+\" ${GFLAGS_INCLUDE_PATH}/gflags/gflags_declare.h | head -1 | awk '{print $3}' | tr -d '\n'"
  49. OUTPUT_VARIABLE GFLAGS_NS
  50. )
  51. endif()
  52. include_directories(
  53. ${CMAKE_SOURCE_DIR}/src
  54. ${CMAKE_CURRENT_BINARY_DIR}
  55. )
  56. execute_process(
  57. COMMAND bash -c "git rev-parse --short HEAD | tr -d '\n'"
  58. OUTPUT_VARIABLE BRPC_REVISION
  59. )
  60. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  61. include(CheckFunctionExists)
  62. CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)
  63. if(NOT HAVE_CLOCK_GETTIME)
  64. set(DEFINE_CLOCK_GETTIME "-DNO_CLOCK_GETTIME_IN_MAC")
  65. endif()
  66. endif()
  67. set(CMAKE_CPP_FLAGS "${DEFINE_CLOCK_GETTIME} -DBRPC_WITH_GLOG=${WITH_GLOG_VAL} -DGFLAGS_NS=${GFLAGS_NS}")
  68. set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} -DBTHREAD_USE_FAST_PTHREAD_MUTEX -D__const__= -D_GNU_SOURCE -DUSE_SYMBOLIZE -DNO_TCMALLOC -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DBRPC_REVISION=\\\"${BRPC_REVISION}\\\" -D__STRICT_ANSI__")
  69. set(CMAKE_CPP_FLAGS "${CMAKE_CPP_FLAGS} ${DEBUG_SYMBOL} ${THRIFT_CPP_FLAG}")
  70. set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer")
  71. set(CMAKE_C_FLAGS "${CMAKE_CPP_FLAGS} -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-unused-parameter -fno-omit-frame-pointer")
  72. macro(use_cxx11)
  73. if(CMAKE_VERSION VERSION_LESS "3.1.3")
  74. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  75. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  76. endif()
  77. if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  78. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  79. endif()
  80. else()
  81. set(CMAKE_CXX_STANDARD 11)
  82. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  83. endif()
  84. endmacro(use_cxx11)
  85. use_cxx11()
  86. if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  87. #required by butil/crc32.cc to boost performance for 10x
  88. if(NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4))
  89. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4 -msse4.2")
  90. endif()
  91. if(NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0))
  92. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-aligned-new")
  93. endif()
  94. endif()
  95. include(FindProtobuf)
  96. include(FindThreads)
  97. find_path(LEVELDB_INCLUDE_PATH NAMES leveldb/db.h)
  98. find_library(LEVELDB_LIB NAMES leveldb)
  99. if ((NOT LEVELDB_INCLUDE_PATH) OR (NOT LEVELDB_LIB))
  100. message(FATAL_ERROR "Fail to find leveldb")
  101. endif()
  102. if(WITH_GLOG)
  103. find_path(GLOG_INCLUDE_PATH NAMES glog/logging.h)
  104. find_library(GLOG_LIB NAMES glog)
  105. if((NOT GLOG_INCLUDE_PATH) OR (NOT GLOG_LIB))
  106. message(FATAL_ERROR "Fail to find glog")
  107. endif()
  108. include_directories(${GLOG_INCLUDE_PATH})
  109. endif()
  110. find_library(PROTOC_LIB NAMES protoc)
  111. if(NOT PROTOC_LIB)
  112. message(FATAL_ERROR "Fail to find protoc lib")
  113. endif()
  114. if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  115. set(OPENSSL_ROOT_DIR
  116. "/usr/local/opt/openssl" # Homebrew installed OpenSSL
  117. )
  118. endif()
  119. include(FindOpenSSL)
  120. include_directories(
  121. ${GFLAGS_INCLUDE_PATH}
  122. ${PROTOBUF_INCLUDE_DIRS}
  123. ${LEVELDB_INCLUDE_PATH}
  124. ${OPENSSL_INCLUDE_DIR}
  125. )
  126. set(DYNAMIC_LIB
  127. ${GFLAGS_LIBRARY}
  128. ${PROTOBUF_LIBRARIES}
  129. ${LEVELDB_LIB}
  130. ${PROTOC_LIB}
  131. ${CMAKE_THREAD_LIBS_INIT}
  132. ${THRIFT_LIB}
  133. ${THRIFTNB_LIB}
  134. ${OPENSSL_LIBRARIES}
  135. ${OPENSSL_CRYPTO_LIBRARY}
  136. dl
  137. z
  138. )
  139. set(BRPC_PRIVATE_LIBS "-lgflags -lprotobuf -lleveldb -lprotoc -lssl -lcrypto -ldl -lz")
  140. if(WITH_GLOG)
  141. set(DYNAMIC_LIB ${DYNAMIC_LIB} ${GLOG_LIB})
  142. set(BRPC_PRIVATE_LIBS "${BRPC_PRIVATE_LIBS} -lglog")
  143. endif()
  144. if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  145. set(DYNAMIC_LIB ${DYNAMIC_LIB} rt)
  146. set(BRPC_PRIVATE_LIBS "${BRPC_PRIVATE_LIBS} -lrt")
  147. elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  148. set(DYNAMIC_LIB ${DYNAMIC_LIB}
  149. pthread
  150. "-framework CoreFoundation"
  151. "-framework CoreGraphics"
  152. "-framework CoreData"
  153. "-framework CoreText"
  154. "-framework Security"
  155. "-framework Foundation"
  156. "-Wl,-U,_MallocExtension_ReleaseFreeMemory"
  157. "-Wl,-U,_ProfilerStart"
  158. "-Wl,-U,_ProfilerStop")
  159. endif()
  160. # for *.so
  161. set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/lib)
  162. # for *.a
  163. set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/lib)
  164. # list all source files
  165. set(BUTIL_SOURCES
  166. ${CMAKE_SOURCE_DIR}/src/butil/third_party/dmg_fp/g_fmt.cc
  167. ${CMAKE_SOURCE_DIR}/src/butil/third_party/dmg_fp/dtoa_wrapper.cc
  168. ${CMAKE_SOURCE_DIR}/src/butil/third_party/dynamic_annotations/dynamic_annotations.c
  169. ${CMAKE_SOURCE_DIR}/src/butil/third_party/icu/icu_utf.cc
  170. ${CMAKE_SOURCE_DIR}/src/butil/third_party/superfasthash/superfasthash.c
  171. ${CMAKE_SOURCE_DIR}/src/butil/third_party/modp_b64/modp_b64.cc
  172. ${CMAKE_SOURCE_DIR}/src/butil/third_party/nspr/prtime.cc
  173. ${CMAKE_SOURCE_DIR}/src/butil/third_party/symbolize/demangle.cc
  174. ${CMAKE_SOURCE_DIR}/src/butil/third_party/symbolize/symbolize.cc
  175. ${CMAKE_SOURCE_DIR}/src/butil/third_party/snappy/snappy-sinksource.cc
  176. ${CMAKE_SOURCE_DIR}/src/butil/third_party/snappy/snappy-stubs-internal.cc
  177. ${CMAKE_SOURCE_DIR}/src/butil/third_party/snappy/snappy.cc
  178. ${CMAKE_SOURCE_DIR}/src/butil/third_party/murmurhash3/murmurhash3.cpp
  179. ${CMAKE_SOURCE_DIR}/src/butil/arena.cpp
  180. ${CMAKE_SOURCE_DIR}/src/butil/at_exit.cc
  181. ${CMAKE_SOURCE_DIR}/src/butil/atomicops_internals_x86_gcc.cc
  182. ${CMAKE_SOURCE_DIR}/src/butil/base64.cc
  183. ${CMAKE_SOURCE_DIR}/src/butil/big_endian.cc
  184. ${CMAKE_SOURCE_DIR}/src/butil/cpu.cc
  185. ${CMAKE_SOURCE_DIR}/src/butil/debug/alias.cc
  186. ${CMAKE_SOURCE_DIR}/src/butil/debug/asan_invalid_access.cc
  187. ${CMAKE_SOURCE_DIR}/src/butil/debug/crash_logging.cc
  188. ${CMAKE_SOURCE_DIR}/src/butil/debug/debugger.cc
  189. ${CMAKE_SOURCE_DIR}/src/butil/debug/debugger_posix.cc
  190. ${CMAKE_SOURCE_DIR}/src/butil/debug/dump_without_crashing.cc
  191. ${CMAKE_SOURCE_DIR}/src/butil/debug/proc_maps_linux.cc
  192. ${CMAKE_SOURCE_DIR}/src/butil/debug/stack_trace.cc
  193. ${CMAKE_SOURCE_DIR}/src/butil/debug/stack_trace_posix.cc
  194. ${CMAKE_SOURCE_DIR}/src/butil/environment.cc
  195. ${CMAKE_SOURCE_DIR}/src/butil/files/file.cc
  196. ${CMAKE_SOURCE_DIR}/src/butil/files/file_posix.cc
  197. ${CMAKE_SOURCE_DIR}/src/butil/files/file_enumerator.cc
  198. ${CMAKE_SOURCE_DIR}/src/butil/files/file_enumerator_posix.cc
  199. ${CMAKE_SOURCE_DIR}/src/butil/files/file_path.cc
  200. ${CMAKE_SOURCE_DIR}/src/butil/files/file_path_constants.cc
  201. ${CMAKE_SOURCE_DIR}/src/butil/files/memory_mapped_file.cc
  202. ${CMAKE_SOURCE_DIR}/src/butil/files/memory_mapped_file_posix.cc
  203. ${CMAKE_SOURCE_DIR}/src/butil/files/scoped_file.cc
  204. ${CMAKE_SOURCE_DIR}/src/butil/files/scoped_temp_dir.cc
  205. ${CMAKE_SOURCE_DIR}/src/butil/file_util.cc
  206. ${CMAKE_SOURCE_DIR}/src/butil/file_util_posix.cc
  207. ${CMAKE_SOURCE_DIR}/src/butil/guid.cc
  208. ${CMAKE_SOURCE_DIR}/src/butil/guid_posix.cc
  209. ${CMAKE_SOURCE_DIR}/src/butil/hash.cc
  210. ${CMAKE_SOURCE_DIR}/src/butil/lazy_instance.cc
  211. ${CMAKE_SOURCE_DIR}/src/butil/location.cc
  212. ${CMAKE_SOURCE_DIR}/src/butil/md5.cc
  213. ${CMAKE_SOURCE_DIR}/src/butil/memory/aligned_memory.cc
  214. ${CMAKE_SOURCE_DIR}/src/butil/memory/ref_counted.cc
  215. ${CMAKE_SOURCE_DIR}/src/butil/memory/ref_counted_memory.cc
  216. ${CMAKE_SOURCE_DIR}/src/butil/memory/singleton.cc
  217. ${CMAKE_SOURCE_DIR}/src/butil/memory/weak_ptr.cc
  218. ${CMAKE_SOURCE_DIR}/src/butil/posix/file_descriptor_shuffle.cc
  219. ${CMAKE_SOURCE_DIR}/src/butil/posix/global_descriptors.cc
  220. ${CMAKE_SOURCE_DIR}/src/butil/process_util.cc
  221. ${CMAKE_SOURCE_DIR}/src/butil/rand_util.cc
  222. ${CMAKE_SOURCE_DIR}/src/butil/rand_util_posix.cc
  223. ${CMAKE_SOURCE_DIR}/src/butil/fast_rand.cpp
  224. ${CMAKE_SOURCE_DIR}/src/butil/safe_strerror_posix.cc
  225. ${CMAKE_SOURCE_DIR}/src/butil/sha1_portable.cc
  226. ${CMAKE_SOURCE_DIR}/src/butil/strings/latin1_string_conversions.cc
  227. ${CMAKE_SOURCE_DIR}/src/butil/strings/nullable_string16.cc
  228. ${CMAKE_SOURCE_DIR}/src/butil/strings/safe_sprintf.cc
  229. ${CMAKE_SOURCE_DIR}/src/butil/strings/string16.cc
  230. ${CMAKE_SOURCE_DIR}/src/butil/strings/string_number_conversions.cc
  231. ${CMAKE_SOURCE_DIR}/src/butil/strings/string_split.cc
  232. ${CMAKE_SOURCE_DIR}/src/butil/strings/string_piece.cc
  233. ${CMAKE_SOURCE_DIR}/src/butil/strings/string_util.cc
  234. ${CMAKE_SOURCE_DIR}/src/butil/strings/string_util_constants.cc
  235. ${CMAKE_SOURCE_DIR}/src/butil/strings/stringprintf.cc
  236. ${CMAKE_SOURCE_DIR}/src/butil/strings/utf_offset_string_conversions.cc
  237. ${CMAKE_SOURCE_DIR}/src/butil/strings/utf_string_conversion_utils.cc
  238. ${CMAKE_SOURCE_DIR}/src/butil/strings/utf_string_conversions.cc
  239. ${CMAKE_SOURCE_DIR}/src/butil/synchronization/cancellation_flag.cc
  240. ${CMAKE_SOURCE_DIR}/src/butil/synchronization/condition_variable_posix.cc
  241. ${CMAKE_SOURCE_DIR}/src/butil/synchronization/waitable_event_posix.cc
  242. ${CMAKE_SOURCE_DIR}/src/butil/threading/non_thread_safe_impl.cc
  243. ${CMAKE_SOURCE_DIR}/src/butil/threading/platform_thread_posix.cc
  244. ${CMAKE_SOURCE_DIR}/src/butil/threading/simple_thread.cc
  245. ${CMAKE_SOURCE_DIR}/src/butil/threading/thread_checker_impl.cc
  246. ${CMAKE_SOURCE_DIR}/src/butil/threading/thread_collision_warner.cc
  247. ${CMAKE_SOURCE_DIR}/src/butil/threading/thread_id_name_manager.cc
  248. ${CMAKE_SOURCE_DIR}/src/butil/threading/thread_local_posix.cc
  249. ${CMAKE_SOURCE_DIR}/src/butil/threading/thread_local_storage.cc
  250. ${CMAKE_SOURCE_DIR}/src/butil/threading/thread_local_storage_posix.cc
  251. ${CMAKE_SOURCE_DIR}/src/butil/threading/thread_restrictions.cc
  252. ${CMAKE_SOURCE_DIR}/src/butil/threading/watchdog.cc
  253. ${CMAKE_SOURCE_DIR}/src/butil/time/clock.cc
  254. ${CMAKE_SOURCE_DIR}/src/butil/time/default_clock.cc
  255. ${CMAKE_SOURCE_DIR}/src/butil/time/default_tick_clock.cc
  256. ${CMAKE_SOURCE_DIR}/src/butil/time/tick_clock.cc
  257. ${CMAKE_SOURCE_DIR}/src/butil/time/time.cc
  258. ${CMAKE_SOURCE_DIR}/src/butil/time/time_posix.cc
  259. ${CMAKE_SOURCE_DIR}/src/butil/version.cc
  260. ${CMAKE_SOURCE_DIR}/src/butil/logging.cc
  261. ${CMAKE_SOURCE_DIR}/src/butil/class_name.cpp
  262. ${CMAKE_SOURCE_DIR}/src/butil/errno.cpp
  263. ${CMAKE_SOURCE_DIR}/src/butil/find_cstr.cpp
  264. ${CMAKE_SOURCE_DIR}/src/butil/status.cpp
  265. ${CMAKE_SOURCE_DIR}/src/butil/string_printf.cpp
  266. ${CMAKE_SOURCE_DIR}/src/butil/thread_local.cpp
  267. ${CMAKE_SOURCE_DIR}/src/butil/unix_socket.cpp
  268. ${CMAKE_SOURCE_DIR}/src/butil/endpoint.cpp
  269. ${CMAKE_SOURCE_DIR}/src/butil/fd_utility.cpp
  270. ${CMAKE_SOURCE_DIR}/src/butil/files/temp_file.cpp
  271. ${CMAKE_SOURCE_DIR}/src/butil/files/file_watcher.cpp
  272. ${CMAKE_SOURCE_DIR}/src/butil/time.cpp
  273. ${CMAKE_SOURCE_DIR}/src/butil/zero_copy_stream_as_streambuf.cpp
  274. ${CMAKE_SOURCE_DIR}/src/butil/crc32c.cc
  275. ${CMAKE_SOURCE_DIR}/src/butil/containers/case_ignored_flat_map.cpp
  276. ${CMAKE_SOURCE_DIR}/src/butil/iobuf.cpp
  277. ${CMAKE_SOURCE_DIR}/src/butil/popen.cpp
  278. )
  279. if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  280. set(BUTIL_SOURCES ${BUTIL_SOURCES}
  281. ${CMAKE_SOURCE_DIR}/src/butil/file_util_linux.cc
  282. ${CMAKE_SOURCE_DIR}/src/butil/threading/platform_thread_linux.cc
  283. ${CMAKE_SOURCE_DIR}/src/butil/strings/sys_string_conversions_posix.cc)
  284. elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  285. set(BUTIL_SOURCES ${BUTIL_SOURCES}
  286. ${CMAKE_SOURCE_DIR}/src/butil/mac/bundle_locations.mm
  287. ${CMAKE_SOURCE_DIR}/src/butil/mac/foundation_util.mm
  288. ${CMAKE_SOURCE_DIR}/src/butil/file_util_mac.mm
  289. ${CMAKE_SOURCE_DIR}/src/butil/threading/platform_thread_mac.mm
  290. ${CMAKE_SOURCE_DIR}/src/butil/strings/sys_string_conversions_mac.mm
  291. ${CMAKE_SOURCE_DIR}/src/butil/time/time_mac.cc
  292. ${CMAKE_SOURCE_DIR}/src/butil/mac/scoped_mach_port.cc)
  293. endif()
  294. file(GLOB_RECURSE BVAR_SOURCES "${CMAKE_SOURCE_DIR}/src/bvar/*.cpp")
  295. file(GLOB_RECURSE BTHREAD_SOURCES "${CMAKE_SOURCE_DIR}/src/bthread/*.cpp")
  296. file(GLOB_RECURSE JSON2PB_SOURCES "${CMAKE_SOURCE_DIR}/src/json2pb/*.cpp")
  297. file(GLOB_RECURSE BRPC_SOURCES "${CMAKE_SOURCE_DIR}/src/brpc/*.cpp")
  298. file(GLOB_RECURSE THRIFT_SOURCES "thrift*.cpp")
  299. if(WITH_THRIFT)
  300. message("brpc compile with thrift proctol")
  301. else()
  302. # Remove thrift sources
  303. foreach(v ${THRIFT_SOURCES})
  304. list(REMOVE_ITEM BRPC_SOURCES ${v})
  305. endforeach()
  306. set(THRIFT_SOURCES "")
  307. endif()
  308. set(MCPACK2PB_SOURCES
  309. ${CMAKE_SOURCE_DIR}/src/mcpack2pb/field_type.cpp
  310. ${CMAKE_SOURCE_DIR}/src/mcpack2pb/mcpack2pb.cpp
  311. ${CMAKE_SOURCE_DIR}/src/mcpack2pb/parser.cpp
  312. ${CMAKE_SOURCE_DIR}/src/mcpack2pb/serializer.cpp
  313. )
  314. include(CompileProto)
  315. set(PROTO_FILES idl_options.proto
  316. brpc/rtmp.proto
  317. brpc/rpc_dump.proto
  318. brpc/get_favicon.proto
  319. brpc/span.proto
  320. brpc/builtin_service.proto
  321. brpc/get_js.proto
  322. brpc/errno.proto
  323. brpc/nshead_meta.proto
  324. brpc/options.proto
  325. brpc/policy/baidu_rpc_meta.proto
  326. brpc/policy/hulu_pbrpc_meta.proto
  327. brpc/policy/public_pbrpc_meta.proto
  328. brpc/policy/sofa_pbrpc_meta.proto
  329. brpc/policy/mongo.proto
  330. brpc/trackme.proto
  331. brpc/streaming_rpc_meta.proto)
  332. file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/output/include/brpc)
  333. set(PROTOC_FLAGS ${PROTOC_FLAGS} -I${PROTOBUF_INCLUDE_DIR})
  334. compile_proto(PROTO_HDRS PROTO_SRCS ${CMAKE_BINARY_DIR}
  335. ${CMAKE_BINARY_DIR}/output/include
  336. ${CMAKE_SOURCE_DIR}/src
  337. "${PROTO_FILES}")
  338. add_library(PROTO_LIB OBJECT ${PROTO_SRCS} ${PROTO_HDRS})
  339. set(SOURCES
  340. ${BVAR_SOURCES}
  341. ${BTHREAD_SOURCES}
  342. ${JSON2PB_SOURCES}
  343. ${MCPACK2PB_SOURCES}
  344. ${BRPC_SOURCES}
  345. ${THRIFT_SOURCES}
  346. )
  347. add_subdirectory(src)
  348. if(BUILD_UNIT_TESTS)
  349. add_subdirectory(test)
  350. endif()
  351. add_subdirectory(tools)
  352. file(COPY ${CMAKE_CURRENT_BINARY_DIR}/brpc/
  353. DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/output/include/brpc/
  354. FILES_MATCHING
  355. PATTERN "*.h"
  356. PATTERN "*.hpp"
  357. )
  358. file(COPY ${CMAKE_SOURCE_DIR}/src/
  359. DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/output/include/
  360. FILES_MATCHING
  361. PATTERN "*.h"
  362. PATTERN "*.hpp"
  363. )
  364. install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/output/include/
  365. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
  366. FILES_MATCHING
  367. PATTERN "*.h"
  368. PATTERN "*.hpp"
  369. )
  370. # Install pkgconfig
  371. configure_file(cmake/brpc.pc.in ${CMAKE_BINARY_DIR}/brpc.pc @ONLY)
  372. install(FILES ${CMAKE_BINARY_DIR}/brpc.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)