diff --git a/CMakeLists.txt b/CMakeLists.txt index 29be9185a22..8bcb41c2a13 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -451,6 +451,8 @@ if( APPLE ) endif() option(OGRE_BUILD_PLUGIN_PFX "Build ParticleFX plugin" TRUE) +option( OGRE_ADDRESS_SANITIZER_ASAN "Build with Asan (Address Sanitizer)" OFF ) + cmake_dependent_option(OGRE_BUILD_COMPONENT_HLMS_PBS "PBS Stands for Physically Based Shading and it's the default material for most entities and meshes. This is the 'desktop' version for OpenGL 3.3+ and D3D11." TRUE "" FALSE) cmake_dependent_option(OGRE_BUILD_COMPONENT_HLMS_UNLIT @@ -572,8 +574,26 @@ if( NOT Remotery_FOUND AND OGRE_PROFILING_PROVIDER STREQUAL "remotery" ) set( OGRE_PROFILING_PROVIDER "none" ) endif() +if( OGRE_ADDRESS_SANITIZER_ASAN ) + if( APPLE ) + set( CMAKE_XCODE_GENERATE_SCHEME ON ) + set( CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER ON ) + set( CMAKE_XCODE_SCHEME_ADDRESS_SANITIZER_USE_AFTER_RETURN ON ) + elseif( UNIX ) + set( CMAKE_C_FLAGS + "${CMAKE_C_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=address" ) + set( CMAKE_CXX_FLAGS + "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer -fno-optimize-sibling-calls -fsanitize=address" ) + set( CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fsanitize=address" ) + elseif (MSVC) + set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS_DEBUG} /fsanitize=address" ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_DEBUG} /fsanitize=address" ) + endif() +endif() + # hide advanced options mark_as_advanced( + OGRE_ADDRESS_SANITIZER_ASAN OGRE_CONFIG_DOUBLE OGRE_CONFIG_NODE_INHERIT_TRANSFORM OGRE_CONFIG_ALLOCATOR