Merge pull request #10 from RWTH-ELP/feature/fewer_messages
Show fewer warnings for targets.
This commit is contained in:
commit
295c360967
@ -53,7 +53,32 @@ function(sanitizer_add_blacklist_file FILE)
|
||||
endfunction()
|
||||
|
||||
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})
|
||||
# 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_thread(${TARGET})
|
||||
add_sanitize_memory(${TARGET})
|
||||
|
@ -139,6 +139,10 @@ function (sanitizer_check_compiler_flags FLAG_CANDIDATES NAME PREFIX)
|
||||
set(${PREFIX}_${COMPILER}_FLAGS "" CACHE STRING
|
||||
"${NAME} flags for ${COMPILER} compiler.")
|
||||
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 ()
|
||||
endforeach ()
|
||||
@ -147,19 +151,12 @@ endfunction ()
|
||||
|
||||
# Helper to assign sanitizer flags for TARGET.
|
||||
function (saitizer_add_flags TARGET NAME PREFIX)
|
||||
# Get list of compilers used by target and check, if target can be checked
|
||||
# by sanitizer.
|
||||
# Get list of compilers used by target and check, if sanitizer is available
|
||||
# for this target. Other compiler checks like check for conflicting
|
||||
# compilers will be done in add_sanitizers function.
|
||||
sanitizer_target_compilers(${TARGET} TARGET_COMPILER)
|
||||
list(LENGTH TARGET_COMPILER NUM_COMPILERS)
|
||||
if (NUM_COMPILERS GREATER 1)
|
||||
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.")
|
||||
if ("${${PREFIX}_${TARGET_COMPILER}_FLAGS}" STREQUAL "")
|
||||
return()
|
||||
endif()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user