From b448f5b8dec6df6ae1f08fc5828694dc24641662 Mon Sep 17 00:00:00 2001 From: Milian Wolff Date: Sat, 18 Jun 2022 18:33:34 +0200 Subject: [PATCH] Add CMakePresets.json including configuration for sanitizers Only works with modern CMake versions that support the cmake presets version 3 or higher, i.e. CMake 3.21 or newer. --- .clang-format | 4 ++- CMakePresets.json | 71 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 CMakePresets.json diff --git a/.clang-format b/.clang-format index d95ddd19..f33ff8d9 100644 --- a/.clang-format +++ b/.clang-format @@ -47,4 +47,6 @@ BinPackParameters: true #MacroBlockBegin: BEGINTESTFUNCIMPL #MacroBlockEnd: ENDTESTFUNCIMPL ... - +--- +Language: Json +DisableFormat: true diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 00000000..43f2af61 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,71 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "dev", + "displayName": "dev", + "description": "Preset for developers", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build-${presetName}", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" + } + }, + { + "name": "asan", + "cacheVariables": { + "CMAKE_CXX_FLAGS_DEBUG": "-g -fsanitize=address,undefined", + "CMAKE_C_FLAGS_DEBUG": "-g -fsanitize=address,undefined" + } + }, + { + "name": "dev-asan", + "displayName": "dev with sanitizers", + "description": "Preset for developers with asan and ubsan enabled", + "inherits": [ + "dev", + "asan" + ] + }, + { + "name": "dev-opt", + "displayName": "dev with optimizations", + "description": "Preset for developers with compiler optimizations enabled", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "CMAKE_CXX_FLAGS" : "-DQT_FORCE_ASSERTS -DQT_MESSAGELOGCONTEXT" + }, + "inherits": [ + "dev" + ] + }, + { + "name": "dev-opt-asan", + "displayName": "dev with optimizations and sanitizers", + "description": "Preset for developers with compiler optimizations and sanitizers enabled", + "inherits": [ + "dev-opt", + "asan" + ] + } + ], + "buildPresets": [ + { + "name": "dev", + "configurePreset": "dev" + }, + { + "name": "dev-asan", + "configurePreset": "dev-asan" + }, + { + "name": "dev-opt", + "configurePreset": "dev-opt" + }, + { + "name": "dev-opt-asan", + "configurePreset": "dev-opt-asan" + } + ] +}