Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton3 committed Dec 14, 2023
1 parent b57c8ef commit e01ec7f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
24 changes: 24 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
cmake_minimum_required(VERSION 3.12)
project(service_template CXX)


# This option is disabled when using CMake presets
option(
SERVICE_TEMPLATE_OVERRIDES
"Use hardcoded overrides for userver options from the service template"
ON
)
if(SERVICE_TEMPLATE_OVERRIDES)
# Disable userver libraries that are not needed in this project
set(USERVER_FEATURE_MONGODB OFF CACHE BOOL "" FORCE)
set(USERVER_FEATURE_POSTGRESQL OFF CACHE BOOL "" FORCE)
set(USERVER_FEATURE_REDIS OFF CACHE BOOL "" FORCE)
set(USERVER_FEATURE_CLICKHOUSE OFF CACHE BOOL "" FORCE)
set(USERVER_FEATURE_GRPC OFF CACHE BOOL "" FORCE)
set(USERVER_FEATURE_RABBITMQ OFF CACHE BOOL "" FORCE)

# Compatibility mode: some systems don't support these features
set(USERVER_FEATURE_CRYPTOPP_BLAKE2 OFF CACHE BOOL "" FORCE)
set(USERVER_FEATURE_GRPC_CHANNELZ OFF CACHE BOOL "" FORCE)
set(USERVER_FEATURE_REDIS_HI_MALLOC ON CACHE BOOL "" FORCE)
endif()


# Adding userver dependency
include(third_party/userver/cmake/SetupEnvironment.cmake)
include(GNUInstallDirs)
add_subdirectory(third_party/userver)
Expand Down
1 change: 1 addition & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"hidden": true,
"generator": "Ninja",
"cacheVariables": {
"SERVICE_TEMPLATE_OVERRIDES": "OFF",
"USERVER_FEATURE_MONGODB": "OFF",
"USERVER_FEATURE_POSTGRESQL": "OFF",
"USERVER_FEATURE_REDIS": "OFF",
Expand Down
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
DEBUG_PRESET ?= debug
RELEASE_PRESET ?= release
CMAKE_COMMON_FLAGS ?= -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
CMAKE_DEBUG_FLAGS ?= -DUSERVER_SANITIZE='addr ub'
CMAKE_RELEASE_FLAGS ?=
NPROCS ?= $(shell nproc)
CLANG_FORMAT ?= clang-format
DOCKER_COMPOSE ?= docker-compose

# NOTE: use Makefile.local to override the options defined above.
-include Makefile.local

CMAKE_DEBUG_FLAGS += -DCMAKE_BUILD_TYPE=Debug $(CMAKE_COMMON_FLAGS)
CMAKE_RELEASE_FLAGS += -DCMAKE_BUILD_TYPE=Release $(CMAKE_COMMON_FLAGS)

.PHONY: all
all: test-debug test-release

# Run cmake
.PHONY: cmake-debug
cmake-debug:
git submodule update --init
cmake --preset $(DEBUG_PRESET)
cmake -B build_debug $(CMAKE_DEBUG_FLAGS)

.PHONY: cmake-release
cmake-release:
git submodule update --init
cmake --preset $(RELEASE_PRESET)
cmake -B build_release $(CMAKE_RELEASE_FLAGS)

build_debug/CMakeCache.txt: cmake-debug
build_release/CMakeCache.txt: cmake-release
Expand Down

0 comments on commit e01ec7f

Please sign in to comment.