Skip to content

Commit

Permalink
Add OGRE_ADDRESS_SANITIZER_ASAN option (#235)
Browse files Browse the repository at this point in the history
  • Loading branch information
darksylinc committed Jan 7, 2022
1 parent c422bc2 commit 870c68c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 870c68c

Please sign in to comment.