diff --git a/CMakeLists.txt b/CMakeLists.txt index fd85b7c2..75b42172 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,9 +17,25 @@ option(SOLTRACE_BUILD_EMBREE_SUPPORT "Build Embree support for ray tracing" OFF) option(SOLTRACE_BUILD_OPTIX_SUPPORT "Build the OptiX support for ray tracing" OFF) option(SOLTRACE_BUILD_PERF_TEST "Build performance tests (not built for debug)" OFF) +option(SOLTRACE_ENABLE_ASAN "Enable AddressSanitizer for supported builds" OFF) option(FULL_FIELD_VALIDATION_TEST "Include full field validation tests" OFF) +if(SOLTRACE_ENABLE_ASAN) + if(MSVC) + message(WARNING "SOLTRACE_ENABLE_ASAN is not yet supported with MSVC or GCC") + elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang|AppleClang") + message(STATUS "Enabling address sanitizer") + add_compile_options( + $<$:-fsanitize=address> + $<$:-fno-omit-frame-pointer> + ) + add_link_options(-fsanitize=address) + else() + message(WARNING "SOLTRACE_ENABLE_ASAN is only supported with Clang") + endif() +endif() + enable_testing() @@ -29,4 +45,3 @@ add_subdirectory(google-tests) if(SOLTRACE_BUILD_GUI) add_subdirectory(app) endif() -