86 lines
2 KiB
CMake
86 lines
2 KiB
CMake
cmake_minimum_required(VERSION 3.20)
|
|
|
|
project(gRPCTest C CXX)
|
|
|
|
# Options to build certain parts of the application
|
|
option(BUILD_CLIENT "Build the gRPC client." ON)
|
|
option(BUILD_SERVER "Build the gRPC server." ON)
|
|
|
|
# If you do not have gRPC isntalled through a package manager, you can set the custom install location here
|
|
# so CMake can find the libraries
|
|
set(GRPC_INSTALL_LOCATION "" CACHE PATH "Custom gRPC installation location.")
|
|
cmake_path(ABSOLUTE_PATH GRPC_INSTALL_LOCATION)
|
|
|
|
# set required C++ version
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
|
|
add_compile_options(-Wall
|
|
-Wextra
|
|
-Wconversion-null
|
|
-Wmissing-declarations
|
|
-Woverlength-strings)
|
|
add_compile_options(
|
|
-Wpointer-arith
|
|
-Wunused-local-typedefs
|
|
-Wunused-result
|
|
-Wvarargs
|
|
-Wvla
|
|
-Wwrite-strings
|
|
-Wformat-security
|
|
-Wundef)
|
|
add_compile_options(-O2)
|
|
|
|
# Find the protoc protobuffer compiler
|
|
find_program(_PROTOBUF_PROTOC protoc)
|
|
|
|
# Find the required gRPC libraries
|
|
# Since we have the option to link dynamically, we have to be explicit
|
|
find_library(
|
|
_PROTOBUF_LIBPROTOBUF
|
|
protobuf
|
|
HINTS ${GRPC_INSTALL_LOCATION}/lib/
|
|
REQUIRED
|
|
)
|
|
find_library(
|
|
_GRPC_GRPCPP_REFLECTION
|
|
grpc++_reflection
|
|
HINTS ${GRPC_INSTALL_LOCATION}/lib/
|
|
REQUIRED
|
|
)
|
|
find_library(
|
|
_GRPC_GRPCPP
|
|
grpc++
|
|
HINTS ${GRPC_INSTALL_LOCATION}/lib/
|
|
REQUIRED
|
|
)
|
|
find_library(
|
|
_GRPC_GRPC
|
|
grpc
|
|
HINTS ${GRPC_INSTALL_LOCATION}/lib/
|
|
REQUIRED
|
|
)
|
|
find_library(
|
|
_GRPC_GPR
|
|
gpr
|
|
HINTS ${GRPC_INSTALL_LOCATION}/lib/
|
|
REQUIRED
|
|
)
|
|
|
|
# Configure the location of the gRPC protoc plugin
|
|
find_program(_GRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin)
|
|
|
|
# gRPC uses the Abseil package
|
|
find_package(absl REQUIRED)
|
|
|
|
# Include the protobuffers
|
|
add_subdirectory(buffers)
|
|
|
|
# Include the client
|
|
if(BUILD_CLIENT)
|
|
add_subdirectory(client)
|
|
endif(BUILD_CLIENT)
|
|
|
|
# Include the controller server
|
|
if(BUILD_SERVER)
|
|
add_subdirectory(controller)
|
|
endif(BUILD_SERVER)
|