Moving ASAN macros and calls to macros above the information output section so we can display ASAN information properly.
parent
f88d91d596
commit
320666044e
116
CMakeLists.txt
116
CMakeLists.txt
|
@ -2302,6 +2302,64 @@ Libs.private:")
|
||||||
"${SDL2_BINARY_DIR}/SDL2.spec" @ONLY)
|
"${SDL2_BINARY_DIR}/SDL2.spec" @ONLY)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
macro(check_add_debug_flag FLAG SUFFIX)
|
||||||
|
check_c_compiler_flag(${FLAG} HAS_C_FLAG_${SUFFIX})
|
||||||
|
if (HAS_C_FLAG_${SUFFIX})
|
||||||
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${FLAG}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
check_cxx_compiler_flag(${FLAG} HAS_CXX_${SUFFIX})
|
||||||
|
if (HAS_CXX_${SUFFIX})
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${FLAG}")
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
macro(asan_check_add_debug_flag ASAN_FLAG)
|
||||||
|
check_add_debug_flag("-fsanitize=${ASAN_FLAG}" "${ASAN_FLAG}")
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
macro(asan_check_add_debug_flag2 ASAN_FLAG)
|
||||||
|
# for some sanitize flags we have to manipulate the CMAKE_REQUIRED_LIBRARIES:
|
||||||
|
# http://cmake.3232098.n2.nabble.com/CHECK-CXX-COMPILER-FLAG-doesn-t-give-correct-result-for-fsanitize-address-tp7600216p7600217.html
|
||||||
|
|
||||||
|
set(FLAG "-fsanitize=${ASAN_FLAG}")
|
||||||
|
|
||||||
|
set (STORED_REQLIBS ${CMAKE_REQUIRED_LIBRARIES})
|
||||||
|
set (CMAKE_REQUIRED_LIBRARIES "${FLAG};asan")
|
||||||
|
check_c_compiler_flag (${FLAG} HAS_C_FLAG_${ASAN_FLAG})
|
||||||
|
check_cxx_compiler_flag (${FLAG} HAS_CXX_FLAG_${ASAN_FLAG})
|
||||||
|
set (CMAKE_REQUIRED_LIBRARIES ${STORED_REQLIBS})
|
||||||
|
|
||||||
|
if (HAS_C_FLAG_${ASAN_FLAG})
|
||||||
|
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${FLAG}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (HAS_CXX_${ASAN_FLAG})
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${FLAG}")
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
# enable AddressSanitizer if supported
|
||||||
|
if (ASAN)
|
||||||
|
asan_check_add_debug_flag2("address")
|
||||||
|
asan_check_add_debug_flag("bool")
|
||||||
|
asan_check_add_debug_flag("bounds")
|
||||||
|
asan_check_add_debug_flag("enum")
|
||||||
|
asan_check_add_debug_flag("float-cast-overflow")
|
||||||
|
asan_check_add_debug_flag("float-divide-by-zero")
|
||||||
|
asan_check_add_debug_flag("nonnull-attribute")
|
||||||
|
asan_check_add_debug_flag("returns-nonnull-attribute")
|
||||||
|
asan_check_add_debug_flag("signed-integer-overflow")
|
||||||
|
asan_check_add_debug_flag("undefined")
|
||||||
|
asan_check_add_debug_flag("vla-bound")
|
||||||
|
asan_check_add_debug_flag("leak")
|
||||||
|
# The object size sanitizer has no effect on unoptimized builds on Clang,
|
||||||
|
# but causes warnings.
|
||||||
|
if((NOT USE_CLANG) OR (CMAKE_BUILD_TYPE STREQUAL ""))
|
||||||
|
asan_check_add_debug_flag("object-size")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
##### Info output #####
|
##### Info output #####
|
||||||
message(STATUS "")
|
message(STATUS "")
|
||||||
message(STATUS "SDL2 was configured with the following options:")
|
message(STATUS "SDL2 was configured with the following options:")
|
||||||
|
@ -2478,64 +2536,6 @@ if(SDL_STATIC)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
macro(check_add_debug_flag FLAG SUFFIX)
|
|
||||||
check_c_compiler_flag(${FLAG} HAS_C_FLAG_${SUFFIX})
|
|
||||||
if (HAS_C_FLAG_${SUFFIX})
|
|
||||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${FLAG}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
check_cxx_compiler_flag(${FLAG} HAS_CXX_${SUFFIX})
|
|
||||||
if (HAS_CXX_${SUFFIX})
|
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${FLAG}")
|
|
||||||
endif()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
macro(asan_check_add_debug_flag ASAN_FLAG)
|
|
||||||
check_add_debug_flag("-fsanitize=${ASAN_FLAG}" "${ASAN_FLAG}")
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
macro(asan_check_add_debug_flag2 ASAN_FLAG)
|
|
||||||
# for some sanitize flags we have to manipulate the CMAKE_REQUIRED_LIBRARIES:
|
|
||||||
# http://cmake.3232098.n2.nabble.com/CHECK-CXX-COMPILER-FLAG-doesn-t-give-correct-result-for-fsanitize-address-tp7600216p7600217.html
|
|
||||||
|
|
||||||
set(FLAG "-fsanitize=${ASAN_FLAG}")
|
|
||||||
|
|
||||||
set (STORED_REQLIBS ${CMAKE_REQUIRED_LIBRARIES})
|
|
||||||
set (CMAKE_REQUIRED_LIBRARIES "${FLAG};asan")
|
|
||||||
check_c_compiler_flag (${FLAG} HAS_C_FLAG_${ASAN_FLAG})
|
|
||||||
check_cxx_compiler_flag (${FLAG} HAS_CXX_FLAG_${ASAN_FLAG})
|
|
||||||
set (CMAKE_REQUIRED_LIBRARIES ${STORED_REQLIBS})
|
|
||||||
|
|
||||||
if (HAS_C_FLAG_${ASAN_FLAG})
|
|
||||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${FLAG}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if (HAS_CXX_${ASAN_FLAG})
|
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${FLAG}")
|
|
||||||
endif()
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
# enable AddressSanitizer if supported
|
|
||||||
if (ASAN)
|
|
||||||
asan_check_add_debug_flag2("address")
|
|
||||||
asan_check_add_debug_flag("bool")
|
|
||||||
asan_check_add_debug_flag("bounds")
|
|
||||||
asan_check_add_debug_flag("enum")
|
|
||||||
asan_check_add_debug_flag("float-cast-overflow")
|
|
||||||
asan_check_add_debug_flag("float-divide-by-zero")
|
|
||||||
asan_check_add_debug_flag("nonnull-attribute")
|
|
||||||
asan_check_add_debug_flag("returns-nonnull-attribute")
|
|
||||||
asan_check_add_debug_flag("signed-integer-overflow")
|
|
||||||
asan_check_add_debug_flag("undefined")
|
|
||||||
asan_check_add_debug_flag("vla-bound")
|
|
||||||
asan_check_add_debug_flag("leak")
|
|
||||||
# The object size sanitizer has no effect on unoptimized builds on Clang,
|
|
||||||
# but causes warnings.
|
|
||||||
if((NOT USE_CLANG) OR (CMAKE_BUILD_TYPE STREQUAL ""))
|
|
||||||
asan_check_add_debug_flag("object-size")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
##### Tests #####
|
##### Tests #####
|
||||||
|
|
||||||
if(SDL_TEST)
|
if(SDL_TEST)
|
||||||
|
|
Loading…
Reference in New Issue