1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-09-27 22:58:24 +00:00

Add address sanitized build target

Update the Volk build types to include a target that compiles with
-fsanitize=address when using clang or gcc.
Activated with -DCMAKE_BUILD_TYPE=ASAN
This commit is contained in:
Carles Fernandez 2018-08-12 10:59:12 +02:00
parent ecdd5f4e57
commit 1087b764cf
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D

View File

@ -38,6 +38,7 @@ set(__INCLUDED_VOLK_BUILD_TYPES_CMAKE TRUE)
list(APPEND AVAIL_BUILDTYPES
None Debug Release RelWithDebInfo MinSizeRel
DebugParanoid NoOptWithASM O2WithASM O3WithASM
ASAN
)
########################################################################
@ -185,3 +186,25 @@ if(NOT WIN32)
CMAKE_EXE_LINKER_FLAGS_O3WITHASM
CMAKE_SHARED_LINKER_FLAGS_O3WITHASM)
endif(NOT WIN32)
########################################################################
# For GCC and Clang, we can set a build type:
#
# -DCMAKE_BUILD_TYPE=ASAN
#
# This type creates an address sanitized build (-fsanitize=address)
# and defaults to the DebugParanoid linker flags.
# NOTE: This is not defined on Windows systems.
########################################################################
if(NOT WIN32)
SET(CMAKE_CXX_FLAGS_ASAN "-Wall -Wextra -g -O2 -fsanitize=address -fno-omit-frame-pointer" CACHE STRING
"Flags used by the C++ compiler during Address Sanitized builds." FORCE)
SET(CMAKE_C_FLAGS_ASAN "-Wall -Wextra -g -O2 -fsanitize=address -fno-omit-frame-pointer" CACHE STRING
"Flags used by the C compiler during Address Sanitized builds." FORCE)
MARK_AS_ADVANCED(
CMAKE_CXX_FLAGS_ASAN
CMAKE_C_FLAGS_ASAN
CMAKE_EXE_LINKER_FLAGS_DEBUGPARANOID
CMAKE_SHARED_LINKER_DEBUGPARANOID)
endif(NOT WIN32)