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.
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 83.44%. Comparing base (
852f8ce) to head (440b05a). Report is 9 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #1135 +/- ##
=======================================
Coverage 83.44% 83.44%
=======================================
Files 57 57
Lines 5985 5985
=======================================
Hits 4994 4994
Misses 991 991
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.