Cmake build: Re-enable address sanitizer

Moved code because:
1.) Setting of LYX_CXX_FLAGS only has no effect,
2.) and setting of CMAKE_CXX_FLAGS was to late.
This commit is contained in:
Kornel Benko 2020-07-15 14:24:49 +02:00
parent 3b6fec3835
commit 5529172fa1

View File

@ -711,6 +711,16 @@ else()
endif() endif()
endif() endif()
if(LYX_ASAN)
set(CMAKE_CXX_FLAGS "-fsanitize=address -fno-omit-frame-pointer -g ${CMAKE_CXX_FLAGS}")
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/${_lyx} 2>&1 | ./asan_symbolize.py | c++filt ")
message(STATUS)
endif()
set(LYX_CXX_FLAGS_EXTRA "" CACHE STRING "Desired semicolon separated list of extra cxx compile flags, like '-Werror'") set(LYX_CXX_FLAGS_EXTRA "" CACHE STRING "Desired semicolon separated list of extra cxx compile flags, like '-Werror'")
mark_as_advanced(LYX_CXX_FLAGS_EXTRA) mark_as_advanced(LYX_CXX_FLAGS_EXTRA)
if(LYX_CXX_FLAGS_EXTRA) if(LYX_CXX_FLAGS_EXTRA)
@ -1168,16 +1178,6 @@ endif ()
add_custom_target (lyx_run_tests COMMAND ${cmd}) add_custom_target (lyx_run_tests COMMAND ${cmd})
set_target_properties(lyx_run_tests PROPERTIES FOLDER "tests") 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_INSTALL)
if(${LYX_PYTHON_EXECUTABLE} MATCHES "-NOTFOUND") if(${LYX_PYTHON_EXECUTABLE} MATCHES "-NOTFOUND")
message(STATUS "Python required to create doc!") message(STATUS "Python required to create doc!")