diff options
author | Sergio Martins <smartins@kde.org> | 2021-10-30 18:04:33 +0100 |
---|---|---|
committer | Sergio Martins <smartins@kde.org> | 2021-10-30 18:04:33 +0100 |
commit | c4b3f46af893e7f9067c6f4c63c901af52edfe6c (patch) | |
tree | 555a6936f3ad31ccd355196b15e0d1a3c5679267 | |
parent | 854f3408dfc9d2d96d2a9bda46660e2074315d6c (diff) |
cmake: Allow to build clazy with ASAN/UBSAN
For clazy's own development only
-rw-r--r-- | CMakeLists.txt | 8 | ||||
-rw-r--r-- | CMakePresets.json | 12 |
2 files changed, 20 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e649bfe..6daa6f82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,14 @@ option(CLAZY_AST_MATCHERS_CRASH_WORKAROUND "Disable AST Matchers if being built option(LINK_CLAZY_TO_LLVM "Links the clazy plugin to LLVM. Switch to OFF if your clang binary has all symbols already. Might need to be OFF if your LLVM is static." ON) option(APPIMAGE_HACK "Links the clazy plugin to the clang tooling libs only. For some reason this is needed when building on our old CentOS 6.8 to create the AppImage." OFF) option(CLAZY_MAN_PAGE "Builds the man page." ON) +option(CLAZY_ENABLE_SANITIZERS "Builds clazy with ASAN/UBSAN. For clazy's own development only." OFF) + +if (CLAZY_ENABLE_SANITIZERS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") + if (NOT MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined") + endif() +endif() if (CLAZY_AST_MATCHERS_CRASH_WORKAROUND AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") message("Enabling AST Matchers workaround. Consider building with gcc instead. See bug #392223.") diff --git a/CMakePresets.json b/CMakePresets.json index f1ec4772..6e0071f7 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -13,6 +13,18 @@ } }, { + "name": "dev-asan", + "displayName": "dev-asan", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build-dev-asan", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CLAZY_MAN_PAGE" : "OFF", + "CMAKE_EXPORT_COMPILE_COMMANDS" : "ON", + "CLAZY_ENABLE_SANITIZERS" : "ON" + } + }, + { "name": "profile", "displayName": "profile", "generator": "Ninja", |