CMake: Add ENABLE_ASAN options to build with address sanitizer
This commit is contained in:
parent
ebb556a866
commit
b963450b45
|
|
@ -51,6 +51,16 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GCC")
|
|||
|
||||
endif()
|
||||
|
||||
# AddressSanitizer
|
||||
if(ENABLE_ASAN)
|
||||
if(CMAKE_CXX_COMPILER_ID MATCHES "(AppleClang|Clang|GNU)")
|
||||
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
|
||||
add_link_options(-fsanitize=address)
|
||||
else()
|
||||
message(FATAL_ERROR "ENABLE_ASAN requires GCC or Clang")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Panda3D is now a C++14 project.
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
|
|
|||
|
|
@ -425,6 +425,14 @@ endif()
|
|||
|
||||
unset(_prefer_mimalloc)
|
||||
|
||||
#
|
||||
# Sanitizers
|
||||
#
|
||||
|
||||
option(ENABLE_ASAN
|
||||
"Enable AddressSanitizer for detecting memory errors such as
|
||||
buffer overflows, use-after-free, etc. Requires GCC or Clang." OFF)
|
||||
|
||||
#
|
||||
# This section relates to mobile-device/phone support and options
|
||||
#
|
||||
|
|
|
|||
Loading…
Reference in New Issue