diff options
author | Vojtech Kral <vojtech@kral.hk> | 2018-11-07 17:23:00 +0300 |
---|---|---|
committer | Vojtech Kral <vojtech@kral.hk> | 2018-11-07 19:38:08 +0300 |
commit | 8c4fa9ba51e93c8e0b9da6671c5c6cedd58b9cc4 (patch) | |
tree | d38c1c8a0dce4e36c4861ae485dd3423de00745b /CMakeLists.txt | |
parent | 377350db33a7bb8f5bc8b8fa37044a1ae9745120 (diff) |
CMake: Add ASan option
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0656b824e..bcdb67684 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,6 +26,7 @@ option(SLIC3R_PROFILE "Compile Slic3r with an invasive Shiny profiler" 0) option(SLIC3R_MSVC_COMPILE_PARALLEL "Compile on Visual Studio in parallel" 1) option(SLIC3R_MSVC_PDB "Generate PDB files on MSVC in Release mode" 1) option(SLIC3R_PERL_XS "Compile XS Perl module and enable Perl unit and integration tests" 0) +option(SLIC3R_ASAN "Enable ASan on Clang and GCC" 0) if (MSVC) if (SLIC3R_MSVC_COMPILE_PARALLEL) @@ -89,6 +90,13 @@ endif() if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # On GCC and Clang, no return from a non-void function is a warning only. Here, we make it an error. add_compile_options(-Werror=return-type) + + if (SLIC3R_ASAN) + add_compile_options(-fsanitize=address -fno-omit-frame-pointer) + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lasan") + endif () + endif () endif() # Where all the bundled libraries reside? |