mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-26 07:17:23 +00:00
[host] cmake: add ubsan and asan to CMake (needs clang64 on windows)
Note that this still is a pain to make work as you require the MS runtime DLLs, and to build with clang64.
This commit is contained in:
parent
a391e271c3
commit
c05282c38c
@ -29,6 +29,12 @@ include(UninstallTarget)
|
|||||||
option(ENABLE_BACKTRACE "Enable backtrace support on crash" ON)
|
option(ENABLE_BACKTRACE "Enable backtrace support on crash" ON)
|
||||||
add_feature_info(ENABLE_BACKTRACE ENABLE_BACKTRACE "Backtrace support.")
|
add_feature_info(ENABLE_BACKTRACE ENABLE_BACKTRACE "Backtrace support.")
|
||||||
|
|
||||||
|
option(ENABLE_ASAN "Build with AddressSanitizer" OFF)
|
||||||
|
add_feature_info(ENABLE_ASAN ENABLE_ASAN "AddressSanitizer support.")
|
||||||
|
|
||||||
|
option(ENABLE_UBSAN "Build with UndefinedBehaviorSanitizer" OFF)
|
||||||
|
add_feature_info(ENABLE_UBSAN ENABLE_UBSAN "UndefinedBehaviorSanitizer support.")
|
||||||
|
|
||||||
add_compile_options(
|
add_compile_options(
|
||||||
"-Wall"
|
"-Wall"
|
||||||
"-Werror"
|
"-Werror"
|
||||||
@ -44,6 +50,16 @@ if(WIN32)
|
|||||||
add_compile_options("-fdebug-prefix-map=${PROJECT_TOP}/=")
|
add_compile_options("-fdebug-prefix-map=${PROJECT_TOP}/=")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_ASAN)
|
||||||
|
add_compile_options("-fno-omit-frame-pointer" "-fsanitize=address")
|
||||||
|
set(EXE_FLAGS "${EXE_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_UBSAN)
|
||||||
|
add_compile_options("-fsanitize=undefined")
|
||||||
|
set(EXE_FLAGS "${EXE_FLAGS} -fsanitize=undefined")
|
||||||
|
endif()
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
OUTPUT ${CMAKE_BINARY_DIR}/version.c
|
OUTPUT ${CMAKE_BINARY_DIR}/version.c
|
||||||
${CMAKE_BINARY_DIR}/include/version.h
|
${CMAKE_BINARY_DIR}/include/version.h
|
||||||
@ -60,6 +76,12 @@ include_directories(
|
|||||||
#link_libraries(
|
#link_libraries(
|
||||||
#)
|
#)
|
||||||
|
|
||||||
|
if (ENABLE_ASAN OR ENABLE_UBSAN)
|
||||||
|
link_directories("c:/msys64/clang64/lib/clang/12.0.0/lib/windows")
|
||||||
|
link_libraries(clang_rt.asan_dynamic-x86_64 clang_rt.asan_dynamic_runtime_thunk-x86_64)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
${CMAKE_BINARY_DIR}/version.c
|
${CMAKE_BINARY_DIR}/version.c
|
||||||
src/app.c
|
src/app.c
|
||||||
|
Loading…
Reference in New Issue
Block a user