The aws_check_sanitizer cmake function incorrectly handles the out parameter. The issue is with if(NOT ${ARGN}) check.
When an extra parameter is passed to the function (e.g., aws_check_sanitizer("thread" CUSTOM_OUT_VAR)), if(NOT ${ARGN}) checks the value of this extra parameter. This means that ${CUSTOM_OUT_VAR} will be used as out variable only if it's undefined/false:
aws_check_sanitizer("thread" CUSTOM_OUT_VAR) # sets ${CUSTOM_OUT_VAR} to 1
aws_check_sanitizer("thread" CUSTOM_OUT_VAR) # the second call sets ${HAS_SANITIZER_thread} to 1
When no extra parameter is passed (e.g., aws_check_sanitizer("thread")), this check essentially transforms to if(NOT). Which looks kind of weird, but in practice works fine.
Description of changes:
Check for the number of passed parameter to determine which variable to use as out parameter.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Issue #, if available:
The
aws_check_sanitizer
cmake function incorrectly handles the out parameter. The issue is withif(NOT ${ARGN})
check.When an extra parameter is passed to the function (e.g.,
aws_check_sanitizer("thread" CUSTOM_OUT_VAR)
),if(NOT ${ARGN})
checks the value of this extra parameter. This means that${CUSTOM_OUT_VAR}
will be used as out variable only if it's undefined/false:When no extra parameter is passed (e.g.,
aws_check_sanitizer("thread")
), this check essentially transforms toif(NOT)
. Which looks kind of weird, but in practice works fine.Description of changes:
Check for the number of passed parameter to determine which variable to use as out parameter.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.