Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Anton3 committed Dec 13, 2023
1 parent 3dc1179 commit b57c8ef
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 24 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ cmake-build-*
Testing/
.DS_Store
Makefile.local
CmakeUserPresets.json
15 changes: 0 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
cmake_minimum_required(VERSION 3.12)
project(service_template CXX)

# 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)


# Adding userver dependency
include(third_party/userver/cmake/SetupEnvironment.cmake)
include(GNUInstallDirs)
add_subdirectory(third_party/userver)
Expand Down
85 changes: 85 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"version": 2,
"cmakeMinimumRequired": {
"major": 3,
"minor": 20,
"patch": 0
},
"configurePresets": [
{
"name": "debug",
"displayName": "Default Debug",
"description": "Fully featured Debug build, some platforms miss the required dependencies",
"inherits": [
"common-flags"
],
"binaryDir": "${sourceDir}/build_debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"USERVER_SANITIZE": "addr;ub"
}
},
{
"name": "compat-debug",
"displayName": "Compatibility-mode Debug",
"description": "Debug build with some features (e.g. sanitizers) disabled for compatibility",
"inherits": [
"compat-flags",
"common-flags"
],
"binaryDir": "${sourceDir}/build_debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "release",
"displayName": "Default Release",
"description": "Fully featured Release build, some platforms miss the required dependencies",
"inherits": [
"common-flags"
],
"binaryDir": "${sourceDir}/build_release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "compat-release",
"displayName": "Compatibility-mode Release",
"description": "Release build with some features disabled for compatibility",
"inherits": [
"common-flags",
"compat-flags"
],
"binaryDir": "${sourceDir}/build_release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "common-flags",
"hidden": true,
"generator": "Ninja",
"cacheVariables": {
"USERVER_FEATURE_MONGODB": "OFF",
"USERVER_FEATURE_POSTGRESQL": "OFF",
"USERVER_FEATURE_REDIS": "OFF",
"USERVER_FEATURE_CLICKHOUSE": "OFF",
"USERVER_FEATURE_GRPC": "OFF",
"USERVER_FEATURE_RABBITMQ": "OFF",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
},
{
"name": "compat-flags",
"hidden": true,
"generator": "Unix Makefiles",
"cacheVariables": {
"USERVER_FEATURE_CRYPTOPP_BLAKE2": "OFF",
"USERVER_FEATURE_GRPC_CHANNELZ": "OFF",
"USERVER_FEATURE_REDIS_HI_MALLOC": "ON"
}
}
]
}
14 changes: 5 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
CMAKE_COMMON_FLAGS ?= -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
CMAKE_DEBUG_FLAGS ?= -DUSERVER_SANITIZE='addr ub'
CMAKE_RELEASE_FLAGS ?=
DEBUG_PRESET ?= debug
RELEASE_PRESET ?= release
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 -B build_debug $(CMAKE_DEBUG_FLAGS)
cmake --preset $(DEBUG_PRESET)

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

build_debug/CMakeCache.txt: cmake-debug
build_release/CMakeCache.txt: cmake-release
Expand All @@ -44,7 +40,7 @@ test-debug test-release: test-%: build-%
# Start the service (via testsuite service runner)
.PHONY: service-start-debug service-start-release
service-start-debug service-start-release: service-start-%:
cmake --build build_$* -v --target=start-service_template
cmake --build build_$* -v --target start-service_template

# Cleanup data
.PHONY: clean-debug clean-release
Expand Down

0 comments on commit b57c8ef

Please sign in to comment.