mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 02:55:50 +00:00
Introduces a conanfile.py (and a Conan recipe for RocksDB) to enable building the package with Conan, choosing more recent default versions of dependencies. It removes almost all of the CMake build files related to dependencies, and the configurations for Travis CI and GitLab CI. A new set of cross-platform build instructions are written in BUILD.md. Includes example GitHub Actions workflow for each of Linux, macOS, Windows. * Test on macos-12 We use the <concepts> library which was not added to Apple Clang until version 13.1.6. The default Clang on macos-11 (the sometimes current version of macos-latest) is 13.0.0, and the default Clang on macos-12 is 14.0.0. Closes #4223.
63 lines
2.5 KiB
CMake
63 lines
2.5 KiB
CMake
find_package(gRPC 1.23)
|
|
|
|
#[=================================[
|
|
generate protobuf sources for
|
|
grpc defs and bundle into a
|
|
static lib
|
|
#]=================================]
|
|
set(GRPC_GEN_DIR "${CMAKE_BINARY_DIR}/proto_gen_grpc")
|
|
file(MAKE_DIRECTORY ${GRPC_GEN_DIR})
|
|
set(GRPC_PROTO_SRCS)
|
|
set(GRPC_PROTO_HDRS)
|
|
set(GRPC_PROTO_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/src/ripple/proto/org")
|
|
file(GLOB_RECURSE GRPC_DEFINITION_FILES LIST_DIRECTORIES false "${GRPC_PROTO_ROOT}/*.proto")
|
|
foreach(file ${GRPC_DEFINITION_FILES})
|
|
get_filename_component(_abs_file ${file} ABSOLUTE)
|
|
get_filename_component(_abs_dir ${_abs_file} DIRECTORY)
|
|
get_filename_component(_basename ${file} NAME_WE)
|
|
get_filename_component(_proto_inc ${GRPC_PROTO_ROOT} DIRECTORY) # updir one level
|
|
file(RELATIVE_PATH _rel_root_file ${_proto_inc} ${_abs_file})
|
|
get_filename_component(_rel_root_dir ${_rel_root_file} DIRECTORY)
|
|
file(RELATIVE_PATH _rel_dir ${CMAKE_CURRENT_SOURCE_DIR} ${_abs_dir})
|
|
|
|
set(src_1 "${GRPC_GEN_DIR}/${_rel_root_dir}/${_basename}.grpc.pb.cc")
|
|
set(src_2 "${GRPC_GEN_DIR}/${_rel_root_dir}/${_basename}.pb.cc")
|
|
set(hdr_1 "${GRPC_GEN_DIR}/${_rel_root_dir}/${_basename}.grpc.pb.h")
|
|
set(hdr_2 "${GRPC_GEN_DIR}/${_rel_root_dir}/${_basename}.pb.h")
|
|
add_custom_command(
|
|
OUTPUT ${src_1} ${src_2} ${hdr_1} ${hdr_2}
|
|
COMMAND protobuf::protoc
|
|
ARGS --grpc_out=${GRPC_GEN_DIR}
|
|
--cpp_out=${GRPC_GEN_DIR}
|
|
--plugin=protoc-gen-grpc=$<TARGET_FILE:gRPC::grpc_cpp_plugin>
|
|
-I ${_proto_inc} -I ${_rel_dir}
|
|
${_abs_file}
|
|
DEPENDS ${_abs_file} protobuf::protoc gRPC::grpc_cpp_plugin
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
COMMENT "Running gRPC C++ protocol buffer compiler on ${file}"
|
|
VERBATIM)
|
|
set_source_files_properties(${src_1} ${src_2} ${hdr_1} ${hdr_2} PROPERTIES GENERATED TRUE)
|
|
list(APPEND GRPC_PROTO_SRCS ${src_1} ${src_2})
|
|
list(APPEND GRPC_PROTO_HDRS ${hdr_1} ${hdr_2})
|
|
endforeach()
|
|
|
|
add_library(grpc_pbufs STATIC ${GRPC_PROTO_SRCS} ${GRPC_PROTO_HDRS})
|
|
#target_include_directories(grpc_pbufs PRIVATE src)
|
|
target_include_directories(grpc_pbufs SYSTEM PUBLIC ${GRPC_GEN_DIR})
|
|
target_link_libraries(grpc_pbufs
|
|
"gRPC::grpc++"
|
|
# libgrpc is missing references.
|
|
absl::random_random
|
|
)
|
|
target_compile_options(grpc_pbufs
|
|
PRIVATE
|
|
$<$<BOOL:${MSVC}>:-wd4065>
|
|
$<$<NOT:$<BOOL:${MSVC}>>:-Wno-deprecated-declarations>
|
|
PUBLIC
|
|
$<$<BOOL:${MSVC}>:-wd4996>
|
|
$<$<BOOL:${XCODE}>:
|
|
--system-header-prefix="google/protobuf"
|
|
-Wno-deprecated-dynamic-exception-spec
|
|
>)
|
|
add_library(Ripple::grpc_pbufs ALIAS grpc_pbufs)
|