diff --git a/CMakeLists.txt b/CMakeLists.txt index faca0ced81..74ed869dc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -119,6 +119,7 @@ LYX_OPTION(INSTALL_PREFIX "Install path for LyX" OFF ALL) LYX_OPTION(BUNDLE "Build bundle (experimental) " OFF ALL) LYX_OPTION(ENABLE_URLTESTS "Enable for URL tests" OFF ALL) LYX_OPTION(ENABLE_EXPORT_TESTS "Enable for export tests" OFF ALL) +LYX_OPTION(ASAN "Use address sanitizer" OFF ALL) # GCC specific LYX_OPTION(PROFILE "Build profile version" OFF GCC) @@ -514,7 +515,7 @@ if(NOT MSVC) if(NOT LYX_QUIET) set(CMAKE_VERBOSE_MAKEFILE ON) endif() - set(LYX_CXX_FLAGS "-Wall -Wunused-parameter ${LYX_GCC11_MODE}") + set(LYX_CXX_FLAGS "-Wall -Wunused-parameter ${LYX_GCC11_MODE}") if(LYX_STDLIB_DEBUG) set(LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC") endif() @@ -824,6 +825,15 @@ endif () add_custom_target (lyx_run_tests COMMAND ${cmd}) set_target_properties(lyx_run_tests PROPERTIES FOLDER "tests") +if(LYX_ASAN) + set(LYX_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -g") + message(STATUS) + message(STATUS "Address sanitizer enabled. Usage:") + message(STATUS " wget https://llvm.org/svn/llvm-project/compiler-rt/trunk/lib/asan/scripts/asan_symbolize.py") + message(STATUS " chmod +x ./asan_symbolize.py") + message(STATUS " ./bin/lyx2.2 2>&1 | ./asan_symbolize.py | c++filt ") + message(STATUS) +endif() if(LYX_INSTALL) if(${LYX_PYTHON_EXECUTABLE} MATCHES "-NOTFOUND")