Check flags availability for sanitization

This commit is contained in:
PM 2025-09-05 17:10:17 -03:00
parent 1bc5105272
commit 75d1546476

View file

@ -2,9 +2,19 @@ cmake_minimum_required(VERSION 3.27)
project(clay_examples_cpp_project_example CXX) project(clay_examples_cpp_project_example CXX)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -g") macro(add_checked_flag FLAG)
endif() include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("${FLAG}" SUPPORTED)
if(SUPPORTED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}")
else()
message(WARNING "${FLAG} not supported")
endif()
endmacro()
add_checked_flag("-fsanitize=address")
add_checked_flag("-fno-omit-frame-pointer")
add_executable(clay_examples_cpp_project_example main.cpp) add_executable(clay_examples_cpp_project_example main.cpp)