aws-c-common
aws-c-common copied to clipboard
Add IS_CXX option to sanitizer cmake module
Issue #, if available:
aws_check_sanitizer
checks for the sanitizer flags using check_c_compiler_flag
. However, for C++ projects C language could be not enabled, which leads to the following error:
CMake Error at /usr/share/cmake3/Modules/CheckCSourceCompiles.cmake:109 (try_compile):
Unknown extension ".c" for file
aws-iot-device-sdk-cpp-v2/samples/mqtt5/mqtt5_pubsub/cmake-build-tsan/CMakeFiles/CMakeTmp/src.c
try_compile() works only for enabled languages. Currently these are:
CXX
See project() command to enable other languages.
A possible solution could be to add enable_language(C)
before calling check_c_compiler_flag
. But I'm not sure that C++ and C compilers have the same set of the sanitizer options. And even if they do currently, this might change.
So, using check_cxx_compiler_flag
for C++ project looks like a more correct approach.
Description of changes:
Add IS_CXX
option to aws_check_sanitizer
and aws_add_sanitizers
CMake functions.
This change does not break or change the existing usages of these functions.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.