Cmake build: Unify use of sanitizer

The configuration variable is LYX_DEBUG_SANITIZE
which can have following values:
"NONE"
"ADDRESS" Use address sanitizer (previously used with the variable LYX_ASAN)
"UNSPECIFIED" Use unspecified sanitizer
This commit is contained in:
Kornel Benko 2021-09-21 11:27:13 +02:00
parent ffa1b1dcc7
commit 4f46c22d03

View File

@ -217,7 +217,7 @@ else()
unset(LYX_ENABLE_VALGRIND_TESTS CACHE)
endif()
endif()
LYX_OPTION(ASAN "Use address sanitizer" OFF ALL)
LYX_COMBO(DEBUG_SANITIZE "Use sanitize check" NONE ADDRESS UNSPECIFIED)
#LYX_COMBO(USE_FILEDIALOG "Use native or QT file dialog" QT NATIVE)
LYX_COMBO(USE_QT "Use Qt version as frontend" AUTO QT4 QT5 QT6)
LYX_COMBO(USE_IPO "Interprocedural optimization" OFF AUTO ON)
@ -674,6 +674,19 @@ else()
set(LYX_CXX_FLAGS "")
endif()
if (LYX_DEBUG_SANITIZE MATCHES "ADDRESS")
set(LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
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)
elseif (LYX_DEBUG_SANITIZE MATCHES "UNSPECIFIED")
set(LYX_CXX_FLAGS "${LYX_CXX_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer")
endif()
if(MSVC)
if (CXX11_FLAG MATCHES "\\+\\+([0-9]+)")
set(CMAKE_CXX_STANDARD ${CMAKE_MATCH_1})
@ -726,16 +739,6 @@ else()
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'")
mark_as_advanced(LYX_CXX_FLAGS_EXTRA)
if(LYX_CXX_FLAGS_EXTRA)