From 90c3e637458e0b51ef47dd260351870b5a472357 Mon Sep 17 00:00:00 2001 From: Anton Zhilin Date: Thu, 28 Dec 2023 19:26:12 +0300 Subject: [PATCH] feat cmake: up userver (#29) --- CMakeLists.txt | 22 +++++++++++----------- third_party/userver | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12bc2e8..1c7eba1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,9 @@ cmake_minimum_required(VERSION 3.12) project(pg_grpc_service_template CXX) -# Disable userver libraries that are not needed in this project -set(USERVER_FEATURE_MONGODB OFF CACHE BOOL "" FORCE) -set(USERVER_FEATURE_REDIS OFF CACHE BOOL "" FORCE) -set(USERVER_FEATURE_CLICKHOUSE OFF CACHE BOOL "" FORCE) -set(USERVER_FEATURE_RABBITMQ OFF CACHE BOOL "" FORCE) +# Enable userver libraries that are needed in this project +set(USERVER_FEATURE_POSTGRESQL ON CACHE BOOL "" FORCE) +set(USERVER_FEATURE_GRPC ON CACHE BOOL "" FORCE) # Compatibility mode: some systems don't support these features set(USERVER_FEATURE_CRYPTOPP_BLAKE2 OFF CACHE BOOL "" FORCE) @@ -14,9 +12,8 @@ set(USERVER_FEATURE_REDIS_HI_MALLOC ON CACHE BOOL "" FORCE) # Adding userver dependency -include(third_party/userver/cmake/SetupEnvironment.cmake) -include(GNUInstallDirs) add_subdirectory(third_party/userver) +userver_setup_environment() # Common sources @@ -26,11 +23,12 @@ add_library(${PROJECT_NAME}_objs OBJECT src/hello_client.hpp src/hello_client.cpp ) -# Grpc enable -include(GrpcTargets) -add_grpc_library(${PROJECT_NAME}_proto PROTOS handlers/hello.proto) +target_link_libraries(${PROJECT_NAME}_objs PUBLIC userver-postgresql) -target_link_libraries(${PROJECT_NAME}_objs PUBLIC userver-postgresql ${PROJECT_NAME}_proto) +# Create a proto library with userver extensions +include(GrpcTargets) +userver_add_grpc_library(${PROJECT_NAME}_proto PROTOS handlers/hello.proto) +target_link_libraries(${PROJECT_NAME}_objs PUBLIC ${PROJECT_NAME}_proto) # The Service @@ -61,6 +59,8 @@ userver_testsuite_add_simple() # Install +include(GNUInstallDirs) + if(DEFINED ENV{PREFIX}) message(STATUS "Set install prefix: $ENV{PREFIX}") file(TO_CMAKE_PATH "$ENV{PREFIX}" PREFIX_PATH) diff --git a/third_party/userver b/third_party/userver index 06b5dfa..320656f 160000 --- a/third_party/userver +++ b/third_party/userver @@ -1 +1 @@ -Subproject commit 06b5dfa5c7951c956c3f3ed5d737a50c88c68f62 +Subproject commit 320656f015cef1a0e91a714dcb41aa543c97631f