CMake: add option to enable address sanitizer

This commit is contained in:
Peter Kümmel 2014-08-10 10:35:56 +02:00
parent 3a78422782
commit 048571a2bf

View File

@ -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")