Show fewer warnings for targets.
Instead of printing the same message over and over again, if a target can't use a specific sanitizer, the message will be printed only once for the first affected target now.
This commit is contained in:
parent
37d5ac8067
commit
a1bee9b178
@ -53,7 +53,32 @@ function(sanitizer_add_blacklist_file FILE)
|
|||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(add_sanitizers ...)
|
function(add_sanitizers ...)
|
||||||
|
# If no sanitizer is enabled, return immediately.
|
||||||
|
if (NOT (SANITZE_ADDRESS OR SANITIZE_MEMORY OR SANITIZE_THREAD OR
|
||||||
|
SANITIZE_UNDEFINED))
|
||||||
|
return()
|
||||||
|
endif ()
|
||||||
|
|
||||||
foreach (TARGET ${ARGV})
|
foreach (TARGET ${ARGV})
|
||||||
|
# Check if this target will be compiled by exactly one compiler. Other-
|
||||||
|
# wise sanitizers can't be used and a warning should be printed once.
|
||||||
|
sanitizer_target_compilers(${TARGET} TARGET_COMPILER)
|
||||||
|
list(LENGTH TARGET_COMPILER NUM_COMPILERS)
|
||||||
|
if (NUM_COMPILERS GREATER 1)
|
||||||
|
message(WARNING "Can't use any sanitizers for target ${TARGET}, "
|
||||||
|
"because it will be compiled by incompatible compilers. "
|
||||||
|
"Target will be compiled without sanitzers.")
|
||||||
|
return()
|
||||||
|
|
||||||
|
# If the target is compiled by no known compiler, ignore it.
|
||||||
|
elseif (NUM_COMPILERS EQUAL 0)
|
||||||
|
message(WARNING "Can't use any sanitizers for target ${TARGET}, "
|
||||||
|
"because it uses an unknown compiler. Target will be "
|
||||||
|
"compiled without sanitzers.")
|
||||||
|
return()
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
# Add sanitizers for target.
|
||||||
add_sanitize_address(${TARGET})
|
add_sanitize_address(${TARGET})
|
||||||
add_sanitize_thread(${TARGET})
|
add_sanitize_thread(${TARGET})
|
||||||
add_sanitize_memory(${TARGET})
|
add_sanitize_memory(${TARGET})
|
||||||
|
@ -139,6 +139,10 @@ function (sanitizer_check_compiler_flags FLAG_CANDIDATES NAME PREFIX)
|
|||||||
set(${PREFIX}_${COMPILER}_FLAGS "" CACHE STRING
|
set(${PREFIX}_${COMPILER}_FLAGS "" CACHE STRING
|
||||||
"${NAME} flags for ${COMPILER} compiler.")
|
"${NAME} flags for ${COMPILER} compiler.")
|
||||||
mark_as_advanced(${PREFIX}_${COMPILER}_FLAGS)
|
mark_as_advanced(${PREFIX}_${COMPILER}_FLAGS)
|
||||||
|
|
||||||
|
message(WARNING "${NAME} is not available for ${COMPILER} "
|
||||||
|
"compiler. Targets using this compiler will be "
|
||||||
|
"compiled without ${NAME}.")
|
||||||
endif ()
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
endforeach ()
|
endforeach ()
|
||||||
@ -147,19 +151,12 @@ endfunction ()
|
|||||||
|
|
||||||
# Helper to assign sanitizer flags for TARGET.
|
# Helper to assign sanitizer flags for TARGET.
|
||||||
function (saitizer_add_flags TARGET NAME PREFIX)
|
function (saitizer_add_flags TARGET NAME PREFIX)
|
||||||
# Get list of compilers used by target and check, if target can be checked
|
# Get list of compilers used by target and check, if sanitizer is available
|
||||||
# by sanitizer.
|
# for this target. Other compiler checks like check for conflicting
|
||||||
|
# compilers will be done in add_sanitizers function.
|
||||||
sanitizer_target_compilers(${TARGET} TARGET_COMPILER)
|
sanitizer_target_compilers(${TARGET} TARGET_COMPILER)
|
||||||
list(LENGTH TARGET_COMPILER NUM_COMPILERS)
|
list(LENGTH TARGET_COMPILER NUM_COMPILERS)
|
||||||
if (NUM_COMPILERS GREATER 1)
|
if ("${${PREFIX}_${TARGET_COMPILER}_FLAGS}" STREQUAL "")
|
||||||
message(WARNING "${NAME} disabled for target ${TARGET} because it will "
|
|
||||||
"be compiled by different compilers.")
|
|
||||||
return()
|
|
||||||
|
|
||||||
elseif ((NUM_COMPILERS EQUAL 0) OR
|
|
||||||
("${${PREFIX}_${TARGET_COMPILER}_FLAGS}" STREQUAL ""))
|
|
||||||
message(WARNING "${NAME} disabled for target ${TARGET} because there is"
|
|
||||||
" no sanitizer available for target sources.")
|
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user