mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-24 04:41:53 +00:00
- Added support to GCC/Clang sanitizers.
This commit is contained in:
parent
e4c63563e3
commit
9575715b1e
1 changed files with 27 additions and 0 deletions
|
@ -452,6 +452,33 @@ if( ZD_CMAKE_COMPILER_IS_GNUCXX_COMPATIBLE )
|
|||
set( CMAKE_CXX_FLAGS_MINSIZEREL "${REL_CXX_FLAGS} ${CMAKE_CXX_FLAGS_MINSIZEREL}" )
|
||||
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "${REL_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}" )
|
||||
|
||||
# Support for the GCC/Clang sanitizers.
|
||||
set( WITH_ASAN 0 CACHE BOOL "Enable the Address Sanitizer")
|
||||
if( NOT CMAKE_COMPILER_IS_GNUCXX )
|
||||
set( WITH_MSAN 0 CACHE BOOL "Enable the Memory Sanitizer")
|
||||
endif( NOT CMAKE_COMPILER_IS_GNUCXX )
|
||||
set( WITH_UBSAN 0 CACHE BOOL "Enable the Undefined Behavior Sanitizer")
|
||||
if( WITH_MSAN )
|
||||
if ( WITH_ASAN OR WITH_UBSAN )
|
||||
message( SEND_ERROR "You can't use MSAN with either ASAN or UBSAN." )
|
||||
endif ( WITH_ASAN OR WITH_UBSAN )
|
||||
endif( WITH_MSAN )
|
||||
|
||||
set( SANITIZER_FLAG "" )
|
||||
if( WITH_ASAN )
|
||||
set( SANITIZER_FLAG "-fsanitize=address" )
|
||||
if ( WITH_UBSAN )
|
||||
set( SANITIZER_FLAG "${SANITIZER_FLAG},undefined" )
|
||||
endif( WITH_UBSAN )
|
||||
elseif( WITH_MSAN )
|
||||
set( SANITIZER_FLAG "-fsanitize=memory" )
|
||||
elseif( WITH_UBSAN )
|
||||
set( SANITIZER_FLAG "-fsanitize=undefined" )
|
||||
endif( WITH_ASAN )
|
||||
|
||||
set( CMAKE_CXX_FLAGS "${SANITIZER_FLAG} ${CMAKE_CXX_FLAGS}" )
|
||||
set( CMAKE_C_FLAGS "${SANITIZER_FLAG} ${CMAKE_C_FLAGS}" )
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.5")
|
||||
set( CMAKE_C_FLAGS "-Wno-unused-result ${CMAKE_C_FLAGS}" )
|
||||
set( CMAKE_CXX_FLAGS "-Wno-unused-result ${CMAKE_CXX_FLAGS}" )
|
||||
|
|
Loading…
Reference in a new issue