Flags will be searched only once per compiler.

If a compiler does not support sanitizing, it will not be checked a second time.
This commit is contained in:
Alexander Haase 2016-04-06 19:39:47 +02:00
parent de1a134183
commit 6975d64d6b

View File

@ -76,7 +76,7 @@ function (sanitizer_check_compiler_flags FLAG_CANDIDATES NAME PREFIX)
# So instead of searching flags foreach language, search flags foreach # So instead of searching flags foreach language, search flags foreach
# compiler used. # compiler used.
set(COMPILER ${CMAKE_${LANG}_COMPILER_ID}) set(COMPILER ${CMAKE_${LANG}_COMPILER_ID})
if (NOT ${PREFIX}_${COMPILER}_FLAGS) if (NOT DEFINED ${PREFIX}_${COMPILER}_FLAGS)
foreach (FLAG ${FLAG_CANDIDATES}) foreach (FLAG ${FLAG_CANDIDATES})
if(NOT CMAKE_REQUIRED_QUIET) if(NOT CMAKE_REQUIRED_QUIET)
message(STATUS "Try ${COMPILER} ${NAME} flag = [${FLAG}]") message(STATUS "Try ${COMPILER} ${NAME} flag = [${FLAG}]")
@ -118,6 +118,12 @@ function (sanitizer_check_compiler_flags FLAG_CANDIDATES NAME PREFIX)
break() break()
endif () endif ()
endforeach () endforeach ()
if (NOT ${PREFIX}_FLAG_DETECTED)
set(${PREFIX}_${COMPILER}_FLAGS "" CACHE STRING
"${NAME} flags for ${COMPILER} compiler.")
mark_as_advanced(${PREFIX}_${COMPILER}_FLAGS)
endif ()
endif () endif ()
endforeach () endforeach ()
endfunction () endfunction ()
@ -135,7 +141,7 @@ function (saitizer_add_flags TARGET NAME PREFIX)
return() return()
elseif ((NUM_COMPILERS EQUAL 0) OR elseif ((NUM_COMPILERS EQUAL 0) OR
(NOT DEFINED "${PREFIX}_${TARGET_COMPILER}_FLAGS")) ("${${PREFIX}_${TARGET_COMPILER}_FLAGS}" STREQUAL ""))
message(WARNING "${NAME} disabled for target ${TARGET} because there is" message(WARNING "${NAME} disabled for target ${TARGET} because there is"
" no sanitizer available for target sources.") " no sanitizer available for target sources.")
return() return()