diff --git a/.gitignore b/.gitignore index c631f25..9e986f8 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ cmake-build-* Testing/ .DS_Store Makefile.local +CmakeUserPresets.json diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..8c2e68d --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,81 @@ +{ + "version": 2, + "cmakeMinimumRequired": { + "major": 3, + "minor": 20, + "patch": 0 + }, + "configurePresets": [ + { + "name": "debug", + "displayName": "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": "release", + "displayName": "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-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": "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": { + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", + "CMAKE_C_COMPILER": "cc", + "CMAKE_CXX_COMPILER": "c++" + } + }, + { + "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" + } + } + ] +} diff --git a/Makefile b/Makefile index 234880f..e9725c5 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CMAKE_COMMON_FLAGS ?= -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -CMAKE_DEBUG_FLAGS ?= -DUSERVER_SANITIZE='addr ub' -CMAKE_RELEASE_FLAGS ?= +CMAKE_DEBUG_FLAGS ?= --preset debug +CMAKE_RELEASE_FLAGS ?= --preset release NPROCS ?= $(shell nproc) CLANG_FORMAT ?= clang-format DOCKER_COMPOSE ?= docker-compose @@ -42,7 +42,7 @@ test-debug test-release: test-%: build-% # Start the service (via testsuite service runner) .PHONY: start-debug start-release start-debug start-release: start-%: - cmake --build build_$* -v --target=start-service_template + cmake --build build_$* -v --target start-service_template .PHONY: service-start-debug service-start-release service-start-debug service-start-release: service-start-%: start-% diff --git a/cmake/DownloadUserver.cmake b/cmake/DownloadUserver.cmake index 83cc000..390533a 100644 --- a/cmake/DownloadUserver.cmake +++ b/cmake/DownloadUserver.cmake @@ -8,17 +8,25 @@ function(download_userver) ARG "${OPTIONS}" "${ONE_VALUE_ARGS}" "${MULTI_VALUE_ARGS}" ${ARGN} ) - if(ARG_TRY_DIR AND EXISTS "${ARG_TRY_DIR}") - message(STATUS "Using userver from ${ARG_TRY_DIR}") - add_subdirectory("${ARG_TRY_DIR}") - return() + if(ARG_TRY_DIR) + get_filename_component(ARG_TRY_DIR "${ARG_TRY_DIR}" REALPATH) + if(EXISTS "${ARG_TRY_DIR}") + message(STATUS "Using userver from ${ARG_TRY_DIR}") + add_subdirectory("${ARG_TRY_DIR}" third_party/userver) + return() + endif() endif() + include(get_cpm) + if(NOT DEFINED ARG_VERSION AND NOT DEFINED ARG_GIT_TAG) set(ARG_GIT_TAG develop) endif() - include(get_cpm) + if(NOT DEFINED CPM_USE_NAMED_CACHE_DIRECTORIES) + set(CPM_USE_NAMED_CACHE_DIRECTORIES ON) + endif() + CPMAddPackage( NAME userver GITHUB_REPOSITORY userver-framework/userver