Commit e859a21b authored by zhujiashun's avatar zhujiashun

Merge branch 'cmake_support' of github.com:brpc/brpc into cmake_support

parents 438cbecc 7f984db5
......@@ -21,3 +21,13 @@
# Ignore auto-generated files
config.mk
src/butil/config.h
# Ignore CMake files
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
cmake_minimum_required(VERSION 3.0)
project(brpc)
option(WITH_GLOG "With glog" OFF)
if(WITH_GLOG)
set(WITH_GLOG_VAL "1")
else()
set(WITH_GLOG_VAL "0")
endif()
configure_file(${CMAKE_SOURCE_DIR}/config.h.in ${CMAKE_SOURCE_DIR}/src/butil/config.h @ONLY)
include_directories(
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/example
)
set(CMAKE_CPP_FLAGS "-DBRPC_WITH_GLOG=0 -DGFLAGS_NS=google -g")
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")
set(CMAKE_CXX_FLAGS "${CMAKE_CPP_FLAGS} -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-invalid-offsetof -Wno-unused-parameter -fno-omit-frame-pointer -std=c++0x -lpthread")
set(CMAKE_C_FLAGS "${CMAKE_CPP_FLAGS} -O2 -pipe -Wall -W -fPIC -fstrict-aliasing -Wno-unused-parameter -fno-omit-frame-pointer")
add_definitions(-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)
#add_definitions(-DPROTOBUF_INLINE_NOT_IN_HEADERS=0)
#required by butil/crc32.cc to boost performance for 10x
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.4)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4 -msse4.2")
endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-aligned-new")
endif()
find_path(GFLAGS_HEADER NAMES gflags/gflags.h PATHS $ENV{GFLAGS_HEADER_PATH})
find_library(GFLAGS_LIB NAMES gflags PATHS $ENV{GFLAGS_LIB_PATH})
#find_package(gflags REQUIRED)
#protobuf 3.2
find_path(PROTOBUF_HEADER NAMES google/protobuf/stubs/common.h PATHS $ENV{PB_HEADER_PATH})
find_library(PROTOBUF_LIB NAMES protobuf PATHS $ENV{PB_LIB_PATH})
find_path(LEVELDB_HEADER NAMES leveldb/db.h PATHS $ENV{LEVELDB_HEADER_PATH})
find_library(LEVELDB_LIB NAMES leveldb PATHS $ENV{LEVELDB_LIB_PATH})
if(WITH_GLOG)
find_path(GLOG_HEADER NAMES glog/logging.h PATHS $ENV{GLOG_HEADER_PATH})
find_library(GLOG_LIB NAMES glog PATHS $ENV{GLOG_LIB_PATH})
include_directories(${GLOG_HEADER})
endif()
find_package(Threads)
#protobuf 3.2
find_library(PROTOC_LIB NAMES protoc PATHS $ENV{PB_LIB_PATH})
include_directories(
${GFLAGS_HEADER}
${PROTOBUF_HEADER}
${LEVELDB_HEADER}
)
# for *.so
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# for *.a
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(example)
set(_gflags_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
find_path(Gflags_INCLUDE_PATH gflags/gflags.h)
if (Gflags_STATIC)
if (WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
else (WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif (WIN32)
endif (Gflags_STATIC)
find_library(Gflags_LIBRARY NAMES gflags libgflags)
if(Gflags_INCLUDE_PATH AND Gflags_LIBRARY)
set(Gflags_FOUND TRUE)
endif(Gflags_INCLUDE_PATH AND Gflags_LIBRARY)
if(Gflags_FOUND)
if(NOT Gflags_FIND_QUIETLY)
message(STATUS "Found gflags: ${Gflags_LIBRARY}")
endif(NOT Gflags_FIND_QUIETLY)
else(Gflags_FOUND)
if(Gflags_FIND_REQUIRED)
message(FATAL_ERROR "Could not find gflags library.")
endif(Gflags_FIND_REQUIRED)
endif(Gflags_FOUND)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_gflags_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
#ifndef BUTIL_CONFIG_H
#define BUTIL_CONFIG_H
#cmakedefine BRPC_WITH_GLOG @WITH_GLOG_VAL@
#endif // BUTIL_CONFIG_H
add_subdirectory(http_c++)
add_subdirectory(asynchronous_echo_c++)
add_subdirectory(backup_request_c++)
add_subdirectory(cancel_c++)
add_subdirectory(cascade_echo_c++)
add_subdirectory(dynamic_partition_echo_c++)
add_subdirectory(echo_c++)
add_subdirectory(echo_c++_hulu_pbrpc)
add_subdirectory(echo_c++_sofa_pbrpc)
add_subdirectory(echo_c++_ubrpc_compack)
add_subdirectory(memcache_c++)
add_subdirectory(multi_threaded_echo_c++)
add_subdirectory(multi_threaded_echo_fns_c++)
add_subdirectory(multi_threaded_mcpack_c++)
add_subdirectory(nshead_extension_c++)
add_subdirectory(nshead_pb_extension_c++)
add_subdirectory(parallel_echo_c++)
add_subdirectory(partition_echo_c++)
# need readline library
#add_subdirectory(redis_c++)
add_subdirectory(selective_echo_c++)
add_subdirectory(session_data_and_thread_local)
add_subdirectory(streaming_echo_c++)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
add_executable(asynchronous_echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(asynchronous_echo_client brpc)
add_executable(asynchronous_echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(asynchronous_echo_server brpc)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
add_executable(backup_request_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(backup_request_client brpc)
add_executable(backup_request_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(backup_request_server brpc)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
add_executable(cancel_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(cancel_client brpc)
add_executable(cancel_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(cancel_server brpc)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
add_executable(cascade_echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(cascade_echo_client brpc)
add_executable(cascade_echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(cascade_echo_server brpc)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
add_executable(dynamic_partition_echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(dynamic_partition_echo_client brpc)
add_executable(dynamic_partition_echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(dynamic_partition_echo_server brpc)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
add_executable(echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(echo_client brpc)
add_executable(echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(echo_server brpc)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
add_executable(echo_hulu_pbrpc_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(echo_hulu_pbrpc_client brpc)
add_executable(echo_hulu_pbrpc_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(echo_hulu_pbrpc_server brpc)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
add_executable(echo_sofa_pbrpc_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(echo_sofa_pbrpc_client brpc)
add_executable(echo_sofa_pbrpc_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(echo_sofa_pbrpc_server brpc)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
execute_process(
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTO_FLAGS} --cpp_out=${CMAKE_CURRENT_BINARY_DIR} --proto_path=${PROTOBUF_INCLUDE_DIR} --proto_path=${CMAKE_CURRENT_BINARY_DIR}/../../src/ --proto_path=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/echo.proto
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_executable(echo_ubrpc_compack_client client.cpp echo.pb.cc)
target_link_libraries(echo_ubrpc_compack_client brpc)
add_executable(echo_ubrpc_compack_server server.cpp echo.pb.cc)
target_link_libraries(echo_ubrpc_compack_server brpc)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER http.proto)
add_executable(http_client http_client.cpp)
target_link_libraries(http_client brpc)
add_executable(http_server http_server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(http_server brpc)
add_executable(benchmark_http benchmark_http.cpp)
target_link_libraries(benchmark_http brpc)
add_executable(memcache_client client.cpp)
target_link_libraries(memcache_client brpc)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
add_executable(multi_threaded_echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(multi_threaded_echo_client brpc)
add_executable(multi_threaded_echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(multi_threaded_echo_server brpc)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
add_executable(multi_threaded_echo_fns_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(multi_threaded_echo_fns_client brpc)
add_executable(multi_threaded_echo_fns_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(multi_threaded_echo_fns_server brpc)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
execute_process(
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTO_FLAGS} --cpp_out=${CMAKE_CURRENT_BINARY_DIR} --proto_path=${PROTOBUF_INCLUDE_DIR} --proto_path=${CMAKE_CURRENT_BINARY_DIR}/../../src/ --proto_path=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/echo.proto
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_executable(multi_threaded_mcpack_client client.cpp echo.pb.cc)
target_link_libraries(multi_threaded_mcpack_client brpc)
add_executable(multi_threaded_mcpack_server server.cpp echo.pb.cc)
target_link_libraries(multi_threaded_mcpack_server brpc)
add_executable(nshead_extension_client client.cpp)
target_link_libraries(nshead_extension_client brpc)
add_executable(nshead_extension_server server.cpp)
target_link_libraries(nshead_extension_server brpc)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
add_executable(nshead_pb_extension_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(nshead_pb_extension_client brpc)
add_executable(nshead_pb_extension_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(nshead_pb_extension_server brpc)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
add_executable(parallel_echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(parallel_echo_client brpc)
add_executable(parallel_echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(parallel_echo_server brpc)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
add_executable(client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(client brpc)
add_executable(server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(server brpc)
add_executable(redis_cli redis_cli.cpp)
target_link_libraries(redis_cli brpc)
add_executable(redis_press redis_press.cpp)
target_link_libraries(redis_press brpc)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
add_executable(selective_echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(selective_echo_client brpc)
add_executable(selective_echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(selective_echo_server brpc)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
add_executable(session_data_and_thread_local_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(session_data_and_thread_local_client brpc)
add_executable(session_data_and_thread_local_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(session_data_and_thread_local_server brpc)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
protobuf_generate_cpp(PROTO_SRC PROTO_HEADER echo.proto)
add_executable(streaming_echo_client client.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(streaming_echo_client brpc)
add_executable(streaming_echo_server server.cpp ${PROTO_SRC} ${PROTO_HEADER})
target_link_libraries(streaming_echo_server brpc)
project(lib)
include(FindProtobuf)
find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
file(GLOB PROTOS "*.proto" "brpc/*.proto" "brpc/policy/*.proto")
list(APPEND PROTO_FLAGS -I${CMAKE_CURRENT_BINARY_DIR})
foreach(PROTO ${PROTOS})
get_filename_component(PROTO_WE ${PROTO} NAME_WE)
#list(APPEND PROTO_SRCS "${CMAKE_CURRENT_BINARY_DIR}/${PROTO_WE}.pb.cc")
#list(APPEND PROTO_HDRS "${CMAKE_CURRENT_BINARY_DIR}/${PROTO_WE}.pb.h")
execute_process(
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTO_FLAGS} --cpp_out=${CMAKE_CURRENT_BINARY_DIR} --proto_path=${PROTOBUF_INCLUDE_DIR} ${PROTO}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endforeach()
#add_library(proto ${PROTO_SRCS} ${PROTO_HDRS})
set(BUTIL_SOURCES
${CMAKE_SOURCE_DIR}/src/butil/third_party/dmg_fp/g_fmt.cc
${CMAKE_SOURCE_DIR}/src/butil/third_party/dmg_fp/dtoa_wrapper.cc
${CMAKE_SOURCE_DIR}/src/butil/third_party/dynamic_annotations/dynamic_annotations.c
${CMAKE_SOURCE_DIR}/src/butil/third_party/icu/icu_utf.cc
${CMAKE_SOURCE_DIR}/src/butil/third_party/superfasthash/superfasthash.c
${CMAKE_SOURCE_DIR}/src/butil/third_party/modp_b64/modp_b64.cc
${CMAKE_SOURCE_DIR}/src/butil/third_party/nspr/prtime.cc
${CMAKE_SOURCE_DIR}/src/butil/third_party/symbolize/demangle.cc
${CMAKE_SOURCE_DIR}/src/butil/third_party/symbolize/symbolize.cc
${CMAKE_SOURCE_DIR}/src/butil/third_party/snappy/snappy-sinksource.cc
${CMAKE_SOURCE_DIR}/src/butil/third_party/snappy/snappy-stubs-internal.cc
${CMAKE_SOURCE_DIR}/src/butil/third_party/snappy/snappy.cc
${CMAKE_SOURCE_DIR}/src/butil/third_party/murmurhash3/murmurhash3.cpp
${CMAKE_SOURCE_DIR}/src/butil/arena.cpp
${CMAKE_SOURCE_DIR}/src/butil/at_exit.cc
${CMAKE_SOURCE_DIR}/src/butil/atomicops_internals_x86_gcc.cc
${CMAKE_SOURCE_DIR}/src/butil/base64.cc
${CMAKE_SOURCE_DIR}/src/butil/big_endian.cc
${CMAKE_SOURCE_DIR}/src/butil/cpu.cc
${CMAKE_SOURCE_DIR}/src/butil/debug/alias.cc
${CMAKE_SOURCE_DIR}/src/butil/debug/asan_invalid_access.cc
${CMAKE_SOURCE_DIR}/src/butil/debug/crash_logging.cc
${CMAKE_SOURCE_DIR}/src/butil/debug/debugger.cc
${CMAKE_SOURCE_DIR}/src/butil/debug/debugger_posix.cc
${CMAKE_SOURCE_DIR}/src/butil/debug/dump_without_crashing.cc
${CMAKE_SOURCE_DIR}/src/butil/debug/proc_maps_linux.cc
${CMAKE_SOURCE_DIR}/src/butil/debug/stack_trace.cc
${CMAKE_SOURCE_DIR}/src/butil/debug/stack_trace_posix.cc
${CMAKE_SOURCE_DIR}/src/butil/environment.cc
${CMAKE_SOURCE_DIR}/src/butil/files/file.cc
${CMAKE_SOURCE_DIR}/src/butil/files/file_posix.cc
${CMAKE_SOURCE_DIR}/src/butil/files/file_enumerator.cc
${CMAKE_SOURCE_DIR}/src/butil/files/file_enumerator_posix.cc
${CMAKE_SOURCE_DIR}/src/butil/files/file_path.cc
${CMAKE_SOURCE_DIR}/src/butil/files/file_path_constants.cc
${CMAKE_SOURCE_DIR}/src/butil/files/memory_mapped_file.cc
${CMAKE_SOURCE_DIR}/src/butil/files/memory_mapped_file_posix.cc
${CMAKE_SOURCE_DIR}/src/butil/files/scoped_file.cc
${CMAKE_SOURCE_DIR}/src/butil/files/scoped_temp_dir.cc
${CMAKE_SOURCE_DIR}/src/butil/file_util.cc
${CMAKE_SOURCE_DIR}/src/butil/file_util_linux.cc
${CMAKE_SOURCE_DIR}/src/butil/file_util_posix.cc
${CMAKE_SOURCE_DIR}/src/butil/guid.cc
${CMAKE_SOURCE_DIR}/src/butil/guid_posix.cc
${CMAKE_SOURCE_DIR}/src/butil/hash.cc
${CMAKE_SOURCE_DIR}/src/butil/lazy_instance.cc
${CMAKE_SOURCE_DIR}/src/butil/location.cc
${CMAKE_SOURCE_DIR}/src/butil/md5.cc
${CMAKE_SOURCE_DIR}/src/butil/memory/aligned_memory.cc
${CMAKE_SOURCE_DIR}/src/butil/memory/ref_counted.cc
${CMAKE_SOURCE_DIR}/src/butil/memory/ref_counted_memory.cc
${CMAKE_SOURCE_DIR}/src/butil/memory/singleton.cc
${CMAKE_SOURCE_DIR}/src/butil/memory/weak_ptr.cc
${CMAKE_SOURCE_DIR}/src/butil/posix/file_descriptor_shuffle.cc
${CMAKE_SOURCE_DIR}/src/butil/posix/global_descriptors.cc
${CMAKE_SOURCE_DIR}/src/butil/rand_util.cc
${CMAKE_SOURCE_DIR}/src/butil/rand_util_posix.cc
${CMAKE_SOURCE_DIR}/src/butil/fast_rand.cpp
${CMAKE_SOURCE_DIR}/src/butil/safe_strerror_posix.cc
${CMAKE_SOURCE_DIR}/src/butil/sha1_portable.cc
${CMAKE_SOURCE_DIR}/src/butil/strings/latin1_string_conversions.cc
${CMAKE_SOURCE_DIR}/src/butil/strings/nullable_string16.cc
${CMAKE_SOURCE_DIR}/src/butil/strings/safe_sprintf.cc
${CMAKE_SOURCE_DIR}/src/butil/strings/string16.cc
${CMAKE_SOURCE_DIR}/src/butil/strings/string_number_conversions.cc
${CMAKE_SOURCE_DIR}/src/butil/strings/string_split.cc
${CMAKE_SOURCE_DIR}/src/butil/strings/string_piece.cc
${CMAKE_SOURCE_DIR}/src/butil/strings/string_util.cc
${CMAKE_SOURCE_DIR}/src/butil/strings/string_util_constants.cc
${CMAKE_SOURCE_DIR}/src/butil/strings/stringprintf.cc
${CMAKE_SOURCE_DIR}/src/butil/strings/sys_string_conversions_posix.cc
${CMAKE_SOURCE_DIR}/src/butil/strings/utf_offset_string_conversions.cc
${CMAKE_SOURCE_DIR}/src/butil/strings/utf_string_conversion_utils.cc
${CMAKE_SOURCE_DIR}/src/butil/strings/utf_string_conversions.cc
${CMAKE_SOURCE_DIR}/src/butil/synchronization/cancellation_flag.cc
${CMAKE_SOURCE_DIR}/src/butil/synchronization/condition_variable_posix.cc
${CMAKE_SOURCE_DIR}/src/butil/synchronization/waitable_event_posix.cc
${CMAKE_SOURCE_DIR}/src/butil/threading/non_thread_safe_impl.cc
${CMAKE_SOURCE_DIR}/src/butil/threading/platform_thread_linux.cc
${CMAKE_SOURCE_DIR}/src/butil/threading/platform_thread_posix.cc
${CMAKE_SOURCE_DIR}/src/butil/threading/simple_thread.cc
${CMAKE_SOURCE_DIR}/src/butil/threading/thread_checker_impl.cc
${CMAKE_SOURCE_DIR}/src/butil/threading/thread_collision_warner.cc
${CMAKE_SOURCE_DIR}/src/butil/threading/thread_id_name_manager.cc
${CMAKE_SOURCE_DIR}/src/butil/threading/thread_local_posix.cc
${CMAKE_SOURCE_DIR}/src/butil/threading/thread_local_storage.cc
${CMAKE_SOURCE_DIR}/src/butil/threading/thread_local_storage_posix.cc
${CMAKE_SOURCE_DIR}/src/butil/threading/thread_restrictions.cc
${CMAKE_SOURCE_DIR}/src/butil/threading/watchdog.cc
${CMAKE_SOURCE_DIR}/src/butil/time/clock.cc
${CMAKE_SOURCE_DIR}/src/butil/time/default_clock.cc
${CMAKE_SOURCE_DIR}/src/butil/time/default_tick_clock.cc
${CMAKE_SOURCE_DIR}/src/butil/time/tick_clock.cc
${CMAKE_SOURCE_DIR}/src/butil/time/time.cc
${CMAKE_SOURCE_DIR}/src/butil/time/time_posix.cc
${CMAKE_SOURCE_DIR}/src/butil/version.cc
${CMAKE_SOURCE_DIR}/src/butil/logging.cc
${CMAKE_SOURCE_DIR}/src/butil/class_name.cpp
${CMAKE_SOURCE_DIR}/src/butil/errno.cpp
${CMAKE_SOURCE_DIR}/src/butil/find_cstr.cpp
${CMAKE_SOURCE_DIR}/src/butil/status.cpp
${CMAKE_SOURCE_DIR}/src/butil/string_printf.cpp
${CMAKE_SOURCE_DIR}/src/butil/thread_local.cpp
${CMAKE_SOURCE_DIR}/src/butil/unix_socket.cpp
${CMAKE_SOURCE_DIR}/src/butil/endpoint.cpp
${CMAKE_SOURCE_DIR}/src/butil/fd_utility.cpp
${CMAKE_SOURCE_DIR}/src/butil/files/temp_file.cpp
${CMAKE_SOURCE_DIR}/src/butil/files/file_watcher.cpp
${CMAKE_SOURCE_DIR}/src/butil/time.cpp
${CMAKE_SOURCE_DIR}/src/butil/zero_copy_stream_as_streambuf.cpp
${CMAKE_SOURCE_DIR}/src/butil/crc32c.cc
${CMAKE_SOURCE_DIR}/src/butil/containers/case_ignored_flat_map.cpp
${CMAKE_SOURCE_DIR}/src/butil/iobuf.cpp
${CMAKE_SOURCE_DIR}/src/butil/popen.cpp
)
aux_source_directory(${CMAKE_SOURCE_DIR}/src/bvar BVAR_SOURCES1)
aux_source_directory(${CMAKE_SOURCE_DIR}/src/bvar/detail BVAR_SOURCES2)
aux_source_directory(${CMAKE_SOURCE_DIR}/src/bthread BTHREAD_SOURCES)
aux_source_directory(${CMAKE_SOURCE_DIR}/src/json2pb JSON2PB_SOURCES)
aux_source_directory(${CMAKE_SOURCE_DIR}/src/brpc BRPC_SOURCES1)
aux_source_directory(${CMAKE_SOURCE_DIR}/src/brpc/details BRPC_SOURCES2)
aux_source_directory(${CMAKE_SOURCE_DIR}/src/brpc/builtin BRPC_SOURCES3)
aux_source_directory(${CMAKE_SOURCE_DIR}/src/brpc/policy BRPC_SOURCES4)
set(MCPACK2PB_SOURCES
${CMAKE_SOURCE_DIR}/src/mcpack2pb/field_type.cpp
${CMAKE_SOURCE_DIR}/src/mcpack2pb/mcpack2pb.cpp
${CMAKE_SOURCE_DIR}/src/mcpack2pb/parser.cpp
${CMAKE_SOURCE_DIR}/src/mcpack2pb/serializer.cpp
${CMAKE_SOURCE_DIR}/src/idl_options.pb.cc
)
set(SOURCES
${BUTIL_SOURCES}
${BVAR_SOURCES1}
${BVAR_SOURCES2}
${BTHREAD_SOURCES}
${JSON2PB_SOURCES}
${MCPACK2PB_SOURCES}
${BRPC_SOURCES1}
${BRPC_SOURCES2}
${BRPC_SOURCES3}
${BRPC_SOURCES4}
)
add_library(brpc SHARED ${SOURCES})
add_library(brpc_static STATIC ${SOURCES})
target_link_libraries(brpc
${CMAKE_THREAD_LIBS_INIT}
${GFLAGS_LIB}
${PROTOBUF_LIB}
${LEVELDB_LIB}
rt
ssl
crypto
dl
z
${PROTOC_LIB}
)
if(WITH_GLOG)
target_link_libraries(brpc ${GLOG_LIB})
endif()
set(protoc_gen_mcpack_SOURCES
${CMAKE_SOURCE_DIR}/src/mcpack2pb/generator.cpp
)
add_executable(protoc-gen-mcpack ${protoc_gen_mcpack_SOURCES})
target_link_libraries(protoc-gen-mcpack brpc)
#install directory
# cmake -DCMAKE_INSTALL_PREFIX=/usr
install(TARGETS brpc
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
install(DIRECTORY src/
DESTINATION include
FILES_MATCHING
PATTERN "*.h*"
PATTERN "*.proto"
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment