Skip to content

Commit

Permalink
Support sanitizer for C++ projects
Browse files Browse the repository at this point in the history
  • Loading branch information
sfodagain committed Feb 21, 2025
1 parent 6401c83 commit c7ad18c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmake/AwsSanitizers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0.

include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)

option(ENABLE_SANITIZERS "Enable sanitizers in debug builds" OFF)
set(SANITIZERS "address;undefined" CACHE STRING "List of sanitizers to build with")
Expand Down Expand Up @@ -32,7 +33,12 @@ function(aws_check_sanitizer sanitizer)

# Need to set this here so that the flag is passed to the linker
set(CMAKE_REQUIRED_FLAGS ${sanitizer_test_flag})
check_c_compiler_flag(${sanitizer_test_flag} ${out_variable})
if(${CMAKE_C_COMPILER_LOADED})
check_c_compiler_flag(${sanitizer_test_flag} ${out_variable})
endif()
if(${CMAKE_CXX_COMPILER_LOADED})
check_cxx_compiler_flag(${sanitizer_test_flag} ${out_variable})
endif()
else()
set(${out_variable} 0 PARENT_SCOPE)
endif()
Expand Down

0 comments on commit c7ad18c

Please sign in to comment.