Skip to content

Commit

Permalink
cmake: Allow to build clazy with ASAN/UBSAN
Browse files Browse the repository at this point in the history
For clazy's own development only
  • Loading branch information
Sergio Martins committed Oct 30, 2021
1 parent 854f340 commit c4b3f46
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
12 changes: 12 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
"CMAKE_EXPORT_COMPILE_COMMANDS" : "ON"
}
},
{
"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",
Expand Down

0 comments on commit c4b3f46

Please sign in to comment.